Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Notifier] [Mercure] Add options #54961

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

Closed
wants to merge 21 commits into from
Closed

Conversation

ernie76
Copy link
Contributor

@ernie76 ernie76 commented May 17, 2024

Q A
Branch? 7.3
Bug fix? no
New feature? yes
Deprecations? no
License MIT

Add content option

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 7.1 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@xabbuh xabbuh modified the milestones: 7.1, 7.2 May 17, 2024
@ernie76
Copy link
Contributor Author

ernie76 commented May 17, 2024

this PR connect to this PR symfony/ux#1853

@ernie76 ernie76 changed the title Notifier mercure [Notifier] mercure add body, icon, tag ,renotify May 17, 2024
@OskarStark OskarStark changed the title [Notifier] mercure add body, icon, tag ,renotify [Notifier][Mercure] Add body, icon, tag ,renotify May 21, 2024
@chapterjason
Copy link
Contributor

chapterjason commented May 21, 2024

I just noticed that renotify is not supported in Firefox and Safari according to developer.mozilla.org; and there seem to be more properties than just those 4.

@ernie76
Copy link
Contributor Author

ernie76 commented May 21, 2024

I just noticed that renotify is not supported in Firefox and Safari according to developer.mozilla.org; and there seem to be more properties than just those 4.

you need this option in google chrome

@chapterjason
Copy link
Contributor

chapterjason commented May 21, 2024

I just noticed that renotify is not supported in Firefox and Safari according to developer.mozilla.org; and there seem to be more properties than just those 4.

you need this option in google chrome

Might be the case, couldn't find any example/issue that this is the case, but why excluding other browsers and not use just a simple array to dynamically pass the possible options?

My recommendation:

  • Replace args for the options with an array
  • Add type doc with a reference to developer.mozilla.org, optionally define array shape
  • Just pass the array (Also reduces the named arguments and multiple JSON.parse calls in ux package)

It also looks like the resulting activity stream doesn't fit the spec: https://www.w3.org/TR/activitystreams-vocabulary/#dfn-announce.

This might fit the spec more:

{
   "@context":"https://www.w3.org/ns/activitystreams",
   "type":"Announce",
   "summary":"subject",
   "mediaType": "application/json",
   "content": "{\"body\":null,\"icon\":null,\"tag\":null,\"renotify\":false}"
}

@ernie76
Copy link
Contributor Author

ernie76 commented May 22, 2024

@chapterjason it's a good idea
i close this PR and the PR on the ux side, and try it again.
is this ok?

@chapterjason
Copy link
Contributor

@ernie76 You don't need to create new ones, just modify it, that's what PRs are about, they are evolving. I really like the initial idea, as it gives more control without creating any JS.

Sven Scholz added 2 commits May 22, 2024 10:23
@OskarStark OskarStark changed the title [Notifier][Mercure] Add body, icon, tag ,renotify [Notifier][Mercure] Add body, icon, tag ,renotify May 22, 2024
@ernie76 ernie76 changed the title [Notifier][Mercure] Add body, icon, tag ,renotify [Notifier][Mercure] Add options May 22, 2024
@ernie76
Copy link
Contributor Author

ernie76 commented May 23, 2024

@chapterjason is this so ok now?

$this->topics = $topics ?? 'https://symfony.com/notifier';

parent::__construct($client, $dispatcher);
}

public function __toString(): string
{
return sprintf('mercure://%s%s', $this->hubId, '?'.http_build_query(['topic' => $this->topics], '', '&'));
return sprintf('mercure://%s%s', $this->hubId, null !== $this->topics ? '?'.http_build_query(['topic' => $this->topics], '', '&') : '');
Copy link
Contributor

Choose a reason for hiding this comment

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

Why checking for null if constructor always sets a topic in that case?

@chapterjason
Copy link
Contributor

Hey @ernie76 a bit busy the last days, only one thing, everything else looks good. 👍🏼

@carsonbot carsonbot changed the title [Mercure] Add options [Notifier] [Mercure] Add options May 29, 2024
@ernie76 ernie76 requested a review from chapterjason June 3, 2024 10:53
@ernie76 ernie76 requested a review from OskarStark June 15, 2024 16:53
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

What's the status of this PR?
It looks like the description is a bit out of sync? Can you give it some live please?

@ernie76
Copy link
Contributor Author

ernie76 commented Jun 26, 2024

What's the status of this PR? It looks like the description is a bit out of sync? Can you give it some live please?

in MercuryOptions you can now
pass an array with the proterties https://developer.mozilla.org/en-US/docs/Web/API/Notification?retiredLocale=de#instance_properties

        new MercureOptions(['https://example.com/books/1'], content: ['tag' => $randonnumber,'body' => 'TEST', 'icon' =>  'https://media.flaticon.com/dist/min/img/logos/flaticon-color-negative.svg'])

@ernie76
Copy link
Contributor Author

ernie76 commented Jun 26, 2024

what shall i do?

@ernie76
Copy link
Contributor Author

ernie76 commented Jul 9, 2024

What must i do, to make this to a end?

@fabpot fabpot modified the milestones: 7.2, 7.3 Nov 20, 2024
@OskarStark
Copy link
Contributor

@ernie76 can you please update the PR header?

@OskarStark OskarStark requested review from dunglas and removed request for chapterjason April 2, 2025 07:06
@OskarStark
Copy link
Contributor

Needs a rebase

@@ -114,7 +114,7 @@ public function testSendWithMercureOptions()
{
$hub = new MockHub('https://foo.com/.well-known/mercure', new StaticTokenProvider('foo'), function (Update $update): string {
$this->assertSame(['/topic/1', '/topic/2'], $update->getTopics());
$this->assertSame('{"@context":"https:\/\/www.w3.org\/ns\/activitystreams","type":"Announce","summary":"subject"}', $update->getData());
$this->assertSame('{"@context":"https:\/\/www.w3.org\/ns\/activitystreams","type":"Announce","summary":"subject","mediaType":"application\/json","content":null}', $update->getData());
Copy link
Member

Choose a reason for hiding this comment

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

I think we should add a test where content is not null as this is the goal off this PR.

@ernie76
Copy link
Contributor Author

ernie76 commented Apr 3, 2025

i can't make a rebase.
can i make a new pullrequest?
i have all changes done.

@fabpot
Copy link
Member

fabpot commented Apr 4, 2025

i can't make a rebase. can i make a new pullrequest? i have all changes done.

Sure, just close this one, create a new one, and reference this one.

@ernie76
Copy link
Contributor Author

ernie76 commented Apr 4, 2025

new PullRequest under
#60140

@ernie76 ernie76 closed this Apr 4, 2025
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.

8 participants