From 4e780e33028b452e74546968461070bb1aaa3eb7 Mon Sep 17 00:00:00 2001 From: Jana Peper Date: Thu, 14 May 2026 14:48:33 +0200 Subject: [PATCH] feat: add new mail events to list Signed-off-by: Jana Peper --- lib/Controller/ApiController.php | 199 +++++++++++++++++++++++++++++++ 1 file changed, 199 insertions(+) diff --git a/lib/Controller/ApiController.php b/lib/Controller/ApiController.php index 624546f..ec464de 100644 --- a/lib/Controller/ApiController.php +++ b/lib/Controller/ApiController.php @@ -645,6 +645,205 @@ public function listEvents(): DataResponse { ]; } + if (class_exists('OCA\\Mail\\Events\\MessageSentEvent')) { + $events[] = [ + 'name' => 'MessageSentEvent', + 'description' => 'A mail has been sent', + 'path' => "OCA\Mail\Events\MessageSentEvent", + 'parameters' => [ + 'user' => ['uid' => 'string', 'displayName' => 'string'], + 'time' => 'int', + 'event' => [ + 'class' => 'string', + 'message' => [ + 'id' => 'int', + 'cc' => [ + 'id' => 'int', + 'type' => 'int', + 'email' => 'string', + 'label' => 'string', + 'messageId' => 'int', + 'localMessageId' => 'int', + ], + 'to' => [ + 'id' => 'int', + 'type' => 'int', + 'email' => 'string', + 'label' => 'string', + 'messageId' => 'int', + 'localMessageId' => 'int', + ], + 'bcc' => [ + 'id' => 'int', + 'type' => 'int', + 'email' => 'string', + 'label' => 'string', + 'messageId' => 'int', + 'localMessageId' => 'int', + ], + 'raw' => 'string', + 'from' => [ + 'id' => 'int', + 'type' => 'int', + 'email' => 'string', + 'label' => 'string', + 'messageId' => 'int', + 'localMessageId' => 'int', + ], + 'type' => 'int', + 'failed' => 'bool', + 'isHtml' => 'bool', + 'sendAt' => 'int', + 'status' => 'int', + 'aliasId' => 'int', + 'subject' => 'string', + 'bodyHtml' => 'string', + 'accountId' => 'int', + 'bodyPlain' => 'string', + 'isPgpMime' => 'bool', + 'smimeSign' => 'bool', + 'updatedAt' => 'int', + 'editorBody' => 'string', + 'requestMdn' => 'bool', + 'attachments' => [ + 'type' => 'string', + 'messageId' => 'int', + 'fileName' => 'string', + 'mimeType' => 'string', + ], + 'smimeEncrypt' => 'bool', + 'inReplyToMessageId' => 'int', + 'smimeCertificateId' => 'int', + ], + ], + ], + ]; + } + + if (class_exists('OCA\\Mail\\Events\\MessageDeletedEvent')) { + $events[] = [ + 'name' => 'MessageDeletedEvent', + 'description' => 'A mail has been deleted', + 'path' => "OCA\Mail\Events\MessageDeletedEvent", + 'parameters' => [ + 'user' => ['uid' => 'string', 'displayName' => 'string'], + 'time' => 'int', + 'event' => [ + 'class' => 'string', + 'accountId' => 'int', + 'mailboxId' => 'int', + 'messageId' => 'int', + ], + ], + ]; + } + + if (class_exists('OCA\\Mail\\Events\\MessageFlaggedEvent')) { + $events[] = [ + 'name' => 'MessageFlaggedEvent', + 'description' => 'A mail has been flagged', + 'path' => "OCA\Mail\Events\MessageFlaggedEvent", + 'parameters' => [ + 'user' => ['uid' => 'string', 'displayName' => 'string'], + 'time' => 'int', + 'event' => [ + 'class' => 'string', + 'accountId' => 'int', + 'mailboxId' => 'int', + 'messageId' => 'int', + 'flag' => 'string', + 'set' => 'bool', + ], + ], + ]; + } + + if (class_exists('OCA\\Mail\\Events\\NewMessageReceivedEvent')) { + $events[] = [ + 'name' => 'NewMessageReceivedEvent', + 'description' => 'A new mail has been received', + 'path' => "OCA\Mail\Events\NewMessageReceivedEvent", + 'parameters' => [ + 'user' => ['uid' => 'string', 'displayName' => 'string'], + 'time' => 'int', + 'event' => [ + 'class' => 'string', + 'messageUri' => 'string', + 'message' => [ + 'uid' => 'int', + 'cc' => [ + 'id' => 'int', + 'type' => 'int', + 'email' => 'string', + 'label' => 'string', + 'messageId' => 'int', + 'localMessageId' => 'int', + ], + 'to' => [ + 'id' => 'int', + 'type' => 'int', + 'email' => 'string', + 'label' => 'string', + 'messageId' => 'int', + 'localMessageId' => 'int', + ], + 'bcc' => [ + 'id' => 'int', + 'type' => 'int', + 'email' => 'string', + 'label' => 'string', + 'messageId' => 'int', + 'localMessageId' => 'int', + ], + 'from' => [ + 'id' => 'int', + 'type' => 'int', + 'email' => 'string', + 'label' => 'string', + 'messageId' => 'int', + 'localMessageId' => 'int', + ], + 'tags' => 'string[]', + 'flags' => [ + 'seen' => 'bool', + '$junk' => 'bool', + 'draft' => 'bool', + 'deleted' => 'bool', + 'flagged' => 'bool', + '$mdnsent' => 'bool', + '$notjunk' => 'bool', + 'answered' => 'bool', + 'forwarded' => 'bool', + 'important' => 'bool', + 'hasAttachments' => 'bool', + ], + 'avatar' => 'string', + 'dateInt' => 'int', + 'subject' => 'string', + 'summary' => 'string', + 'encrypted' => 'bool', + 'inReplyTo' => 'string', + 'mailboxId' => 'int', + 'messageId' => 'string', + 'databaseId' => 'int', + 'mentionsMe' => 'bool', + 'references' => 'string[]', + 'attachments' => [ + 'type' => 'string', + 'messageId' => 'int', + 'fileName' => 'string', + 'mimeType' => 'string', + ], + 'imipMessage' => 'bool', + 'previewText' => 'string', + 'threadRootId' => 'string', + 'fetchAvatarFromClient' => 'bool', + ] + ], + ], + ]; + } + return new DataResponse(json_encode($events), Http::STATUS_OK); }