sender

package
v0.0.0-...-2b29b9b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 25, 2024 License: Apache-2.0 Imports: 25 Imported by: 1

Documentation

Overview

Copyright 2019 Yunion

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	ApiWebhookRobotV2SendMessage = "https://open.feishu.cn/open-apis/bot/v2/hook/"
	// 钉钉发送消息
	ApiDingtalkSendMessage = "https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2?"
	// 钉钉获取token
	ApiDingtalkGetToken = "https://oapi.dingtalk.com/gettoken?"
	// 钉钉使用手机号获取用户ID
	ApiDingtalkGetUserByMobile = "https://oapi.dingtalk.com/topapi/v2/user/getbymobile?"
	// 钉钉获取消息发送结果
	ApiDingtalkGetSendResult = "https://oapi.dingtalk.com/topapi/message/corpconversation/getsendresult?"
	// 企业微信获取token
	ApiWorkwxGetToken = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?"
	// 企业微信使用手机号获取用户ID
	ApiWorkwxGetUserByMobile = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserid?"
	// 企业微信发送消息
	ApiWorkwxSendMessage = "https://qyapi.weixin.qq.com/cgi-bin/message/send?"
	// 飞书使用手机号或邮箱获取用户ID
	ApiFetchUserID = "https://open.feishu.cn/open-apis/user/v1/batch_get_id?"
)
View Source
const ApiSendMessageForFeishuByOpenId = feishu.ApiRobotSendMessage + "?receive_id_type=open_id"
View Source
const EVENT_HEADER = "X-Yunion-Event"
View Source
const (
	LARK_MESSAGE_SUCCESS = "success"
)
View Source
const (
	WEBHOOK_PREFIX = "https://oapi.dingtalk.com/robot/send?access_token="
)

Variables

View Source
var (
	ErrIPWhiteList         = errors.Error("Need to add ip to whtelist")
	ErrNoSupportSecSetting = errors.Error("Only the IP address option in the security Settings is supported")
	ErrNoSuchMobile        = errors.Error("No such mobile")
	ErrIncompleteConfig    = errors.Error("Incomplete config")
	ErrDuplicateConfig     = errors.Error("Duplicate config for a domain")
)
View Source
var ErrNoSuchWebhook = errors.Error("No such webhook")
View Source
var (
	FAIL_KEY = []string{"失败", "fail ", "failed"}
)
View Source
var InvalidWebhook = errors.Error("Invalid webhook")

Functions

This section is empty.

Types

type SDingTalkRobotSender

type SDingTalkRobotSender struct {
	// contains filtered or unexported fields
}

func (*SDingTalkRobotSender) ContactByMobile

func (dingRobotSender *SDingTalkRobotSender) ContactByMobile(ctx context.Context, mobile, domainId string) (string, error)

func (*SDingTalkRobotSender) GetAccessToken

func (dingRobotSender *SDingTalkRobotSender) GetAccessToken(ctx context.Context, key string) error

func (*SDingTalkRobotSender) GetSenderType

func (dingRobotSender *SDingTalkRobotSender) GetSenderType() string

func (*SDingTalkRobotSender) IsPersonal

func (dingRobotSender *SDingTalkRobotSender) IsPersonal() bool

func (*SDingTalkRobotSender) IsPullType

func (dingRobotSender *SDingTalkRobotSender) IsPullType() bool

func (*SDingTalkRobotSender) IsRobot

func (dingRobotSender *SDingTalkRobotSender) IsRobot() bool

func (*SDingTalkRobotSender) IsSystemConfigContactType

func (dingRobotSender *SDingTalkRobotSender) IsSystemConfigContactType() bool

func (*SDingTalkRobotSender) IsValid

func (dingRobotSender *SDingTalkRobotSender) IsValid() bool

func (*SDingTalkRobotSender) RegisterConfig

func (dingRobotSender *SDingTalkRobotSender) RegisterConfig(config models.SConfig)

func (*SDingTalkRobotSender) Send

func (dingRobotSender *SDingTalkRobotSender) Send(ctx context.Context, args api.SendParams) error

func (*SDingTalkRobotSender) ValidateConfig

func (dingRobotSender *SDingTalkRobotSender) ValidateConfig(ctx context.Context, config api.NotifyConfig) (string, error)

