chore: refactor lint code
This commit is contained in:
@@ -29,7 +29,7 @@ func NotifyTokenAuth() gin.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
if strings.ToLower(token) != strings.ToLower(savedToken) {
|
||||
if !strings.EqualFold(token, savedToken) {
|
||||
utils.Unauthorized(c, "通知 Token 无效")
|
||||
c.Abort()
|
||||
return
|
||||
|
||||
@@ -26,11 +26,12 @@ func (c *DtalkChannel) Send(config ChannelConfig, msg *Message) (*Result, error)
|
||||
var res []byte
|
||||
var err error
|
||||
|
||||
if contentType == FormatTypeText {
|
||||
switch contentType {
|
||||
case FormatTypeText:
|
||||
res, err = cli.SendMessageText(formattedContent, atMobiles...)
|
||||
} else if contentType == FormatTypeMarkdown {
|
||||
case FormatTypeMarkdown:
|
||||
res, err = cli.SendMessageMarkdown(msg.Title, formattedContent, atMobiles...)
|
||||
} else {
|
||||
default:
|
||||
return SendError("未知的钉钉发送内容类型:%s", contentType), nil
|
||||
}
|
||||
|
||||
|
||||
@@ -34,11 +34,12 @@ func (c *EmailChannel) Send(config ChannelConfig, msg *Message) (*Result, error)
|
||||
emailer.Init(server, port, account, passwd, fromName)
|
||||
|
||||
var errMsg string
|
||||
if contentType == FormatTypeText {
|
||||
switch contentType {
|
||||
case FormatTypeText:
|
||||
errMsg = emailer.SendTextMessage(toAccount, msg.Title, formattedContent)
|
||||
} else if contentType == FormatTypeHTML {
|
||||
case FormatTypeHTML:
|
||||
errMsg = emailer.SendHtmlMessage(toAccount, msg.Title, formattedContent)
|
||||
} else {
|
||||
default:
|
||||
errMsg = fmt.Sprintf("未知的邮件发送内容类型:%s", contentType)
|
||||
}
|
||||
|
||||
|
||||
@@ -28,11 +28,12 @@ func (c *FeishuChannel) Send(config ChannelConfig, msg *Message) (*Result, error
|
||||
var res []byte
|
||||
var err error
|
||||
|
||||
if contentType == FormatTypeText {
|
||||
switch contentType {
|
||||
case FormatTypeText:
|
||||
res, err = cli.SendMessageText(formattedContent, atList...)
|
||||
} else if contentType == FormatTypeMarkdown {
|
||||
case FormatTypeMarkdown:
|
||||
res, err = cli.SendMessageMarkdown(msg.Title, formattedContent, atList...)
|
||||
} else {
|
||||
default:
|
||||
return SendError("未知的飞书发送内容类型:%s", contentType), nil
|
||||
}
|
||||
|
||||
|
||||
@@ -34,10 +34,8 @@ func sendAliyunSMS(client *dysmsapi.Client, phoneNumber, signName, templateCode,
|
||||
templateParam := map[string]interface{}{
|
||||
"content": content,
|
||||
}
|
||||
if extra != nil {
|
||||
for k, v := range extra {
|
||||
templateParam[k] = v
|
||||
}
|
||||
for k, v := range extra {
|
||||
templateParam[k] = v
|
||||
}
|
||||
templateParamJSON, _ := json.Marshal(templateParam)
|
||||
|
||||
|
||||
@@ -27,11 +27,12 @@ func (c *QyWeiXinChannel) Send(config ChannelConfig, msg *Message) (*Result, err
|
||||
var res []byte
|
||||
var err error
|
||||
|
||||
if contentType == FormatTypeText {
|
||||
switch contentType {
|
||||
case FormatTypeText:
|
||||
res, err = cli.SendMessageText(formattedContent, atList...)
|
||||
} else if contentType == FormatTypeMarkdown {
|
||||
case FormatTypeMarkdown:
|
||||
res, err = cli.SendMessageMarkdown(msg.Title, formattedContent, atList...)
|
||||
} else {
|
||||
default:
|
||||
return SendError("未知的企业微信发送内容类型:%s", contentType), nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user