Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Notifier] [Telegram] Add support for local API server#57769

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
ahmedghanem00 wants to merge1 commit intosymfony:7.4
base:7.4
Choose a base branch
Loading
fromahmedghanem00:make-protocol-schema-configurable

Conversation

ahmedghanem00
Copy link
Contributor

@ahmedghanem00ahmedghanem00 commentedJul 18, 2024
edited
Loading

QA
Branch?7.3
Bug fix?no
New feature?yes
Deprecations?no
IssuesFix#57766
LicenseMIT

Since Telegram'slocal API server doesn't support HTTPS traffic natively, this PR introduces a new DSN option/flag to allow the disabling of bridge's default behavior of usinghttps protocol

@OskarStark
Copy link
Contributor

I am afraid that this could lead to security issues, what about combining this flag with kernel debug parameter? Does that make sense? 🤔

@ahmedghanem00
Copy link
ContributorAuthor

I am afraid that this could lead to security issues

Agree, but usually this "API server" is hosted internally within the same infrastruture/server, so it might not be a big risk in that case? Maybe when it hosted on a remote server and the communication will flow over the internet, a TLS-termination server may be used in combination with it, to secure the data and keep the transmition happens onhttps?

We also may add an explicit caution in the readme file about this?

@ahmedghanem00
Copy link
ContributorAuthor

what about combining this flag with kernel debug parameter? Does that make sense? 🤔

Not sure, but usually I see options of other bridges being controlled via DSN only.

@ahmedghanem00ahmedghanem00force-pushed themake-protocol-schema-configurable branch from0e0398c toac9edcaCompareAugust 16, 2024 08:00
@OskarStarkOskarStark changed the title[Notifier] [Telegram] Add support for local API server[Notifier][Telegram] Add support for local API serverAug 16, 2024
Copy link
Contributor

@OskarStarkOskarStark left a comment

Choose a reason for hiding this comment

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

After my comments

@carsonbotcarsonbot changed the title[Notifier][Telegram] Add support for local API server[Notifier] [Telegram] Add support for local API serverAug 16, 2024
@OskarStarkOskarStark changed the title[Notifier] [Telegram] Add support for local API server[Notifier][Telegram] Add support for local API serverAug 16, 2024
$toString = \sprintf('telegram://%s', $this->getEndpoint());
$formattedOptions = http_build_query(['channel' => $this->chatChannel, 'disable_https' => $this->disableHttps ?: null]);

if ($formattedOptions) {

Choose a reason for hiding this comment

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

something is wrong here: the condition is always true now

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

It will be true only if one of the$chatChannel or$disableHttps properties has been set to something except the default. Unless this, the condition will always be false.

echo http_build_query(['channel' => null, 'disable_https' => false ?: null]); should return an empty string which will not pass the condition.

I may useempty() function in the condition for better readability? (e.g.if (!empty($formattedOptions)))

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Tests are passing well also

Copy link
Contributor

Choose a reason for hiding this comment

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

I just tested it, as I was always confused, but http_build_query behaves likearray_filter and if chatChannel and disableHttps is null,$formattedOptions is not true

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Actually, I don't get what is wrong with thehttp_build_query or theif statement 😅. It just tries to build a query string from a given set of class properties ($chatChannel & $disableHttps). I also have seen many other bridges usehttp_build_query in the same function to build the transport DSN.

If that's not a good approach, what is the alternative then?

Copy link
ContributorAuthor

@ahmedghanem00ahmedghanem00Aug 25, 2024
edited
Loading

Choose a reason for hiding this comment

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

Copy link
ContributorAuthor

@ahmedghanem00ahmedghanem00Jan 9, 2025
edited
Loading

Choose a reason for hiding this comment

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

Hola@nicolas-grekas@OskarStark, Can you have a recheck on here? Thanks

@carsonbotcarsonbot changed the title[Notifier][Telegram] Add support for local API server[Notifier] [Telegram] Add support for local API serverAug 22, 2024
@fabpotfabpot removed this from the7.2 milestoneNov 20, 2024
@fabpotfabpot added this to the7.3 milestoneNov 20, 2024
…'s default behavior of using `https` protocolSigned-off-by: Ahmed Ghanem <ahmedghanem7361@gmail.com>
@ahmedghanem00
Copy link
ContributorAuthor

@nicolas-grekas@OskarStark, Hola guys, can this PR get some review on here, whether it will be accepted or rejected😅? Thanks

@@ -14,6 +14,27 @@ where:
- `TOKEN` is your Telegram token
- `CHAT_ID` is your Telegram chat id
Copy link
Member

Choose a reason for hiding this comment

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

ahmedghanem00 reacted with thumbs up emoji

Example:
```
TELEGRAM_DSN=telegram://TOKEN@localhost:5001?channel=CHAT_ID&disable_https=1
Copy link
Member

Choose a reason for hiding this comment

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

In AmazonSns, this option is namedsslmode. I don't know if this name is better, but I think it's better to be consistent between adapters.

$protocol ='disable' ===$dsn->getOption('sslmode') ?'http' :'https';

This would become:

Suggested change
TELEGRAM_DSN=telegram://TOKEN@localhost:5001?channel=CHAT_ID&disable_https=1
TELEGRAM_DSN=telegram://TOKEN@localhost:5001?channel=CHAT_ID&sslmode=disable

Copy link
Member

@GromNaNGromNaNFeb 8, 2025
edited
Loading

Choose a reason for hiding this comment

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

I know you've already changed the name in response to our request#57769 (comment), but perhaps the consistency with other bridges hadn't been examined.

Copy link
Contributor

Choose a reason for hiding this comment

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

I likesslmode 👍

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@GromNaNGromNaNGromNaN left review comments

@alexislefebvrealexislefebvrealexislefebvre left review comments

@nicolas-grekasnicolas-grekasAwaiting requested review from nicolas-grekas

@OskarStarkOskarStarkAwaiting requested review from OskarStarkOskarStark is a code owner

Assignees
No one assigned
Projects
None yet
Milestone
7.4
Development

Successfully merging this pull request may close these issues.

symfony/telegram-notifier does not support local telegram api server
7 participants
@ahmedghanem00@OskarStark@nicolas-grekas@GromNaN@alexislefebvre@fabpot@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp