feat: allow non-https when CHANNEL_URL_ALLOW_NON_HTTPS is true (close #153)

This commit is contained in:
JustSong
2025-02-11 00:52:32 +08:00
parent 109756674f
commit 9b45ba2505

View File

@@ -3,15 +3,17 @@ package channel
import (
"bytes"
"errors"
"net/http"
"os"
"strings"
"message-pusher/common"
"message-pusher/model"
"net/http"
"strings"
)
func SendCustomMessage(message *model.Message, user *model.User, channel_ *model.Channel) error {
url := channel_.URL
if strings.HasPrefix(url, "http:") {
if strings.HasPrefix(url, "http:") && os.Getenv("CHANNEL_URL_ALLOW_NON_HTTPS") != "true" {
return errors.New("自定义通道必须使用 HTTPS 协议")
}
if strings.HasPrefix(url, common.ServerAddress) {