From 528b6cd096f523a41dc71362fb17aec33e085d58 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Wed, 25 Jan 2023 09:41:15 +0100 Subject: [PATCH] cleanup some json code --- dev/Knoin/AbstractModel.js | 16 ++++++++-------- dev/Model/Attachment.js | 1 + dev/Model/Message.js | 6 ++++++ .../app/libraries/MailSo/Imap/BodyStructure.php | 2 +- .../0.0.0/app/libraries/MailSo/Mail/Message.php | 6 +++--- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/dev/Knoin/AbstractModel.js b/dev/Knoin/AbstractModel.js index 66f94e6a2..092466e00 100644 --- a/dev/Knoin/AbstractModel.js +++ b/dev/Knoin/AbstractModel.js @@ -80,11 +80,9 @@ export class AbstractModel { } revivePropertiesFromJson(json) { - let model = this.constructor; - if (!model.validJson(json)) { - return false; - } - forEachObjectEntry(json, (key, value) => { + const model = this.constructor, + valid = model.validJson(json); + valid && forEachObjectEntry(json, (key, value) => { if ('@' !== key[0]) try { // key = key[0].toLowerCase() + key.slice(1); switch (typeof this[key]) @@ -103,9 +101,11 @@ export class AbstractModel { this[key] = typeCast(this[key], value); break; case 'undefined': + console.log(`Undefined ${model.name}.${key} set`); this[key] = value; - // fall through - default: + break; +// default: +// console.log((typeof this[key])+` ${model.name}.${key} not revived`); // console.log((typeof this[key])+' '+(model.name)+'.'+key+' not revived'); } } catch (e) { @@ -113,7 +113,7 @@ export class AbstractModel { console.error(e); } }); - return true; + return valid; } } diff --git a/dev/Model/Attachment.js b/dev/Model/Attachment.js index 4ebe3d29f..011dcd271 100644 --- a/dev/Model/Attachment.js +++ b/dev/Model/Attachment.js @@ -18,6 +18,7 @@ export class AttachmentModel extends AbstractModel { this.checked = ko.observable(true); this.mimeType = ''; +// this.mimeTypeParams = ''; this.fileName = ''; this.fileNameExt = ''; this.fileType = FileType.Unknown; diff --git a/dev/Model/Message.js b/dev/Model/Message.js index 9d4793136..036d7b0b4 100644 --- a/dev/Model/Message.js +++ b/dev/Model/Message.js @@ -74,6 +74,7 @@ export class MessageModel extends AbstractModel { this.to = new EmailCollectionModel; this.cc = new EmailCollectionModel; this.bcc = new EmailCollectionModel; + this.sender = new EmailCollectionModel; this.replyTo = new EmailCollectionModel; this.deliveredTo = new EmailCollectionModel; this.body = null; @@ -120,6 +121,11 @@ export class MessageModel extends AbstractModel { readReceipt: '', + autocrypt: '', + // rfc8621 + id: '', +// threadId: '', + hasUnseenSubMessage: false, hasFlaggedSubMessage: false }); diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Imap/BodyStructure.php b/snappymail/v/0.0.0/app/libraries/MailSo/Imap/BodyStructure.php index 2fe70bf5a..246231322 100644 --- a/snappymail/v/0.0.0/app/libraries/MailSo/Imap/BodyStructure.php +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Imap/BodyStructure.php @@ -528,7 +528,7 @@ class BodyStructure implements \JsonSerializable return array( 'mimeIndex' => $this->sPartID, 'mimeType' => $this->sContentType, - 'mimeTypeParams' => $this->aContentTypeParams, +// 'mimeTypeParams' => $this->aContentTypeParams, 'fileName' => \MailSo\Base\Utils::SecureFileName($this->FileName(true)), 'estimatedSize' => $this->EstimatedSize(), 'cId' => $this->sContentID, diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Mail/Message.php b/snappymail/v/0.0.0/app/libraries/MailSo/Mail/Message.php index 55ac6e176..e6003b9a0 100644 --- a/snappymail/v/0.0.0/app/libraries/MailSo/Mail/Message.php +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Mail/Message.php @@ -380,11 +380,11 @@ class Message implements \JsonSerializable . \trim($oFetchResponse->GetFetchValue(FetchType::BODY.'['.$oMessage->pgpSigned['bodyPartId'].']')) ); if ($sPgpText) { - $oMessage->pgpSigned['Body'] = $sPgpText; + $oMessage->pgpSigned['body'] = $sPgpText; } $sPgpSignatureText = $oFetchResponse->GetFetchValue(FetchType::BODY.'['.$oMessage->pgpSigned['sigPartId'].']'); if ($sPgpSignatureText && 0 < \strpos($sPgpSignatureText, 'BEGIN PGP SIGNATURE')) { - $oMessage->pgpSigned['Signature'] = $oPart->SubParts()[0]->PartID(); + $oMessage->pgpSigned['signature'] = $oPart->SubParts()[0]->PartID(); } */ break; @@ -527,7 +527,7 @@ class Message implements \JsonSerializable // https://datatracker.ietf.org/doc/html/rfc8621#section-4.1.1 'id' => $this->sEmailId, // 'blobId' => $this->sEmailIdBlob, - 'threadId' => $this->sThreadId, +// 'threadId' => $this->sThreadId, // 'mailboxIds' => ['mailboxid'=>true], // 'keywords' => $keywords, 'size' => $this->iSize