refactor: Update SMTPPort type to int in NotificationChannelV2 model

This commit is contained in:
Marvin Zhang
2024-07-22 17:34:55 +08:00
parent b33c61a893
commit c893b5452e
2 changed files with 2 additions and 9 deletions

View File

@@ -8,7 +8,7 @@ type NotificationChannelV2 struct {
Description string `json:"description" bson:"description"`
Provider string `json:"provider" bson:"provider"`
SMTPServer string `json:"smtp_server" bson:"smtp_server"`
SMTPPort string `json:"smtp_port" bson:"smtp_port"`
SMTPPort int `json:"smtp_port" bson:"smtp_port"`
SMTPUsername string `json:"smtp_username" bson:"smtp_username"`
SMTPPassword string `json:"smtp_password" bson:"smtp_password"`
WebhookUrl string `json:"webhook_url" bson:"webhook_url"`

View File

@@ -10,21 +10,14 @@ import (
"net/mail"
"regexp"
"runtime/debug"
"strconv"
"strings"
)
func SendMail(s *models.NotificationSettingV2, ch *models.NotificationChannelV2, to, cc, bcc, title, content string) error {
// config
port, err := strconv.Atoi(ch.SMTPPort)
if err != nil {
log.Errorf("failed to convert SMTP port to int: %v", err)
trace.PrintError(err)
return err
}
smtpConfig := smtpAuthentication{
Server: ch.SMTPServer,
Port: port,
Port: ch.SMTPPort,
SenderIdentity: s.SenderName,
SenderEmail: s.SenderEmail,
SMTPUser: ch.SMTPUsername,