fix: check if the custom channel's server address is valid

This commit is contained in:
JustSong
2023-05-08 22:39:38 +08:00
parent 82068de143
commit 4796b7dd69
+4
View File
@@ -3,6 +3,7 @@ package channel
import (
"bytes"
"errors"
"message-pusher/common"
"message-pusher/model"
"net/http"
"strings"
@@ -13,6 +14,9 @@ func SendCustomMessage(message *model.Message, user *model.User, channel_ *model
if strings.HasPrefix(url, "http:") {
return errors.New("自定义通道必须使用 HTTPS 协议")
}
if strings.HasPrefix(url, common.ServerAddress) {
return errors.New("自定义通道不能使用本服务地址")
}
template := channel_.Other
template = strings.Replace(template, "$url", message.URL, -1)
template = strings.Replace(template, "$to", message.To, -1)