feat: dispatching AnnouncementPublished event - #1158
Conversation
580c1d6 to
f25f0e9
Compare
| } | ||
|
|
||
| #[\Override] | ||
| public function getWebhookSerializable(): array { |
There was a problem hiding this comment.
I would prefer if it's only this instead of exposing an internal entity. Sorry didn't see that before.
So I would have the constructor of the event take those strings and integers instead and not have a getAnnouncement method
There was a problem hiding this comment.
Initially I had the same idea, then I saw other apps (e.g. in Mail) just dispatching the whole involved Entity.
Anyway, I would suggest to keep IWebhookCompatibleEvent implementation separated by the behavior of the event. Maybe, something like
public function getData() {
return $this->serialize();
}
public function getWebhookSerializable() {
return $this->serialize();
}
private function serialize() {
return [
'subject' => $this->announcement->getsubJect(),
etc...
];
}
Just to avoid breaking all Listeners in the unlikely event IWebhookCompatibleEvent interface will change.
There was a problem hiding this comment.
(And I just realized I mistyped all entity's getters method... Not my best performance, today...)
There was a problem hiding this comment.
Or simply:
public function getWebhookSerializable() {
return [
'subject' => $this->announcement->getSubject(),
etc...
];
}
Ne need to duplicate a getData method
Signed-off-by: Roberto Guido <info@madbob.org>
Added an Event to notify other apps (both local than remote, using webhooks) about announcement publishing.
Ref #1050 (as the event can be listened by the
mohamedsakhri/nextcloud-announcementbannerapp and display the attached announcement as preferred).