Skip to content

Added support for custom Telegram proxy host #29648

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

C-Y-X
Copy link

@C-Y-X C-Y-X commented Mar 7, 2024

Added support for custom Telegram proxy domain names

In some specific environments, it supports defining the proxy or self-built domain name of the telegram bot API

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 7, 2024
@lunny
Copy link
Member

lunny commented Mar 7, 2024

Please speak in English.

@C-Y-X C-Y-X changed the title 新增对Telegram 自定义代理域名的设置 Added support for custom Telegram proxy domain names\ Mar 7, 2024
@C-Y-X C-Y-X changed the title Added support for custom Telegram proxy domain names\ Added support for custom Telegram proxy domain names Mar 7, 2024
@C-Y-X
Copy link
Author

C-Y-X commented Mar 7, 2024

Please speak in English.

Done

@yp05327
Copy link
Contributor

yp05327 commented Mar 8, 2024

How about convert it into custom host which contains both domain and protocol

@C-Y-X
Copy link
Author

C-Y-X commented Mar 8, 2024

How about convert it into custom host which contains both domain and protocol

Hi @yp05327
In some network environments, api.telegram.org cannot be accessed directly. It is necessary to build a reverse proxy through the server to access it. For example, by using this project (https://github.com/paran3xus/telegram-bot-api-proxy-cf-worker) to use Cloudflare Worker to implement interface server access. Telegram message reminder server has this option in most notifications. It will still use api.telegram.org by default when it is not filled in or left blank.

@yp05327
Copy link
Contributor

yp05327 commented Mar 8, 2024

I know your needs.
I mean users may want to use http instead of https ( as a possible case I can image ), so how about form.CustomHost = "https://api.telegram.org", then they can also select which protocol to use.

@C-Y-X C-Y-X force-pushed the update-telegramwehook branch from a0e90c2 to 514d558 Compare March 8, 2024 09:49
@C-Y-X
Copy link
Author

C-Y-X commented Mar 8, 2024

I know your needs. I mean users may want to use http instead of https ( as a possible case I can image ), so how about form.CustomHost = "https://api.telegram.org", then they can also select which protocol to use.

@yp05327 Good idea, I didn't consider that there are still some people using http. I've already updated the relevant code.
also rename CustomDomain to CustomHost

@C-Y-X C-Y-X force-pushed the update-telegramwehook branch from 514d558 to 0603f10 Compare March 8, 2024 09:54
@C-Y-X C-Y-X changed the title Added support for custom Telegram proxy domain names Added support for custom Telegram proxy host Mar 8, 2024
@@ -425,15 +425,19 @@ func TelegramHooksEditPost(ctx *context.Context) {
func telegramHookParams(ctx *context.Context) webhookParams {
form := web.GetForm(ctx).(*forms.NewTelegramHookForm)

if form.CustomHost == "" {
form.CustomHost = "https://api.telegram.org"
Copy link
Contributor

@yp05327 yp05327 Mar 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

convert the default server host into a const. and add it to ctx.Data, then we can use it in template.
Then there's no need to maintain both frontend and backend.

@techknowlogick
Copy link
Member

I've been thinking if this is the approach we should take (having an additional field in the webhook form for each telegram webhooks), there are a few other ways to achieve using a different host for telegram webhooks.

  1. We have proxy support for webhooks that can filter on specific domains, and then the proxy could modify the URL
  2. We could have a config setting for "telegram proxy host" so it just needs to be set once in the config

@906051999
Copy link

Sadly, this feature still doesn't seem to be incorporated

@wxiaoguang
Copy link
Contributor

There are still unresolved reviews. Is this PR still active?

@wxiaoguang wxiaoguang added the issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail label Apr 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/translation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants