From a253c75323517089d2ae27a90346484f72c87de9 Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Tue, 3 Mar 2026 22:30:27 +0100 Subject: [PATCH 1/4] docs: decryptDataFetch can throw SmimeDecryptException Signed-off-by: Daniel Kesselberg --- lib/Service/SmimeService.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Service/SmimeService.php b/lib/Service/SmimeService.php index c30984eaff..f39d3b841b 100644 --- a/lib/Service/SmimeService.php +++ b/lib/Service/SmimeService.php @@ -485,7 +485,8 @@ public function decryptMimePartText(string $mimePartText, * @param string $userId * @return SmimeDecryptionResult * - * @throws ServiceException + * @throws ServiceException If the database query fails + * @throws SmimeDecryptException No certificate for decryption found */ public function decryptDataFetch(Horde_Imap_Client_Data_Fetch $message, string $userId): SmimeDecryptionResult { From 7fc9be4324cd7341b8255d5d7180b913331d5e14 Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Wed, 4 Mar 2026 00:23:33 +0100 Subject: [PATCH 2/4] docs: Update throws for find, findByIds and findAll Signed-off-by: Daniel Kesselberg --- lib/IMAP/MessageMapper.php | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/IMAP/MessageMapper.php b/lib/IMAP/MessageMapper.php index a6ca3228d3..38b7485b8e 100644 --- a/lib/IMAP/MessageMapper.php +++ b/lib/IMAP/MessageMapper.php @@ -27,6 +27,7 @@ use OCA\Mail\Attachment; use OCA\Mail\Db\Mailbox; use OCA\Mail\Exception\ServiceException; +use OCA\Mail\Exception\SmimeDecryptException; use OCA\Mail\Html\Parser; use OCA\Mail\IMAP\Charset\Converter; use OCA\Mail\Model\IMAPMessage; @@ -66,9 +67,11 @@ public function __construct( } /** - * @return IMAPMessage * @throws DoesNotExistException * @throws Horde_Imap_Client_Exception + * @throws Horde_Mime_Exception + * @throws ServiceException + * @throws SmimeDecryptException */ public function find(Horde_Imap_Client_Base $client, string $mailbox, @@ -85,15 +88,17 @@ public function find(Horde_Imap_Client_Base $client, } /** - * @param Horde_Imap_Client_Socket $client - * @param string $mailbox + * @return array{ + * messages: list, + * all: bool, + * total: int, + * } * - * @param int $maxResults - * @param int $highestKnownUid - * @param PerformanceLoggerTask $perf - * - * @return array + * @throws DoesNotExistException * @throws Horde_Imap_Client_Exception + * @throws Horde_Imap_Client_Exception_NoSupportExtension + * @throws Horde_Mime_Exception + * @throws ServiceException */ public function findAll(Horde_Imap_Client_Socket $client, string $mailbox, @@ -256,22 +261,18 @@ public function findAll(Horde_Imap_Client_Socket $client, } /** - * @param Horde_Imap_Client_Base $client - * @param string $mailbox * @param int[]|Horde_Imap_Client_Ids $ids - * @param string $userId - * @param bool $loadBody - * @return IMAPMessage[] + * @return list * * @throws DoesNotExistException * @throws Horde_Imap_Client_Exception - * @throws Horde_Imap_Client_Exception_NoSupportExtension * @throws Horde_Mime_Exception * @throws ServiceException + * @throws SmimeDecryptException */ public function findByIds(Horde_Imap_Client_Base $client, string $mailbox, - $ids, + array|Horde_Imap_Client_Ids $ids, string $userId, bool $loadBody = false, bool $runPhishingCheck = false): array { From 9e0ca977adde14a3f05ab15884412d52e04eaf88 Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Thu, 5 Mar 2026 13:05:09 +0100 Subject: [PATCH 3/4] docs: Update throws for getImapMessage Signed-off-by: Daniel Kesselberg --- lib/Contracts/IMailManager.php | 2 ++ lib/Service/MailManager.php | 15 +-------------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/lib/Contracts/IMailManager.php b/lib/Contracts/IMailManager.php index 3a2fa71125..c18bf8f4a1 100644 --- a/lib/Contracts/IMailManager.php +++ b/lib/Contracts/IMailManager.php @@ -17,6 +17,7 @@ use OCA\Mail\Db\Tag; use OCA\Mail\Exception\ClientException; use OCA\Mail\Exception\ServiceException; +use OCA\Mail\Exception\SmimeDecryptException; use OCA\Mail\Exception\TrashMailboxNotSetException; use OCA\Mail\Model\IMAPMessage; use OCA\Mail\Service\Quota; @@ -97,6 +98,7 @@ public function getSource(Horde_Imap_Client_Socket $client, * @return IMAPMessage * * @throws ServiceException + * @throws SmimeDecryptException */ public function getImapMessage(Horde_Imap_Client_Socket $client, Account $account, diff --git a/lib/Service/MailManager.php b/lib/Service/MailManager.php index 1d6cd50962..1c36a7508f 100644 --- a/lib/Service/MailManager.php +++ b/lib/Service/MailManager.php @@ -31,7 +31,6 @@ use OCA\Mail\Exception\ClientException; use OCA\Mail\Exception\ImapFlagEncodingException; use OCA\Mail\Exception\ServiceException; -use OCA\Mail\Exception\SmimeDecryptException; use OCA\Mail\Exception\TrashMailboxNotSetException; use OCA\Mail\Folder; use OCA\Mail\IMAP\FolderMapper; @@ -164,18 +163,6 @@ public function createMailbox(Account $account, string $name, array $specialUse return $this->mailboxMapper->find($account, $name); } - /** - * @param Horde_Imap_Client_Socket $client - * @param Account $account - * @param Mailbox $mailbox - * @param int $uid - * @param bool $loadBody - * - * @return IMAPMessage - * - * @throws ServiceException - * @throws SmimeDecryptException - */ #[\Override] public function getImapMessage(Horde_Imap_Client_Socket $client, Account $account, @@ -190,7 +177,7 @@ public function getImapMessage(Horde_Imap_Client_Socket $client, $account->getUserId(), $loadBody ); - } catch (Horde_Imap_Client_Exception|DoesNotExistException $e) { + } catch (DoesNotExistException|Horde_Mime_Exception|Horde_Imap_Client_Exception $e) { throw new ServiceException( 'Could not load message', $e->getCode(), From 2aacc58fbc8b0fa2972c896e2f6e837760390726 Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Thu, 5 Mar 2026 12:41:19 +0100 Subject: [PATCH 4/4] fix: Handle SmimeDecryptException when getting attachments Signed-off-by: Daniel Kesselberg --- lib/Service/Attachment/AttachmentService.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Service/Attachment/AttachmentService.php b/lib/Service/Attachment/AttachmentService.php index 929863c927..a7a9a836a3 100644 --- a/lib/Service/Attachment/AttachmentService.php +++ b/lib/Service/Attachment/AttachmentService.php @@ -22,6 +22,7 @@ use OCA\Mail\Db\Message; use OCA\Mail\Exception\AttachmentNotFoundException; use OCA\Mail\Exception\ServiceException; +use OCA\Mail\Exception\SmimeDecryptException; use OCA\Mail\Exception\UploadException; use OCA\Mail\IMAP\MessageMapper; use OCP\AppFramework\Db\DoesNotExistException; @@ -279,6 +280,8 @@ public function getAttachmentNames(Account $account, Mailbox $mailbox, Message $ true ); $attachments = $imapMessage->getAttachments(); + } catch (SmimeDecryptException $e) { + $this->logger->debug('Could not get attachment names for S/MIME encrypted message', ['exception' => $e, 'messageId' => $message->getUid()]); } catch (ServiceException $e) { $this->logger->warning('Could not get attachment names', ['exception' => $e, 'messageId' => $message->getUid()]); }