Skip to content

Feat: make some events webhook compatible#12936

Open
janepie wants to merge 3 commits into
mainfrom
feat/webhook-events
Open

Feat: make some events webhook compatible#12936
janepie wants to merge 3 commits into
mainfrom
feat/webhook-events

Conversation

@janepie
Copy link
Copy Markdown
Member

@janepie janepie commented May 14, 2026

Makes these event types webhook compatible:

  • NewMessageReceivedEvent
  • MessageSentEvent
  • MessageFlaggedEvent
  • MessageDeletedEvent

@welcome
Copy link
Copy Markdown

welcome Bot commented May 14, 2026

Thanks for opening your first pull request in this repository! ✌️

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 14, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds webhook serialization support to message events. MessageDeletedEvent, MessageFlaggedEvent, and MessageSentEvent each implement IWebhookCompatibleEvent with a getWebhookSerializable() method exposing relevant event properties. NewMessageReceivedEvent undergoes a broader structural change: its constructor now accepts both a URI string and a Message entity (previously only the URI), and its webhook serialization exports both fields. The NewMessagesNotifier listener is updated to dispatch the event with both parameters.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main objective of the changeset: making specific event classes webhook compatible by implementing IWebhookCompatibleEvent.
Description check ✅ Passed The description directly relates to the changeset by listing the four event classes being made webhook compatible, which matches the actual file modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
lib/Events/MessageSentEvent.php (1)

40-43: ⚡ Quick win

Stabilize the webhook contract with an explicit payload schema.

Serializing LocalMessage directly couples webhook output to internal entity shape and can expose more fields than intended. Prefer a curated flat payload (for example IDs + explicitly selected message fields).

lib/Events/NewMessageReceivedEvent.php (1)

27-31: ⚡ Quick win

Avoid emitting raw Message entities in webhook payloads.

Returning the entity directly makes the external webhook schema implicit and fragile. Prefer an explicit, versionable payload with selected fields only.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c4a4f676-a8aa-41b8-8c4c-d5989f2ddac6

📥 Commits

Reviewing files that changed from the base of the PR and between 114629c and cfb6a98.

📒 Files selected for processing (5)
  • lib/Events/MessageDeletedEvent.php
  • lib/Events/MessageFlaggedEvent.php
  • lib/Events/MessageSentEvent.php
  • lib/Events/NewMessageReceivedEvent.php
  • lib/Listener/NewMessagesNotifier.php

@janepie janepie requested a review from GretaD as a code owner May 14, 2026 13:05
@janepie janepie force-pushed the feat/webhook-events branch from 8211490 to d9199cc Compare May 14, 2026 13:07
Comment thread lib/Events/MessageFlaggedEvent.php Outdated
@kesselb
Copy link
Copy Markdown
Contributor

kesselb commented May 15, 2026

@janepie is the target 34?

@janepie
Copy link
Copy Markdown
Member Author

janepie commented May 18, 2026

@janepie is the target 34?

Would be nice but I think I can live with 35, let me doublecheck

janepie added 2 commits May 18, 2026 12:22
Signed-off-by: Jana Peper <jana.peper@nextcloud.com>
Signed-off-by: Jana Peper <jana.peper@nextcloud.com>
@janepie janepie force-pushed the feat/webhook-events branch from 0dd001e to 229f1a6 Compare May 18, 2026 10:23
Co-authored-by: Daniel <mail@danielkesselberg.de>
Signed-off-by: janepie <49834966+janepie@users.noreply.github.com>
@janepie janepie force-pushed the feat/webhook-events branch from 229f1a6 to 4c6375e Compare May 18, 2026 10:24
@janepie
Copy link
Copy Markdown
Member Author

janepie commented May 18, 2026

Checked, 35 is fine!

return $this->set;
}

public function getWebhookSerializable(): array {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do you have a use case in mind for this event?

I'm just wondering because you cannot use the messageUid for our api because the expects the message id (oc_mail_messages.id). The uid is an identifier on the imap server. The accountId and mailboxId are database ids from nextcloud mail.

public function get(int $id): DataResponse {

With the uid you could directly lookup a message on the imap server, but for that you need the name of the mailbox (which you currently won't pass, only the id but that one the imap server wont know).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Use case in mind is some hook that reacts whenever a message is flagged. Yeah I guess that would actually need the internal ID to do sth with it, tbh I just forwarded the information already available in the event as I thought that would be fine. Is there an easy way to get the internal id from here?

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.

2 participants