Skip to content

Commit

Permalink
fixup! feat(ocs): notify of new messages and provide API endpoint to …
Browse files Browse the repository at this point in the history
…retrieve its contents
  • Loading branch information
miaulalala committed Jun 18, 2024
1 parent ccc54f4 commit 8858cfc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 8 additions & 1 deletion appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -492,5 +492,12 @@
'outbox' => ['url' => '/api/outbox'],
'preferences' => ['url' => '/api/preferences'],
'smimeCertificates' => ['url' => '/api/smime/certificates'],
]
],
'ocs' => [
[
'name' => 'messageApi#get',
'url' => '/message/{$id}',
'verb' => 'GET',
],
],
];
5 changes: 2 additions & 3 deletions lib/Controller/MessageApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use OCA\Mail\Service\OutboxService;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\ApiRoute;
use OCP\AppFramework\Http\Attribute\BruteForceProtection;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
Expand Down Expand Up @@ -52,13 +51,13 @@ public function __construct(
}

/**
* @param int $id
* @return JSONResponse
*/
#[ApiRoute(verb: 'GET', url: '/message/{id}')]
#[BruteForceProtection('mailGetMessage')]
#[NoAdminRequired]
#[NoCSRFRequired]
public function get(int $id) {
public function get(int $id): JSONResponse {
try {
$message = $this->mailManager->getMessage($this->userId, $id);
$mailbox = $this->mailManager->getMailbox($this->userId, $message->getMailboxId());
Expand Down

0 comments on commit 8858cfc

Please sign in to comment.