Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use OCA\Mail\Contracts\IDkimService;
use OCA\Mail\Contracts\IDkimValidator;
use OCA\Mail\Contracts\IMailSearch;
use OCA\Mail\Contracts\IMailTransmission;
use OCA\Mail\Contracts\ITrustedSenderService;
use OCA\Mail\Contracts\IUserPreferences;
use OCA\Mail\Dashboard\ImportantMailWidget;
Expand Down Expand Up @@ -61,7 +60,6 @@
use OCA\Mail\Service\AvatarService;
use OCA\Mail\Service\DkimService;
use OCA\Mail\Service\DkimValidator;
use OCA\Mail\Service\MailTransmission;
use OCA\Mail\Service\Search\MailSearch;
use OCA\Mail\Service\TrustedSenderService;
use OCA\Mail\Service\UserPreferenceService;
Expand Down Expand Up @@ -119,7 +117,6 @@ public function register(IRegistrationContext $context): void {
$context->registerServiceAlias(IAvatarService::class, AvatarService::class);
$context->registerServiceAlias(IAttachmentService::class, AttachmentService::class);
$context->registerServiceAlias(IMailSearch::class, MailSearch::class);
$context->registerServiceAlias(IMailTransmission::class, MailTransmission::class);
$context->registerServiceAlias(ITrustedSenderService::class, TrustedSenderService::class);
$context->registerServiceAlias(IUserPreferences::class, UserPreferenceService::class);
$context->registerServiceAlias(IDkimService::class, DkimService::class);
Expand Down
63 changes: 0 additions & 63 deletions lib/Contracts/IMailTransmission.php

This file was deleted.

63 changes: 0 additions & 63 deletions lib/Controller/AccountsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,19 @@

namespace OCA\Mail\Controller;

use Horde_Imap_Client;
use OCA\Mail\Account;
use OCA\Mail\AppInfo\Application;
use OCA\Mail\Contracts\IMailTransmission;
use OCA\Mail\Db\Mailbox;
use OCA\Mail\Exception\ClientException;
use OCA\Mail\Exception\CouldNotConnectException;
use OCA\Mail\Exception\ServiceException;
use OCA\Mail\Http\JsonResponse as MailJsonResponse;
use OCA\Mail\Http\TrapError;
use OCA\Mail\IMAP\MailboxSync;
use OCA\Mail\Model\NewMessageData;
use OCA\Mail\Service\AccountService;
use OCA\Mail\Service\AliasesService;
use OCA\Mail\Service\MailManager;
use OCA\Mail\Service\SetupService;
use OCA\Mail\Service\Sync\SyncService;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\OpenAPI;
Expand All @@ -45,10 +41,8 @@ class AccountsController extends Controller {
private LoggerInterface $logger;
private IL10N $l10n;
private AliasesService $aliasesService;
private IMailTransmission $mailTransmission;
private SetupService $setup;
private MailManager $mailManager;
private SyncService $syncService;
private IConfig $config;
private IRemoteHostValidator $hostValidator;
private MailboxSync $mailboxSync;
Expand All @@ -61,10 +55,8 @@ public function __construct(
LoggerInterface $logger,
IL10N $l10n,
AliasesService $aliasesService,
IMailTransmission $mailTransmission,
SetupService $setup,
MailManager $mailManager,
SyncService $syncService,
IConfig $config,
IRemoteHostValidator $hostValidator,
MailboxSync $mailboxSync,
Expand All @@ -76,10 +68,8 @@ public function __construct(
$this->logger = $logger;
$this->l10n = $l10n;
$this->aliasesService = $aliasesService;
$this->mailTransmission = $mailTransmission;
$this->setup = $setup;
$this->mailManager = $mailManager;
$this->syncService = $syncService;
$this->config = $config;
$this->hostValidator = $hostValidator;
$this->mailboxSync = $mailboxSync;
Expand Down Expand Up @@ -398,59 +388,6 @@ public function create(string $accountName,
);
}

/**
* @NoAdminRequired
*
* @return JSONResponse
*
* @throws ClientException
*/
#[TrapError]
public function draft(int $id,
string $subject,
string $body,
string $to,
string $cc,
string $bcc,
bool $isHtml = true,
?int $draftId = null): JSONResponse {
if ($draftId === null) {
$this->logger->info("Saving a new draft in account <$id>");
} else {
$this->logger->info("Updating draft <$draftId> in account <$id>");
}

$account = $this->accountService->find($this->currentUserId, $id);
$previousDraft = null;
if ($draftId !== null) {
try {
$previousDraft = $this->mailManager->getMessage($this->currentUserId, $draftId);
} catch (ClientException $e) {
$this->logger->info("Draft {$draftId} could not be loaded: {$e->getMessage()}");
}
}
$messageData = NewMessageData::fromRequest($account, $subject, $body, $to, $cc, $bcc, [], $isHtml);

try {
/** @var Mailbox $draftsMailbox */
[, $draftsMailbox, $newUID] = $this->mailTransmission->saveDraft($messageData, $previousDraft);
$this->syncService->syncMailbox(
$account,
$draftsMailbox,
Horde_Imap_Client::SYNC_NEWMSGSUIDS,
false,
null,
[]
);
return new JSONResponse([
'id' => $this->mailManager->getMessageIdForUid($draftsMailbox, $newUID)
]);
} catch (ClientException|ServiceException $ex) {
$this->logger->error('Saving draft failed: ' . $ex->getMessage());
throw $ex;
}
}

/**
* @NoAdminRequired
*
Expand Down
30 changes: 13 additions & 17 deletions lib/Controller/MessagesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
use OCA\Mail\Attachment;
use OCA\Mail\Contracts\IDkimService;
use OCA\Mail\Contracts\IMailSearch;
use OCA\Mail\Contracts\IMailTransmission;
use OCA\Mail\Contracts\ITrustedSenderService;
use OCA\Mail\Protocol\ProtocolFactory;
use OCA\Mail\Contracts\IUserPreferences;
use OCA\Mail\Db\Message;
use OCA\Mail\Exception\ClientException;
Expand Down Expand Up @@ -67,7 +67,7 @@
private IURLGenerator $urlGenerator;
private ContentSecurityPolicyNonceManager $nonceManager;
private ITrustedSenderService $trustedSenderService;
private IMailTransmission $mailTransmission;
private ProtocolFactory $protocolFactory;
private SmimeService $smimeService;
private IDkimService $dkimService;
private IUserPreferences $preferences;
Expand All @@ -89,7 +89,7 @@
IURLGenerator $urlGenerator,
ContentSecurityPolicyNonceManager $nonceManager,
ITrustedSenderService $trustedSenderService,
IMailTransmission $mailTransmission,
ProtocolFactory $protocolFactory,
SmimeService $smimeService,
IDkimService $dkimService,
IUserPreferences $preferences,
Expand All @@ -110,7 +110,7 @@
$this->urlGenerator = $urlGenerator;
$this->nonceManager = $nonceManager;
$this->trustedSenderService = $trustedSenderService;
$this->mailTransmission = $mailTransmission;
$this->protocolFactory = $protocolFactory;
$this->smimeService = $smimeService;
$this->dkimService = $dkimService;
$this->preferences = $preferences;
Expand Down Expand Up @@ -495,7 +495,7 @@
}

try {
$this->mailTransmission->sendMdn($account, $mailbox, $message);
$this->protocolFactory->transmissionConnector($account)->sendMdn($account, $mailbox, $message);
$this->mailManager->flagMessages($account, $mailbox, '$mdnsent', true, $message);
} catch (ServiceException $ex) {
$this->logger->error('Sending mdn failed: ' . $ex->getMessage());
Expand Down Expand Up @@ -527,7 +527,7 @@
$response = new JSONResponse([
'source' => $this->mailManager->getRawMessage(
$account,
$mailbox,

Check failure on line 530 in lib/Controller/MessagesController.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable33

InvalidArgument

lib/Controller/MessagesController.php:530:5: InvalidArgument: Argument 2 of OCA\Mail\Service\MailManager::getRawMessage expects string, but OCA\Mail\Db\Mailbox provided (see https://psalm.dev/004)

Check failure on line 530 in lib/Controller/MessagesController.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable32

InvalidArgument

lib/Controller/MessagesController.php:530:5: InvalidArgument: Argument 2 of OCA\Mail\Service\MailManager::getRawMessage expects string, but OCA\Mail\Db\Mailbox provided (see https://psalm.dev/004)

Check failure on line 530 in lib/Controller/MessagesController.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-master

InvalidArgument

lib/Controller/MessagesController.php:530:5: InvalidArgument: Argument 2 of OCA\Mail\Service\MailManager::getRawMessage expects string, but OCA\Mail\Db\Mailbox provided (see https://psalm.dev/004)
$message
)
]);
Expand Down Expand Up @@ -564,7 +564,7 @@

$source = $this->mailManager->getRawMessage(
$account,
$mailbox,

Check failure on line 567 in lib/Controller/MessagesController.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable33

InvalidArgument

lib/Controller/MessagesController.php:567:4: InvalidArgument: Argument 2 of OCA\Mail\Service\MailManager::getRawMessage expects string, but OCA\Mail\Db\Mailbox provided (see https://psalm.dev/004)

Check failure on line 567 in lib/Controller/MessagesController.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable32

InvalidArgument

lib/Controller/MessagesController.php:567:4: InvalidArgument: Argument 2 of OCA\Mail\Service\MailManager::getRawMessage expects string, but OCA\Mail\Db\Mailbox provided (see https://psalm.dev/004)

Check failure on line 567 in lib/Controller/MessagesController.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-master

InvalidArgument

lib/Controller/MessagesController.php:567:4: InvalidArgument: Argument 2 of OCA\Mail\Service\MailManager::getRawMessage expects string, but OCA\Mail\Db\Mailbox provided (see https://psalm.dev/004)
$message
);

Expand Down Expand Up @@ -617,18 +617,14 @@

$html = $cacheInstance->get($imapMessageCacheKey);
if ($html === null) {
$client = $this->clientFactory->getClient($account);
try {
$html = $this->mailManager->getImapMessage(
$client,
$account,
$mailbox,
$message->getUid(),
true
)->getHtmlBody($id);
} finally {
$client->logout();
}
$html = $this->mailManager->getImapMessage(
$account,
$mailbox,
$message,
true
)->getHtmlBody(
$id
);
}


Expand Down
Loading
Loading