Skip to content

[Notifier] Add Google Chat bridge #36488

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

Merged
merged 1 commit into from
Aug 7, 2020
Merged

Conversation

GromNaN
Copy link
Member

@GromNaN GromNaN commented Apr 18, 2020

Q A
Branch? master
Bug fix? no
New feature? yes
Deprecations? no
Tickets Fix #35875
License MIT
Doc PR symfony/symfony-docs#14018

Uses the webhook to send messages.

$transport = (new GoogleChatTransportFactory())
    ->create(Dsn::fromString('googlechat://<key>:<token>@default/<space>?threadKey=<thread>'));

The threadKey can be any string, it allows to post all messages to the same thread instead of creating a new thread for each message.

Example of notification for exceptions:
image

if ('googlechat' === $scheme) {
$space = explode('/', $dsn->getPath())[3];
$accessKey = $dsn->getOption('key');
$accessToken = $dsn->getOption('token');
Copy link
Member

Choose a reason for hiding this comment

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

You should probably throw an exception of the key and/or token is empty. Or perhaps better, user the username/password like other providers.

Copy link
Member Author

Choose a reason for hiding this comment

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

I like the simplicity of copy-paste the webhook url without too much alteration. Changing the scheme is already a trap I fell into while coding this bridge.

But maybe it's a good thing to move apart from the url provided by Google in order to make clear for developers that they have to parse it in their mind and rewrite it following a custom pattern.

Copy link
Member Author

Choose a reason for hiding this comment

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

Regarding how other DSN are made, I chose to use a DSN totally different from the webhook url.

Copy link
Member Author

Choose a reason for hiding this comment

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

After a review of existing DSN, I applied the following format:

googlechat://ACCESS_KEY:ACCESS_TOKEN@default/SPACE?threadKey=THREAD

Where THREAD is optional.

@GromNaN
Copy link
Member Author

GromNaN commented Jul 31, 2020

This PR was not getting much attention.

Since the scope was a little too large, I've removed some non-essential features (card DSL, create transform from webhookUrl) in 1b1946c. I hope It can be accepted with this scope.

Copy link
Member

@fabpot fabpot left a comment

Choose a reason for hiding this comment

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

LGTM with some minor comments.

@GromNaN
Copy link
Member Author

GromNaN commented Aug 6, 2020

Thanks for the review. Each comment has been treated.

@fabpot
Copy link
Member

fabpot commented Aug 7, 2020

Thank you @GromNaN.

@fabpot fabpot merged commit 669b3df into symfony:master Aug 7, 2020
@GromNaN GromNaN deleted the google-chat branch August 7, 2020 21:11
@fabpot
Copy link
Member

fabpot commented Aug 10, 2020

@GromNaN Can you submit a PR on symfony/recipes (you can have a look at other notifier bridge recipes to get some inspiration)?

xabbuh added a commit to symfony/symfony-docs that referenced this pull request Aug 21, 2020
…transports (GromNaN)

This PR was squashed before being merged into the master branch.

Discussion
----------

[Notifier] Add GoogleChat to the list of supported chat transports

Documentation for symfony/symfony#36488

Commits
-------

7bfacde [Notifier] Add GoogleChat to the list of supported chat transports
@nicolas-grekas nicolas-grekas modified the milestones: next, 5.2 Oct 5, 2020
@fabpot fabpot mentioned this pull request Oct 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Notifier] Support Google Chat
4 participants