type SDingTalkSender

type SDingTalkSender struct {
	// contains filtered or unexported fields
}

func (*SDingTalkSender) ContactByMobile

func (dingSender *SDingTalkSender) ContactByMobile(ctx context.Context, mobile, domainId string) (string, error)

func (*SDingTalkSender) GetAccessToken

func (dingSender *SDingTalkSender) GetAccessToken(ctx context.Context, domainId string) error

func (*SDingTalkSender) GetSenderType

func (dingSender *SDingTalkSender) GetSenderType() string

func (*SDingTalkSender) IsPersonal

func (dingSender *SDingTalkSender) IsPersonal() bool

func (*SDingTalkSender) IsPullType

func (dingSender *SDingTalkSender) IsPullType() bool

func (*SDingTalkSender) IsRobot

func (dingSender *SDingTalkSender) IsRobot() bool

func (*SDingTalkSender) IsSystemConfigContactType

func (dingSender *SDingTalkSender) IsSystemConfigContactType() bool

func (*SDingTalkSender) IsValid

func (dingSender *SDingTalkSender) IsValid() bool

func (*SDingTalkSender) RegisterConfig

func (dingSender *SDingTalkSender) RegisterConfig(config models.SConfig)

func (*SDingTalkSender) Send

func (dingSender *SDingTalkSender) Send(ctx context.Context, args api.SendParams) error

func (*SDingTalkSender) ValidateConfig

func (dingSender *SDingTalkSender) ValidateConfig(ctx context.Context, config api.NotifyConfig) (string, error)

type SEmailSender

type SEmailSender struct {
	// contains filtered or unexported fields
}

func (*SEmailSender) ContactByMobile

func (emailSender *SEmailSender) ContactByMobile(ctx context.Context, mobile, domainId string) (string, error)

func (*SEmailSender) GetAccessToken

func (emailSender *SEmailSender) GetAccessToken(ctx context.Context, key string) error

func (*SEmailSender) GetSenderType

func (emailSender *SEmailSender) GetSenderType() string

func (*SEmailSender) IsPersonal

func (emailSender *SEmailSender) IsPersonal() bool

func (*SEmailSender) IsPullType

func (emailSender *SEmailSender) IsPullType() bool

func (*SEmailSender) IsRobot

func (emailSender *SEmailSender) IsRobot() bool

func (*SEmailSender) IsSystemConfigContactType

func (emailSender *SEmailSender) IsSystemConfigContactType() bool

func (*SEmailSender) IsValid

func (emailSender *SEmailSender) IsValid() bool

func (*SEmailSender) RegisterConfig

func (emailSender *SEmailSender) RegisterConfig(config models.SConfig)

func (*SEmailSender) Send

func (emailSender *SEmailSender) Send(ctx context.Context, args api.SendParams) error

func (*SEmailSender) ValidateConfig

func (emailSender *SEmailSender) ValidateConfig(ctx context.Context, config api.NotifyConfig) (string, error)

type SFeishuRobotSender

type SFeishuRobotSender struct {
	// contains filtered or unexported fields
}

func (*SFeishuRobotSender) ContactByMobile

func (feishuRobotSender *SFeishuRobotSender) ContactByMobile(ctx context.Context, mobile, domainId string) (string, error)

func (*SFeishuRobotSender) GetAccessToken

func (feishuRobotSender *SFeishuRobotSender) GetAccessToken(ctx context.Context, key string) error

func (*SFeishuRobotSender) GetSenderType

func (feishuRobotSender *SFeishuRobotSender) GetSenderType() string

func (*SFeishuRobotSender) IsPersonal

func (feishuRobotSender *SFeishuRobotSender) IsPersonal() bool

func (*SFeishuRobotSender) IsPullType

func (feishuRobotSender *SFeishuRobotSender) IsPullType() bool

func (*SFeishuRobotSender) IsRobot

func (feishuRobotSender *SFeishuRobotSender) IsRobot() bool

func (*SFeishuRobotSender) IsSystemConfigContactType

func (feishuRobotSender *SFeishuRobotSender) IsSystemConfigContactType() bool

func (*SFeishuRobotSender) IsValid

func (feishuRobotSender *SFeishuRobotSender) IsValid() bool

func (*SFeishuRobotSender) RegisterConfig

func (feishuRobotSender *SFeishuRobotSender) RegisterConfig(config models.SConfig)

func (*SFeishuRobotSender) Send

func (feishuRobotSender *SFeishuRobotSender) Send(ctx context.Context, args api.SendParams) error

func (*SFeishuRobotSender) ValidateConfig

func (feishuRobotSender *SFeishuRobotSender) ValidateConfig(ctx context.Context, config api.NotifyConfig) (string, error)

type SFeishuSender

type SFeishuSender struct {
	// contains filtered or unexported fields
}

func (*SFeishuSender) ContactByMobile

func (feishuSender *SFeishuSender) ContactByMobile(ctx context.Context, mobile, domainId string) (string, error)

根据用户手机号获取用户的open_id

func (*SFeishuSender) GetAccessToken

func (feishuSender *SFeishuSender) GetAccessToken(ctx context.Context, domainId string) error

获取token

func (*SFeishuSender) GetSenderType

func (self *SFeishuSender) GetSenderType() string

func (*SFeishuSender) IsPersonal

func (feishuSender *SFeishuSender) IsPersonal() bool

func (*SFeishuSender) IsPullType

func (feishuSender *SFeishuSender) IsPullType() bool

func (*SFeishuSender) IsRobot

func (feishuSender *SFeishuSender) IsRobot() bool

func (*SFeishuSender) IsSystemConfigContactType

func (feishuSender *SFeishuSender) IsSystemConfigContactType() bool

func (*SFeishuSender) IsValid

func (feishuSender *SFeishuSender) IsValid() bool

func (*SFeishuSender) RegisterConfig

func (feishuSender *SFeishuSender) RegisterConfig(config models.SConfig)

func (*SFeishuSender) Send

func (feishuSender *SFeishuSender) Send(ctx context.Context, args api.SendParams) error

发送飞书消息

func (*SFeishuSender) ValidateConfig

func (feishuSender *SFeishuSender) ValidateConfig(ctx context.Context, config api.NotifyConfig) (string, error)

校验appId与appSecret

type SMobileSender

type SMobileSender struct {
	// contains filtered or unexported fields
}

func (*SMobileSender) AddConfig

func (smsSender *SMobileSender) AddConfig(config api.NotifyConfig) error

func (*SMobileSender) ContactByMobile

func (smsSender *SMobileSender) ContactByMobile(ctx context.Context, mobile, domainId string) (string, error)

func (*SMobileSender) DeleteConfig

func (smsSender *SMobileSender) DeleteConfig(config api.NotifyConfig) error

func (*SMobileSender) GetAccessToken

func (smsSender *SMobileSender) GetAccessToken(ctx context.Context, key string) error

func (*SMobileSender) GetSenderType

func (smsSender *SMobileSender) GetSenderType() string

func (*SMobileSender) IsPersonal

func (smsSender *SMobileSender) IsPersonal() bool

func (*SMobileSender) IsPullType

func (smsSender *SMobileSender) IsPullType() bool

func (*SMobileSender) IsRobot

func (smsSender *SMobileSender) IsRobot() bool

func (*SMobileSender) IsSystemConfigContactType

func (smsSender *SMobileSender) IsSystemConfigContactType() bool

func (*SMobileSender) IsValid

func (smsSender *SMobileSender) IsValid() bool

func (*SMobileSender) RegisterConfig

func (smsSender *SMobileSender) RegisterConfig(config models.SConfig)

func (*SMobileSender) Send

func (smsSender *SMobileSender) Send(ctx context.Context, args api.SendParams) error

func (*SMobileSender) UpdateConfig

func (smsSender *SMobileSender) UpdateConfig(config api.NotifyConfig) error

func (*SMobileSender) ValidateConfig

func (smsSender *SMobileSender) ValidateConfig(ctx context.Context, config api.NotifyConfig) (string, error)

type SWebconsoleSender

type SWebconsoleSender struct {
	// contains filtered or unexported fields
}

func (*SWebconsoleSender) AddConfig

func (websender *SWebconsoleSender) AddConfig(config api.NotifyConfig) error

