diff --git a/lib/Provider/Command/MessageSend.php b/lib/Provider/Command/MessageSend.php index f8546f8935..63ca70dcd1 100644 --- a/lib/Provider/Command/MessageSend.php +++ b/lib/Provider/Command/MessageSend.php @@ -54,7 +54,6 @@ public function perform(string $userId, string $serviceId, IMessage $message, ar //$localMessage->setEditorBody($message->getBody()); $localMessage->setHtml(true); $localMessage->setSendAt($this->time->getTime()); - // convert all mail provider attachments to local attachments $attachments = []; if (count($message->getAttachments()) > 0) { @@ -90,14 +89,12 @@ public function perform(string $userId, string $serviceId, IMessage $message, ar $bcc, $attachments ); - // evaluate if job scheduler is NOT cron, send message right away otherwise let cron job handle it if ($this->config->getAppValue('core', 'backgroundjobs_mode', 'ajax') !== 'cron') { $localMessage = $this->outboxService->sendMessage($localMessage, $account); } return $localMessage; - } /** diff --git a/lib/Provider/MailProvider.php b/lib/Provider/MailProvider.php index 076f27eb3a..b35acc478f 100644 --- a/lib/Provider/MailProvider.php +++ b/lib/Provider/MailProvider.php @@ -70,9 +70,8 @@ public function hasServices(string $userId): bool { * @return array collection of service id and object ['1' => IServiceObject] */ public function listServices(string $userId): array { - + // retrieve service(s) details from data store try { - // retrieve service(s) details from data store $accounts = $this->accountService->findByUserId($userId); } catch (\Throwable $e) { $this->logger->error('Error occurred while retrieving mail account details', [ 'exception' => $e ]); @@ -87,7 +86,6 @@ public function listServices(string $userId): array { } // return list of services for user return $services; - } /** @@ -102,23 +100,19 @@ public function listServices(string $userId): array { * */ public function findServiceById(string $userId, string $serviceId): IService|null { - // determine if a valid user and service id was submitted if (empty($userId) && !ctype_digit($serviceId)) { return null; } - - try { - // retrieve service details from data store + // retrieve service details from data store + try { $account = $this->accountService->find($userId, (int)$serviceId); } catch(\Throwable $e) { $this->logger->error('Error occurred while retrieving mail account details', [ 'exception' => $e ]); return null; } - // return mail service object return $this->serviceFromAccount($userId, $account); - } /** @@ -132,9 +126,8 @@ public function findServiceById(string $userId, string $serviceId): IService|nul * @return IService|null returns service object or null if none found */ public function findServiceByAddress(string $userId, string $address): IService|null { - + // retrieve service details from data store try { - // retrieve service details from data store $accounts = $this->accountService->findByUserIdAndAddress($userId, $address); } catch(\Throwable $e) { $this->logger->error('Error occurred while retrieving mail account details', [ 'exception' => $e ]); @@ -147,7 +140,6 @@ public function findServiceByAddress(string $userId, string $address): IService| } return null; - } /** @@ -167,19 +159,17 @@ public function initiateService(): IService { * @since 4.0.0 * * @param string $userId system user id - * @param string $account mail account + * @param Account $account mail account * * @return IService service object */ protected function serviceFromAccount(string $userId, Account $account): IService { - // extract values $serviceId = (string)$account->getId(); $serviceLabel = $account->getName(); $serviceAddress = new MailAddress($account->getEmail(), $account->getName()); // return mail service object return new MailService($this->container, $userId, $serviceId, $serviceLabel, $serviceAddress); - } }