Better keyword/tags/labels handling for #419

This commit is contained in:
the-djmaze 2022-10-06 10:42:21 +02:00
parent df2de7ad66
commit 2defb7ec35
4 changed files with 16 additions and 21 deletions

View file

@ -24,23 +24,22 @@ ignoredKeywords = [
// Mailo // Mailo
'sent', 'sent',
// KMail // KMail
'$attachment',
'$encrypted', '$encrypted',
'$error', '$error',
'$ignored', '$ignored',
'$invitation', '$invitation',
'$queued', '$queued',
'$replied',
'$sent', '$sent',
'$signed', '$signed',
'$todo', '$todo',
'$watched', '$watched',
// GMail // GMail
'$replied',
'$attachment',
'$notphishing', '$notphishing',
'junk', 'junk',
'nonjunk', 'nonjunk',
// KMail & GMail
'$attachment',
'$replied',
// Others // Others
'$readreceipt' '$readreceipt'
], ],

View file

@ -36,7 +36,7 @@ import { MessageFlagsCache } from 'Common/Cache';
import { AppUserStore } from 'Stores/User/App'; import { AppUserStore } from 'Stores/User/App';
import { SettingsUserStore } from 'Stores/User/Settings'; import { SettingsUserStore } from 'Stores/User/Settings';
import { AccountUserStore } from 'Stores/User/Account'; import { AccountUserStore } from 'Stores/User/Account';
import { FolderUserStore } from 'Stores/User/Folder'; import { FolderUserStore, isAllowedKeyword } from 'Stores/User/Folder';
import { MessageUserStore } from 'Stores/User/Message'; import { MessageUserStore } from 'Stores/User/Message';
import { MessagelistUserStore } from 'Stores/User/Messagelist'; import { MessagelistUserStore } from 'Stores/User/Messagelist';
import { ThemeStore } from 'Stores/Theme'; import { ThemeStore } from 'Stores/Theme';
@ -529,8 +529,8 @@ export class MailMessageView extends AbstractViewRight {
newTag() { newTag() {
let message = currentMessage(); let message = currentMessage();
if (message) { if (message) {
let keyword = prompt(i18n('MESSAGE/NEW_TAG'), '')?.replace(/\s+/g, ''); let keyword = prompt(i18n('MESSAGE/NEW_TAG'), '')?.replace(/[\s\\]+/g, '');
if (keyword.length) { if (keyword.length && isAllowedKeyword(keyword)) {
message.toggleTag(keyword); message.toggleTag(keyword);
FolderUserStore.currentFolder().permanentFlags.push(keyword); FolderUserStore.currentFolder().permanentFlags.push(keyword);
} }

View file

@ -647,6 +647,15 @@ class Message implements \JsonSerializable
$this->aFlagsLowerCase $this->aFlagsLowerCase
), true); ), true);
*/ */
// https://datatracker.ietf.org/doc/html/rfc5788#section-3.4.1
// Thunderbird $label1 is same as $Important?
// Thunderbird $label4 is same as $todo?
$aFlags = \array_unique(\str_replace(
['$readreceipt', '$replied', /* 'junk', 'nonjunk', '$queued', '$sent', 'sent'*/],
['$mdnsent', '\\answered',/* '$junk', '$notjunk', '$submitpending', '$submitted', '$submitted'*/],
$this->aFlagsLowerCase
));
return array( return array(
'@Object' => 'Object/Message', '@Object' => 'Object/Message',
'Folder' => $this->sFolder, 'Folder' => $this->sFolder,
@ -676,7 +685,7 @@ class Message implements \JsonSerializable
'Attachments' => $this->oAttachments ? $this->oAttachments->SpecData() : null, 'Attachments' => $this->oAttachments ? $this->oAttachments->SpecData() : null,
'Flags' => $this->aFlagsLowerCase, 'Flags' => $aFlags,
// https://datatracker.ietf.org/doc/html/rfc8621#section-4.1.1 // https://datatracker.ietf.org/doc/html/rfc8621#section-4.1.1
'id' => $this->sEmailId, 'id' => $this->sEmailId,

View file

@ -194,19 +194,6 @@ trait Response
'FileName' => (\strlen($sSubject) ? \MailSo\Base\Utils::ClearXss($sSubject) : 'message-'.$mResult['Uid']) . '.eml' 'FileName' => (\strlen($sSubject) ? \MailSo\Base\Utils::ClearXss($sSubject) : 'message-'.$mResult['Uid']) . '.eml'
)); ));
// https://datatracker.ietf.org/doc/html/rfc5788#section-3.4.1
$key = \array_search('$readreceipt', $mResult['Flags']);
if (false !== $key) {
$mResult['Flags'][$key] = '$mdnsent';
}
// KMail
$key = \array_search('$replied', $mResult['Flags']);
if (false !== $key) {
$mResult['Flags'][$key] = '\\answered';
}
$mResult['Flags'] = \array_unique($mResult['Flags']);
if ('Message' === $sParent) if ('Message' === $sParent)
{ {
$mResult['DraftInfo'] = $mResponse->DraftInfo(); $mResult['DraftInfo'] = $mResponse->DraftInfo();