Skip to content

[Notify] Add Notify bundle #49

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
May 23, 2022
Merged

Conversation

mtarld
Copy link
Contributor

@mtarld mtarld commented Jan 21, 2021

Q A
Bug fix? no
New feature? yes
Tickets
License MIT

In Symfony 5.3, Notifier was shipped with a Mercure bridge (symfony/symfony#39342)

Then, with a simple $this->notifier->send(new Notification('My message', ['chat/mercure'])); (and a running Mercure server), it'll be easy to create "Server-Sent-Events".

Therefore, the Notify bundle idea is to listen to these events using JavaScript event sourcing and convert them as native HTML5 notifications (using the {{ stream_notifications() }} Twig function).

(The "Notify" name was the first that came to my mind a could/should be challenged)

@mtarld mtarld force-pushed the feature/notify branch 2 times, most recently from 56433be to 4ac0d8e Compare January 23, 2021 19:39
@seb-jean
Copy link
Contributor

Hi 😃 ,

With this bundle, will it be web push notifications (with allow and block) or simple notifications?

Push notifications :
Ca1pture

notification-message

Simple notification :
Capture

Thanks :)

@tgalopin
Copy link
Contributor

Push notifications (native)

@tgalopin
Copy link
Contributor

Hello @mtarld

I think this component still makes sense, could we perhaps use latest Symfony changes (especially on ux-mercure) to finalize it? Would you have time to have a look at the failing tests/rebasing?

@mtarld
Copy link
Contributor Author

mtarld commented Nov 25, 2021

Hi @tgalopin!
Yes indeed, I think it is worth it! A lot of improvements and changes happened, I'll update the bundle consequently 🙂

@mtarld mtarld force-pushed the feature/notify branch 5 times, most recently from f553489 to efef096 Compare December 27, 2021 09:39
@mtarld
Copy link
Contributor Author

mtarld commented Dec 27, 2021

Hi @tgalopin! I updated the bundle to be consistent with other bundles (and to reuse some good ideas taken from ux-turbo-mercure)

Still, some questions remain:

  • As the notify bundle is tightly coupled to mercure, should we name the bundle after it? Something like MercureNotify with a stream_mercure_notification twig function?
  • Actually, symfony/mercure-notifier is a strong composer dependency of the bundle. But it could actually work without (as the bundle is just a "listener"). Maybe we can instead change that dependency to a composer suggestion?

@mtarld mtarld requested a review from yceruto January 7, 2022 14:37
@mtarld mtarld requested a review from yceruto January 10, 2022 17:22
Copy link
Member

@yceruto yceruto left a comment

Choose a reason for hiding this comment

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

LGTM

@mtarld mtarld force-pushed the feature/notify branch 2 times, most recently from 16ab0ea to de8d8eb Compare April 28, 2022 11:12
Copy link
Member

@weaverryan weaverryan left a comment

Choose a reason for hiding this comment

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

Very cool 😎

@mtarld mtarld force-pushed the feature/notify branch 4 times, most recently from 6d30370 to eb2d549 Compare May 10, 2022 16:49
@mtarld
Copy link
Contributor Author

mtarld commented May 10, 2022

As we required PHP 8.1 for that bundle, I updated the test workflow to run the bundle's tests on PHP 8.1.
I think we may test other bundles over PHP 8.1 instead of 8.0 in another PR.
WDYT?

@mtarld
Copy link
Contributor Author

mtarld commented May 10, 2022

Thanks for that wonderful review @weaverryan 🙂!

@mtarld mtarld requested review from weaverryan and chalasr May 10, 2022 17:11
@weaverryan
Copy link
Member

As we required PHP 8.1 for that bundle, I updated the test workflow to run the bundle's tests on PHP 8.1.
I think we may test other bundles over PHP 8.1 instead of 8.0 in another PR.
WDYT?

The test matrix DOES need some work. But if a bundle advertises that it works on php8, we need to keep testing it on php 8.0 (though, we should probably also test on php 8.1). Btw, I think we need to improve the test matrix further to be dynamic. There is way too much repeated config, and that's only going to get worse as the number of components grows. If you're interested, I had a WIP version of this at https://github.com/weaverryan/ux/tree/typescript-central-ci - where each package created a dynamic build. I think it's an interesting approach.

For this PR, I'd love to see your excellent explanation put into the docs. But after that, it's ready to merge!

environment variable by specifying the ``topics`` query parameter.
Otherwise, notifications will be sent to ``https://symfony.com/notifier`` topic.

Then, you can inject the ``NotifierInterface`` service and send messages on the ``chat/mercure`` channel::
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Then, you can inject the ``NotifierInterface`` service and send messages on the ``chat/mercure`` channel::
Then, you can inject the ``NotifierInterface`` service and send messages on the ``chat/myMercureChatter `` channel::

Example of a native notification

Extend the Stimulus Controller
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Copy link
Member

Choose a reason for hiding this comment

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

This looks a tiny bit to short

@weaverryan
Copy link
Member

Thank you Mathias! Wonderful work!

@weaverryan weaverryan merged commit 9b877d4 into symfony:2.x May 23, 2022
@weaverryan
Copy link
Member

Docs tweak over at #325

@mtarld mtarld deleted the feature/notify branch May 23, 2022 18:30
chalasr added a commit that referenced this pull request May 23, 2022
This PR was merged into the 2.x branch.

Discussion
----------

[Notify] Minor docs tweaks

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| Tickets       | Related to #49
| License       | MIT

Minor docs changes for #49.

Thanks!

Commits
-------

b294dc7 minor docs tweaks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants