Skip to content

Commit e2c49f3

Browse files
committed
fix: Fix incorrect flag for MDN sent and hide junk flag used by Thunderbird
Signed-off-by: David Dreschner <[email protected]>
1 parent d1f55af commit e2c49f3

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

lib/Controller/MessagesController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ public function mdn(int $id): JSONResponse {
472472

473473
try {
474474
$this->mailTransmission->sendMdn($account, $mailbox, $message);
475-
$this->mailManager->flagMessage($account, $mailbox->getName(), $message->getUid(), 'mdnsent', true);
475+
$this->mailManager->flagMessage($account, $mailbox->getName(), $message->getUid(), '$mdnsent', true);
476476
} catch (ServiceException $ex) {
477477
$this->logger->error('Sending mdn failed: ' . $ex->getMessage());
478478
throw $ex;

lib/Db/Message.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,10 @@ class Message extends Entity implements JsonSerializable {
8383
'seen',
8484
'forwarded',
8585
'$junk',
86+
'junk',
8687
'$notjunk',
87-
'mdnsent',
88+
'notjunk',
89+
'$mdnsent',
8890
Tag::LABEL_IMPORTANT,
8991
'$important' // @todo remove this when we have removed all references on IMAP to $important @link https://github.com/nextcloud/mail/issues/25
9092
];
@@ -282,10 +284,12 @@ public function setFlag(string $flag, bool $value = true) {
282284
}
283285
if ($flag === Tag::LABEL_IMPORTANT) {
284286
$this->setFlagImportant($value);
285-
} elseif ($flag === '$junk') {
287+
} elseif ($flag === '$junk' || $flag === 'junk') {
286288
$this->setFlagJunk($value);
287-
} elseif ($flag === '$notjunk') {
289+
} elseif ($flag === '$notjunk' || $flag === 'notjunk') {
288290
$this->setFlagNotjunk($value);
291+
} elseif ($flag === '$mdnsent') {
292+
$this->setFlagMdnsent($value);
289293
} else {
290294
$this->setter(
291295
$this->columnToProperty("flag_$flag"),
@@ -338,7 +342,7 @@ public function jsonSerialize() {
338342
'important' => ($this->getFlagImportant() === true),
339343
'$junk' => ($this->getFlagJunk() === true),
340344
'$notjunk' => ($this->getFlagNotjunk() === true),
341-
'mdnsent' => ($this->getFlagMdnsent() === true),
345+
'$mdnsent' => ($this->getFlagMdnsent() === true),
342346
],
343347
'tags' => $indexed,
344348
'from' => $this->getFrom()->jsonSerialize(),

lib/Model/IMAPMessage.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public function getFlags(): array {
162162
'draft' => in_array(Horde_Imap_Client::FLAG_DRAFT, $this->flags),
163163
'forwarded' => in_array(Horde_Imap_Client::FLAG_FORWARDED, $this->flags),
164164
'hasAttachments' => $this->hasAttachments,
165-
'mdnsent' => in_array(Horde_Imap_Client::FLAG_MDNSENT, $this->flags, true),
165+
'$mdnsent' => in_array(Horde_Imap_Client::FLAG_MDNSENT, $this->flags, true),
166166
'important' => in_array(Tag::LABEL_IMPORTANT, $this->flags, true)
167167
];
168168
}
@@ -535,7 +535,7 @@ public function toDbMessage(int $mailboxId, MailAccount $account): Message {
535535
$msg->setFlagJunk(
536536
in_array(Horde_Imap_Client::FLAG_JUNK, $flags, true)
537537
|| in_array('junk', $flags, true)
538-
);
538+
); // While this is not a standard IMAP flag, Thunderbird uses it to mark "junk"
539539
$msg->setFlagNotjunk(in_array(Horde_Imap_Client::FLAG_NOTJUNK, $flags, true) || in_array('nonjunk', $flags, true));// While this is not a standard IMAP Flag, Thunderbird uses it to mark "not junk"
540540
// @todo remove this as soon as possible @link https://github.com/nextcloud/mail/issues/25
541541
$msg->setFlagImportant(in_array('$important', $flags, true) || in_array('$labelimportant', $flags, true) || in_array(Tag::LABEL_IMPORTANT, $flags, true));
@@ -552,6 +552,7 @@ public function toDbMessage(int $mailboxId, MailAccount $account): Message {
552552
Horde_Imap_Client::FLAG_DELETED,
553553
Horde_Imap_Client::FLAG_DRAFT,
554554
Horde_Imap_Client::FLAG_JUNK,
555+
'junk', // While this is not a standard IMAP flag, Thunderbird uses it to mark "junk"
555556
Horde_Imap_Client::FLAG_NOTJUNK,
556557
'nonjunk', // While this is not a standard IMAP Flag, Thunderbird uses it to mark "not junk"
557558
Horde_Imap_Client::FLAG_MDNSENT,

src/components/MdnRequest.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default {
5151
computed: {
5252
...mapStores(useMainStore),
5353
mdnSent() {
54-
return this.message.flags.mdnsent
54+
return this.message.flags.$mdnsent
5555
},
5656
},
5757
@@ -62,7 +62,7 @@ export default {
6262
6363
try {
6464
await sendMdn(this.message.databaseId)
65-
this.mainStore.flagEnvelopeMutation({ envelope: this.message, flag: 'mdnsent', value: true })
65+
this.mainStore.flagEnvelopeMutation({ envelope: this.message, flag: '$mdnsent', value: true })
6666
} catch (error) {
6767
logger.error('could not send mdn', error)
6868
showError(t('mail', 'Could not send mdn'))

0 commit comments

Comments
 (0)