Skip to content

Commit

Permalink
fix: check if the custom channel's server address is valid
Browse files Browse the repository at this point in the history
  • Loading branch information
songquanpeng committed May 8, 2023
1 parent 82068de commit 4796b7d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions channel/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package channel
import (
"bytes"
"errors"
"message-pusher/common"
"message-pusher/model"
"net/http"
"strings"
Expand All @@ -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)
Expand Down

0 comments on commit 4796b7d

Please sign in to comment.