feat(notifications): add support for custom Telegram api url (#1508)

feat(notifications): Add support for reverse proxyed telegram api
This commit is contained in:
KyokoMiki 2024-04-15 21:06:22 +08:00 committed by GitHub
parent 72ca7a8a4f
commit c43e2c76d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 1 deletions

View file

@ -73,7 +73,15 @@ func (s *telegramSender) Send(event domain.NotificationEvent, payload domain.Not
return errors.Wrap(err, "could not marshal data: %+v", m) return errors.Wrap(err, "could not marshal data: %+v", m)
} }
url := fmt.Sprintf("https://api.telegram.org/bot%v/sendMessage", s.Settings.Token) var host string
if s.Settings.Host == "" {
host = "https://api.telegram.org"
} else {
host = s.Settings.Host
}
url := fmt.Sprintf("%v/bot%v/sendMessage", host, s.Settings.Token)
req, err := http.NewRequest(http.MethodPost, url, bytes.NewBuffer(jsonData)) req, err := http.NewRequest(http.MethodPost, url, bytes.NewBuffer(jsonData))
if err != nil { if err != nil {

View file

@ -132,6 +132,12 @@ function FormFieldsTelegram() {
label="Message Thread ID" label="Message Thread ID"
help="Message Thread (topic) of a Supergroup" help="Message Thread (topic) of a Supergroup"
/> />
<TextFieldWide
name="host"
label="Telegram Api Proxy"
help="Reverse proxy domain for api.telegram.org, only needs to be specified if the network you are using has blocked the Telegram API."
placeholder="http(s)://ip:port"
/>
</div> </div>
); );
} }