1010
1111namespace OCA \Mail \Controller ;
1212
13- use Horde_Imap_Client ;
1413use OCA \Mail \Account ;
1514use OCA \Mail \AppInfo \Application ;
16- use OCA \Mail \Contracts \IMailTransmission ;
1715use OCA \Mail \Db \Mailbox ;
1816use OCA \Mail \Exception \ClientException ;
1917use OCA \Mail \Exception \CouldNotConnectException ;
2018use OCA \Mail \Exception \ServiceException ;
2119use OCA \Mail \Http \JsonResponse as MailJsonResponse ;
2220use OCA \Mail \Http \TrapError ;
2321use OCA \Mail \IMAP \MailboxSync ;
24- use OCA \Mail \Model \NewMessageData ;
2522use OCA \Mail \Service \AccountService ;
2623use OCA \Mail \Service \AliasesService ;
2724use OCA \Mail \Service \MailManager ;
2825use OCA \Mail \Service \SetupService ;
29- use OCA \Mail \Service \Sync \SyncService ;
3026use OCP \AppFramework \Controller ;
3127use OCP \AppFramework \Http ;
3228use OCP \AppFramework \Http \Attribute \OpenAPI ;
@@ -45,10 +41,8 @@ class AccountsController extends Controller {
4541 private LoggerInterface $ logger ;
4642 private IL10N $ l10n ;
4743 private AliasesService $ aliasesService ;
48- private IMailTransmission $ mailTransmission ;
4944 private SetupService $ setup ;
5045 private MailManager $ mailManager ;
51- private SyncService $ syncService ;
5246 private IConfig $ config ;
5347 private IRemoteHostValidator $ hostValidator ;
5448 private MailboxSync $ mailboxSync ;
@@ -61,10 +55,8 @@ public function __construct(
6155 LoggerInterface $ logger ,
6256 IL10N $ l10n ,
6357 AliasesService $ aliasesService ,
64- IMailTransmission $ mailTransmission ,
6558 SetupService $ setup ,
6659 MailManager $ mailManager ,
67- SyncService $ syncService ,
6860 IConfig $ config ,
6961 IRemoteHostValidator $ hostValidator ,
7062 MailboxSync $ mailboxSync ,
@@ -76,10 +68,8 @@ public function __construct(
7668 $ this ->logger = $ logger ;
7769 $ this ->l10n = $ l10n ;
7870 $ this ->aliasesService = $ aliasesService ;
79- $ this ->mailTransmission = $ mailTransmission ;
8071 $ this ->setup = $ setup ;
8172 $ this ->mailManager = $ mailManager ;
82- $ this ->syncService = $ syncService ;
8373 $ this ->config = $ config ;
8474 $ this ->hostValidator = $ hostValidator ;
8575 $ this ->mailboxSync = $ mailboxSync ;
@@ -398,59 +388,6 @@ public function create(string $accountName,
398388 );
399389 }
400390
401- /**
402- * @NoAdminRequired
403- *
404- * @return JSONResponse
405- *
406- * @throws ClientException
407- */
408- #[TrapError]
409- public function draft (int $ id ,
410- string $ subject ,
411- string $ body ,
412- string $ to ,
413- string $ cc ,
414- string $ bcc ,
415- bool $ isHtml = true ,
416- ?int $ draftId = null ): JSONResponse {
417- if ($ draftId === null ) {
418- $ this ->logger ->info ("Saving a new draft in account < $ id> " );
419- } else {
420- $ this ->logger ->info ("Updating draft < $ draftId> in account < $ id> " );
421- }
422-
423- $ account = $ this ->accountService ->find ($ this ->currentUserId , $ id );
424- $ previousDraft = null ;
425- if ($ draftId !== null ) {
426- try {
427- $ previousDraft = $ this ->mailManager ->getMessage ($ this ->currentUserId , $ draftId );
428- } catch (ClientException $ e ) {
429- $ this ->logger ->info ("Draft {$ draftId } could not be loaded: {$ e ->getMessage ()}" );
430- }
431- }
432- $ messageData = NewMessageData::fromRequest ($ account , $ subject , $ body , $ to , $ cc , $ bcc , [], $ isHtml );
433-
434- try {
435- /** @var Mailbox $draftsMailbox */
436- [, $ draftsMailbox , $ newUID ] = $ this ->mailTransmission ->saveDraft ($ messageData , $ previousDraft );
437- $ this ->syncService ->syncMailbox (
438- $ account ,
439- $ draftsMailbox ,
440- Horde_Imap_Client::SYNC_NEWMSGSUIDS ,
441- false ,
442- null ,
443- []
444- );
445- return new JSONResponse ([
446- 'id ' => $ this ->mailManager ->getMessageIdForUid ($ draftsMailbox , $ newUID )
447- ]);
448- } catch (ClientException |ServiceException $ ex ) {
449- $ this ->logger ->error ('Saving draft failed: ' . $ ex ->getMessage ());
450- throw $ ex ;
451- }
452- }
453-
454391 /**
455392 * @NoAdminRequired
456393 *
0 commit comments