func (*SWebconsoleSender) ContactByMobile

func (websender *SWebconsoleSender) ContactByMobile(ctx context.Context, mobile, domainId string) (string, error)

func (*SWebconsoleSender) DeleteConfig

func (websender *SWebconsoleSender) DeleteConfig(config api.NotifyConfig) error

func (*SWebconsoleSender) GetAccessToken

func (websender *SWebconsoleSender) GetAccessToken(ctx context.Context, key string) error

func (*SWebconsoleSender) GetSenderType

func (self *SWebconsoleSender) GetSenderType() string

func (*SWebconsoleSender) IsPersonal

func (websender *SWebconsoleSender) IsPersonal() bool

func (*SWebconsoleSender) IsPullType

func (websender *SWebconsoleSender) IsPullType() bool

func (*SWebconsoleSender) IsRobot

func (websender *SWebconsoleSender) IsRobot() bool

func (*SWebconsoleSender) IsSystemConfigContactType

func (websender *SWebconsoleSender) IsSystemConfigContactType() bool

func (*SWebconsoleSender) IsValid

func (websender *SWebconsoleSender) IsValid() bool

func (*SWebconsoleSender) RegisterConfig

func (websender *SWebconsoleSender) RegisterConfig(config models.SConfig)

func (*SWebconsoleSender) Send

func (self *SWebconsoleSender) Send(ctx context.Context, args api.SendParams) error

func (*SWebconsoleSender) UpdateConfig

func (websender *SWebconsoleSender) UpdateConfig(config api.NotifyConfig) error

func (*SWebconsoleSender) ValidateConfig

func (websender *SWebconsoleSender) ValidateConfig(ctx context.Context, config api.NotifyConfig) (string, error)

type SWebhookSender

type SWebhookSender struct {
	// contains filtered or unexported fields
}

func (*SWebhookSender) AddConfig

func (websender *SWebhookSender) AddConfig(config api.NotifyConfig) error

func (*SWebhookSender) ContactByMobile

func (websender *SWebhookSender) ContactByMobile(ctx context.Context, mobile, domainId string) (string, error)

func (*SWebhookSender) DeleteConfig

func (websender *SWebhookSender) DeleteConfig(config api.NotifyConfig) error

func (*SWebhookSender) GetAccessToken

func (websender *SWebhookSender) GetAccessToken(ctx context.Context, key string) error

func (*SWebhookSender) GetSenderType

func (self *SWebhookSender) GetSenderType() string

func (*SWebhookSender) IsPersonal

func (websender *SWebhookSender) IsPersonal() bool

func (*SWebhookSender) IsPullType

func (websender *SWebhookSender) IsPullType() bool

func (*SWebhookSender) IsRobot

func (websender *SWebhookSender) IsRobot() bool

func (*SWebhookSender) IsSystemConfigContactType

func (websender *SWebhookSender) IsSystemConfigContactType() bool

func (*SWebhookSender) IsValid

func (websender *SWebhookSender) IsValid() bool

func (*SWebhookSender) RegisterConfig

func (websender *SWebhookSender) RegisterConfig(config models.SConfig)

func (*SWebhookSender) Send

func (self *SWebhookSender) Send(ctx context.Context, args api.SendParams) error

func (*SWebhookSender) UpdateConfig

func (websender *SWebhookSender) UpdateConfig(config api.NotifyConfig) error

func (*SWebhookSender) ValidateConfig

func (websender *SWebhookSender) ValidateConfig(ctx context.Context, config api.NotifyConfig) (string, error)

type SWebsocketSender

type SWebsocketSender struct {
	// contains filtered or unexported fields
}

func (*SWebsocketSender) ContactByMobile

func (websocket *SWebsocketSender) ContactByMobile(ctx context.Context, mobile, domainId string) (string, error)

func (*SWebsocketSender) GetAccessToken

func (websocket *SWebsocketSender) GetAccessToken(ctx context.Context, key string) error

func (*SWebsocketSender) GetSenderType

func (websocket *SWebsocketSender) GetSenderType() string

func (*SWebsocketSender) IsPersonal

func (websocket *SWebsocketSender) IsPersonal() bool

func (*SWebsocketSender) IsPullType

