Skip to content

Commit

Permalink
feat(notifications): add support for custom Telegram api url (#1508)
Browse files Browse the repository at this point in the history
feat(notifications): Add support for reverse proxyed telegram api
  • Loading branch information
KyokoMiki committed Apr 15, 2024
1 parent 72ca7a8 commit c43e2c7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 9 additions & 1 deletion internal/notification/telegram.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,15 @@ func (s *telegramSender) Send(event domain.NotificationEvent, payload domain.Not
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))
if err != nil {
Expand Down
6 changes: 6 additions & 0 deletions web/src/forms/settings/NotificationForms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ function FormFieldsTelegram() {
label="Message Thread ID"
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>
);
}
Expand Down

0 comments on commit c43e2c7

Please sign in to comment.