diff --git a/dev/Common/File.js b/dev/Common/File.js index 19d194b05..67353ec9e 100644 --- a/dev/Common/File.js +++ b/dev/Common/File.js @@ -249,10 +249,10 @@ export const FileInfo = { * @param {string} sFileType * @returns {string} */ - getCombinedIconClass: data => { + getAttachmentsIconClass: data => { if (arrayLength(data)) { let icons = data - .map(item => item ? FileInfo.getIconClass(FileInfo.getExtension(item[0]), item[1]) : '') + .map(item => item ? FileInfo.getIconClass(FileInfo.getExtension(item.fileName), item.mimeType) : '') .validUnique(); return (icons && 1 === icons.length && 'icon-file' !== icons[0]) diff --git a/dev/Model/AttachmentCollection.js b/dev/Model/AttachmentCollection.js index 36a97534b..c22784bb7 100644 --- a/dev/Model/AttachmentCollection.js +++ b/dev/Model/AttachmentCollection.js @@ -11,6 +11,13 @@ export class AttachmentCollectionModel extends AbstractCollectionModel */ static reviveFromJson(items) { return super.reviveFromJson(items, attachment => AttachmentModel.reviveFromJson(attachment)); +/* + const attachments = super.reviveFromJson(items, attachment => AttachmentModel.reviveFromJson(attachment)); + if (attachments) { + attachments.InlineCount = attachments.reduce((accumulator, a) => accumulator + (a.isInline ? 1 : 0), 0); + } + return attachments; +*/ } /** diff --git a/dev/Model/Message.js b/dev/Model/Message.js index 4e712952c..cdfaf7ba2 100644 --- a/dev/Model/Message.js +++ b/dev/Model/Message.js @@ -77,13 +77,12 @@ export class MessageModel extends AbstractModel { }); this.attachments = ko.observableArray(new AttachmentCollectionModel); - this.attachmentsSpecData = ko.observableArray(); this.threads = ko.observableArray(); this.unsubsribeLinks = ko.observableArray(); this.flags = ko.observableArray(); this.addComputables({ - attachmentIconClass: () => FileInfo.getCombinedIconClass(this.hasAttachments() ? this.attachmentsSpecData() : []), + attachmentIconClass: () => FileInfo.getAttachmentsIconClass(this.attachments()), threadsLen: () => this.threads().length, isImportant: () => MessagePriority.High === this.priority(), @@ -137,7 +136,6 @@ export class MessageModel extends AbstractModel { this.selected(false); this.checked(false); this.hasAttachments(false); - this.attachmentsSpecData([]); this.isHtml(false); this.hasImages(false); @@ -190,6 +188,7 @@ export class MessageModel extends AbstractModel { json.Priority = MessagePriority.Normal; } if (super.revivePropertiesFromJson(json)) { + this.hasAttachments(!!this.attachments.length); // this.foundCIDs = isArray(json.FoundCIDs) ? json.FoundCIDs : []; // this.attachments(AttachmentCollectionModel.reviveFromJson(json.Attachments, this.foundCIDs)); @@ -441,7 +440,7 @@ export class MessageModel extends AbstractModel { this.selected(message.selected()); this.checked(message.checked()); this.hasAttachments(message.hasAttachments()); - this.attachmentsSpecData(message.attachmentsSpecData()); + this.attachments(message.attachments()); } this.body = null; diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Mail/AttachmentCollection.php b/snappymail/v/0.0.0/app/libraries/MailSo/Mail/AttachmentCollection.php index 153ed2d8d..5091063a0 100644 --- a/snappymail/v/0.0.0/app/libraries/MailSo/Mail/AttachmentCollection.php +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Mail/AttachmentCollection.php @@ -23,32 +23,20 @@ class AttachmentCollection extends \MailSo\Base\Collection parent::append($oAttachment, $bToTop); } - public function InlineCount() : int - { - $iCount = 0; - foreach ($this as $oAttachment) { - if ($oAttachment && $oAttachment->IsInline()) { - ++$iCount; - } - } - return $iCount; - } - public function SpecData() : array { $aResult = array(); foreach ($this as $oAttachment) { - $aResult[] = $oAttachment - ? array($oAttachment->FileName(true), $oAttachment->MimeType()) - : null; + $aResult[] = array( + '@Object' => 'Object/Attachment', + 'FileName' => $oAttachment->FileName(true), + 'MimeType' => $oAttachment->MimeType(), + 'IsInline' => $oAttachment->IsInline() + ); } - return $aResult; - } - - public function jsonSerialize() - { - return array_merge(parent::jsonSerialize(), array( - 'InlineCount' => $this->InlineCount() - )); + return array( + '@Object' => 'Collection/AttachmentCollection', + '@Collection' => $aResult + ); } } 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 c19ab2726..7bd95be6a 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 @@ -654,8 +654,7 @@ class Message implements \JsonSerializable 'UnsubsribeLinks' => $this->aUnsubsribeLinks, 'ReadReceipt' => '', - 'HasAttachments' => $this->oAttachments && 0 < $this->oAttachments->count(), - 'AttachmentsSpecData' => $this->oAttachments ? $this->oAttachments->SpecData() : array(), + 'Attachments' => $this->oAttachments ? $this->oAttachments->SpecData() : null, 'Flags' => $this->aFlagsLowerCase ); diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Response.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Response.php index 5f6724c30..f03519bb3 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Response.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Response.php @@ -202,13 +202,12 @@ trait Response if ('Message' === $sParent) { - $oAttachments = /* @var \MailSo\Mail\AttachmentCollection */ $mResponse->Attachments(); - $bHasExternals = false; $mFoundCIDs = array(); $aContentLocationUrls = array(); $mFoundContentLocationUrls = array(); + $oAttachments = /* @var \MailSo\Mail\AttachmentCollection */ $mResponse->Attachments(); if ($oAttachments && 0 < $oAttachments->count()) { foreach ($oAttachments as /* @var \MailSo\Mail\Attachment */ $oAttachment) @@ -218,7 +217,7 @@ trait Response $sContentLocation = $oAttachment->ContentLocation(); if ($sContentLocation && \strlen($sContentLocation)) { - $aContentLocationUrls[] = $oAttachment->ContentLocation(); + $aContentLocationUrls[] = $sContentLocation; } } } @@ -273,12 +272,14 @@ trait Response $mResult['HasExternals'] = $bHasExternals; $mResult['HasInternals'] = (\is_array($mFoundCIDs) && \count($mFoundCIDs)) || (\is_array($mFoundContentLocationUrls) && \count($mFoundContentLocationUrls)); + $mResult['Attachments'] = $this->responseObject($oAttachments, $sParent, $aParameters); +/* // $mResult['FoundCIDs'] = $mFoundCIDs; $mResult['Attachments'] = $this->responseObject($oAttachments, $sParent, \array_merge($aParameters, array( 'FoundCIDs' => $mFoundCIDs, 'FoundContentLocationUrls' => $mFoundContentLocationUrls ))); - +*/ $mResult['ReadReceipt'] = $mResponse->ReadReceipt(); if (\strlen($mResult['ReadReceipt']) && !\in_array('$forwarded', $mResult['Flags']))