func (websocket *SWebsocketSender) IsPullType() bool

func (*SWebsocketSender) IsRobot

func (websocket *SWebsocketSender) IsRobot() bool

func (*SWebsocketSender) IsSystemConfigContactType

func (websocket *SWebsocketSender) IsSystemConfigContactType() bool

func (*SWebsocketSender) IsValid

func (websocket *SWebsocketSender) IsValid() bool

func (*SWebsocketSender) RegisterConfig

func (websocket *SWebsocketSender) RegisterConfig(config models.SConfig)

func (*SWebsocketSender) Send

func (websocket *SWebsocketSender) Send(ctx context.Context, params api.SendParams) error

func (*SWebsocketSender) ValidateConfig

func (websocket *SWebsocketSender) ValidateConfig(ctx context.Context, config api.NotifyConfig) (string, error)

type SWorkwxRobotSender

type SWorkwxRobotSender struct {
	// contains filtered or unexported fields
}

func (*SWorkwxRobotSender) ContactByMobile

func (workwxRobotSender *SWorkwxRobotSender) ContactByMobile(ctx context.Context, mobile, domainId string) (string, error)

func (*SWorkwxRobotSender) GetAccessToken

func (workwxRobotSender *SWorkwxRobotSender) GetAccessToken(ctx context.Context, key string) error

func (*SWorkwxRobotSender) GetSenderType

func (workwxRobotSender *SWorkwxRobotSender) GetSenderType() string

func (*SWorkwxRobotSender) IsPersonal

func (workwxRobotSender *SWorkwxRobotSender) IsPersonal() bool

func (*SWorkwxRobotSender) IsPullType

func (workwxRobotSender *SWorkwxRobotSender) IsPullType() bool

func (*SWorkwxRobotSender) IsRobot

func (workwxRobotSender *SWorkwxRobotSender) IsRobot() bool

func (*SWorkwxRobotSender) IsSystemConfigContactType

func (workwxRobotSender *SWorkwxRobotSender) IsSystemConfigContactType() bool

func (*SWorkwxRobotSender) IsValid

func (workwxRobotSender *SWorkwxRobotSender) IsValid() bool

func (*SWorkwxRobotSender) RegisterConfig

func (workwxRobotSender *SWorkwxRobotSender) RegisterConfig(config models.SConfig)

func (*SWorkwxRobotSender) Send

func (workwxRobotSender *SWorkwxRobotSender) Send(ctx context.Context, args api.SendParams) error

func (*SWorkwxRobotSender) ValidateConfig

func (workwxRobotSender *SWorkwxRobotSender) ValidateConfig(ctx context.Context, config api.NotifyConfig) (string, error)

type SWorkwxSender

type SWorkwxSender struct {
	// contains filtered or unexported fields
}

func (*SWorkwxSender) ContactByMobile

func (workwxSender *SWorkwxSender) ContactByMobile(ctx context.Context, mobile, domainId string) (string, error)

func (*SWorkwxSender) GetAccessToken

func (workwxSender *SWorkwxSender) GetAccessToken(ctx context.Context, domainId string) error

func (*SWorkwxSender) GetSenderType

func (workwxSender *SWorkwxSender) GetSenderType() string

func (*SWorkwxSender) IsPersonal

func (workwxSender *SWorkwxSender) IsPersonal() bool

func (*SWorkwxSender) IsPullType

func (workwxSender *SWorkwxSender) IsPullType() bool

func (*SWorkwxSender) IsRobot

func (workwxSender *SWorkwxSender) IsRobot() bool

func (*SWorkwxSender) IsSystemConfigContactType

func (workwxSender *SWorkwxSender) IsSystemConfigContactType() bool

func (*SWorkwxSender) IsValid

func (workwxSender *SWorkwxSender) IsValid() bool

func (*SWorkwxSender) RegisterConfig

func (workwxSender *SWorkwxSender) RegisterConfig(config models.SConfig)

func (*SWorkwxSender) Send

func (workwxSender *SWorkwxSender) Send(ctx context.Context, args api.SendParams) error

func (*SWorkwxSender) ValidateConfig

func (workwxSender *SWorkwxSender) ValidateConfig(ctx context.Context, config api.NotifyConfig) (string, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL