mirror of
https://github.com/go-gitea/gitea
synced 2024-12-23 00:54:28 +00:00
Added support for custom Telegram proxy host
This commit is contained in:
parent
c72e1a7abb
commit
0603f1029c
@ -2433,6 +2433,7 @@ settings.tags.protection.none = There are no protected tags.
|
|||||||
settings.tags.protection.pattern.description = You can use a single name or a glob pattern or regular expression to match multiple tags. Read more in the <a target="_blank" rel="noopener" href="https://docs.gitea.com/usage/protected-tags">protected tags guide</a>.
|
settings.tags.protection.pattern.description = You can use a single name or a glob pattern or regular expression to match multiple tags. Read more in the <a target="_blank" rel="noopener" href="https://docs.gitea.com/usage/protected-tags">protected tags guide</a>.
|
||||||
settings.bot_token = Bot Token
|
settings.bot_token = Bot Token
|
||||||
settings.chat_id = Chat ID
|
settings.chat_id = Chat ID
|
||||||
|
settings.custom_host= Custom Host
|
||||||
settings.thread_id = Thread ID
|
settings.thread_id = Thread ID
|
||||||
settings.matrix.homeserver_url = Homeserver URL
|
settings.matrix.homeserver_url = Homeserver URL
|
||||||
settings.matrix.room_id = Room ID
|
settings.matrix.room_id = Room ID
|
||||||
|
@ -425,14 +425,18 @@ func TelegramHooksEditPost(ctx *context.Context) {
|
|||||||
func telegramHookParams(ctx *context.Context) webhookParams {
|
func telegramHookParams(ctx *context.Context) webhookParams {
|
||||||
form := web.GetForm(ctx).(*forms.NewTelegramHookForm)
|
form := web.GetForm(ctx).(*forms.NewTelegramHookForm)
|
||||||
|
|
||||||
|
if form.CustomHost == "" {
|
||||||
|
form.CustomHost = "https://api.telegram.org"
|
||||||
|
}
|
||||||
return webhookParams{
|
return webhookParams{
|
||||||
Type: webhook_module.TELEGRAM,
|
Type: webhook_module.TELEGRAM,
|
||||||
URL: fmt.Sprintf("https://api.telegram.org/bot%s/sendMessage?chat_id=%s&message_thread_id=%s", url.PathEscape(form.BotToken), url.QueryEscape(form.ChatID), url.QueryEscape(form.ThreadID)),
|
URL: fmt.Sprintf("%s/bot%s/sendMessage?chat_id=%s&message_thread_id=%s", form.CustomHost, url.PathEscape(form.BotToken), url.QueryEscape(form.ChatID), url.QueryEscape(form.ThreadID)),
|
||||||
ContentType: webhook.ContentTypeJSON,
|
ContentType: webhook.ContentTypeJSON,
|
||||||
WebhookForm: form.WebhookForm,
|
WebhookForm: form.WebhookForm,
|
||||||
Meta: &webhook_service.TelegramMeta{
|
Meta: &webhook_service.TelegramMeta{
|
||||||
BotToken: form.BotToken,
|
BotToken: form.BotToken,
|
||||||
ChatID: form.ChatID,
|
ChatID: form.ChatID,
|
||||||
|
CustomHost: form.CustomHost,
|
||||||
ThreadID: form.ThreadID,
|
ThreadID: form.ThreadID,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -352,6 +352,7 @@ func (f *NewDingtalkHookForm) Validate(req *http.Request, errs binding.Errors) b
|
|||||||
type NewTelegramHookForm struct {
|
type NewTelegramHookForm struct {
|
||||||
BotToken string `binding:"Required"`
|
BotToken string `binding:"Required"`
|
||||||
ChatID string `binding:"Required"`
|
ChatID string `binding:"Required"`
|
||||||
|
CustomHost string
|
||||||
ThreadID string
|
ThreadID string
|
||||||
WebhookForm
|
WebhookForm
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ type (
|
|||||||
TelegramMeta struct {
|
TelegramMeta struct {
|
||||||
BotToken string `json:"bot_token"`
|
BotToken string `json:"bot_token"`
|
||||||
ChatID string `json:"chat_id"`
|
ChatID string `json:"chat_id"`
|
||||||
|
CustomHost string `json:"custom_host"`
|
||||||
ThreadID string `json:"thread_id"`
|
ThreadID string `json:"thread_id"`
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -10,6 +10,10 @@
|
|||||||
<label for="chat_id">{{ctx.Locale.Tr "repo.settings.chat_id"}}</label>
|
<label for="chat_id">{{ctx.Locale.Tr "repo.settings.chat_id"}}</label>
|
||||||
<input id="chat_id" name="chat_id" type="text" value="{{.TelegramHook.ChatID}}" required>
|
<input id="chat_id" name="chat_id" type="text" value="{{.TelegramHook.ChatID}}" required>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="field {{if .Err_CustomHost}}error{{end}}">
|
||||||
|
<label for="custom_host">{{ctx.Locale.Tr "repo.settings.custom_host"}}</label>
|
||||||
|
<input id="custom_host" name="custom_host" type="text" value="{{.TelegramHook.CustomHost}}" placeholder="https://api.telegram.org">
|
||||||
|
</div>
|
||||||
<div class="field {{if .Err_ThreadID}}error{{end}}">
|
<div class="field {{if .Err_ThreadID}}error{{end}}">
|
||||||
<label for="thread_id">{{ctx.Locale.Tr "repo.settings.thread_id"}}</label>
|
<label for="thread_id">{{ctx.Locale.Tr "repo.settings.thread_id"}}</label>
|
||||||
<input id="thread_id" name="thread_id" type="text" value="{{.TelegramHook.ThreadID}}">
|
<input id="thread_id" name="thread_id" type="text" value="{{.TelegramHook.ThreadID}}">
|
||||||
|
Loading…
Reference in New Issue
Block a user