/** * @param {AjaxJsonMessage} json * @returns {boolean} */ initByJson(json) { let result = false, priority = MessagePriority.Normal; if (json && 'Object/Message' === json['@Object']) { priority = pInt(json.Priority); this.priority(-1 < inArray(priority, [MessagePriority.High, MessagePriority.Low]) ? priority : MessagePriority.Normal); this.folderFullNameRaw = json.Folder; this.uid = json.Uid; this.hash = json.Hash; this.requestHash = json.RequestHash; this.proxy = !!json.ExternalProxy; this.size(pInt(json.Size)); this.from = emailArrayFromJson(json.From); this.to = emailArrayFromJson(json.To); this.cc = emailArrayFromJson(json.Cc); this.bcc = emailArrayFromJson(json.Bcc); this.replyTo = emailArrayFromJson(json.ReplyTo); this.deliveredTo = emailArrayFromJson(json.DeliveredTo); this.unsubsribeLinks = isNonEmptyArray(json.UnsubsribeLinks) ? json.UnsubsribeLinks : []; this.subject(json.Subject); if (isArray(json.SubjectParts)) { this.subjectPrefix(json.SubjectParts[0]); this.subjectSuffix(json.SubjectParts[1]); } else { this.subjectPrefix(''); this.subjectSuffix(this.subject()); } this.dateTimeStampInUTC(pInt(json.DateTimeStampInUTC)); this.hasAttachments(!!json.HasAttachments); this.attachmentsSpecData(isArray(json.AttachmentsSpecData) ? json.AttachmentsSpecData : []); this.fromEmailString(emailArrayToString(this.from, true)); this.fromClearEmailString(emailArrayToStringClear(this.from)); this.toEmailsString(emailArrayToString(this.to, true)); this.toClearEmailsString(emailArrayToStringClear(this.to)); this.threads(isArray(json.Threads) ? json.Threads : []); this.initFlagsByJson(json); this.computeSenderEmail(); result = true; } return result; }
MessageSimpleModel.prototype.initByJson = function (oJson) { var bResult = false; if (oJson && 'Object/Message' === oJson['@Object']) { this.folder = Utils.pString(oJson.Folder); this.folderFullNameRaw = this.folder; this.uid = Utils.pString(oJson.Uid); this.subject = Utils.pString(oJson.Subject); if (Utils.isArray(oJson.SubjectParts)) { this.subjectPrefix = Utils.pString(oJson.SubjectParts[0]); this.subjectSuffix = Utils.pString(oJson.SubjectParts[1]); } else { this.subjectPrefix = ''; this.subjectSuffix = this.subject; } this.from = MessageHelper.emailArrayFromJson(oJson.From); this.to = MessageHelper.emailArrayFromJson(oJson.To); this.cc = MessageHelper.emailArrayFromJson(oJson.Cc); this.bcc = MessageHelper.emailArrayFromJson(oJson.Bcc); this.replyTo = MessageHelper.emailArrayFromJson(oJson.ReplyTo); this.deliveredTo = MessageHelper.emailArrayFromJson(oJson.DeliveredTo); this.size = Utils.pInt(oJson.Size); this.timestamp = Utils.pInt(oJson.DateTimeStampInUTC); this.fromAsString = MessageHelper.emailArrayToString(this.from, true); this.fromAsStringClear = MessageHelper.emailArrayToStringClear(this.from); this.toAsString = MessageHelper.emailArrayToString(this.to, true); this.toAsStringClear = MessageHelper.emailArrayToStringClear(this.to); this.flagged(false); this.selected(false); this.populateSenderEmail(); bResult = true; } return bResult; };
MessageUserStore.prototype.initUidNextAndNewMessages = function (sFolder, sUidNext, aNewMessages) { if (Cache.getFolderInboxName() === sFolder && Utils.isNormal(sUidNext) && sUidNext !== '') { if (Utils.isArray(aNewMessages) && 0 < aNewMessages.length) { var iIndex = 0, iLen = aNewMessages.length, NotificationStore = require('Stores/User/Notification') ; _.each(aNewMessages, function (oItem) { Cache.addNewMessageCache(sFolder, oItem.Uid); }); NotificationStore.playSoundNotification(); if (3 < iLen) { NotificationStore.displayDesktopNotification( Links.notificationMailIcon(), require('Stores/User/Account').email(), Translator.i18n('MESSAGE_LIST/NEW_MESSAGE_NOTIFICATION', { 'COUNT': iLen }), {'Folder': '', 'Uid': ''} ); } else { for (; iIndex < iLen; iIndex++) { NotificationStore.displayDesktopNotification( Links.notificationMailIcon(), MessageHelper.emailArrayToString( MessageHelper.emailArrayFromJson(aNewMessages[iIndex].From), false), aNewMessages[iIndex].Subject, { 'Folder': aNewMessages[iIndex].Folder, 'Uid': aNewMessages[iIndex].Uid } ); } } } Cache.setFolderUidNext(sFolder, sUidNext); } };
/** * @param {boolean} friendlyView * @param {boolean=} wrapWithLink = false * @returns {string} */ replyToToLine(friendlyView, wrapWithLink = false) { return emailArrayToString(this.replyTo, friendlyView, wrapWithLink); }
/** * @param {boolean} friendlyView * @param {boolean=} wrapWithLink = false * @returns {string} */ fromToLine(friendlyView, wrapWithLink = false) { return emailArrayToString(this.from, friendlyView, wrapWithLink); }
MessageModel.prototype.replyToToLine = function (bFriendlyView, bWrapWithLink) { return MessageHelper.emailArrayToString(this.replyTo, bFriendlyView, bWrapWithLink); };
MessageModel.prototype.initByJson = function (oJsonMessage) { var bResult = false, iPriority = Enums.MessagePriority.Normal ; if (oJsonMessage && 'Object/Message' === oJsonMessage['@Object']) { iPriority = Utils.pInt(oJsonMessage.Priority); this.priority(-1 < Utils.inArray(iPriority, [Enums.MessagePriority.High, Enums.MessagePriority.Low]) ? iPriority : Enums.MessagePriority.Normal); this.folderFullNameRaw = oJsonMessage.Folder; this.uid = oJsonMessage.Uid; this.hash = oJsonMessage.Hash; this.requestHash = oJsonMessage.RequestHash; this.proxy = !!oJsonMessage.ExternalProxy; this.size(Utils.pInt(oJsonMessage.Size)); this.from = MessageHelper.emailArrayFromJson(oJsonMessage.From); this.to = MessageHelper.emailArrayFromJson(oJsonMessage.To); this.cc = MessageHelper.emailArrayFromJson(oJsonMessage.Cc); this.bcc = MessageHelper.emailArrayFromJson(oJsonMessage.Bcc); this.replyTo = MessageHelper.emailArrayFromJson(oJsonMessage.ReplyTo); this.deliveredTo = MessageHelper.emailArrayFromJson(oJsonMessage.DeliveredTo); this.subject(oJsonMessage.Subject); if (Utils.isArray(oJsonMessage.SubjectParts)) { this.subjectPrefix(oJsonMessage.SubjectParts[0]); this.subjectSuffix(oJsonMessage.SubjectParts[1]); } else { this.subjectPrefix(''); this.subjectSuffix(this.subject()); } this.dateTimeStampInUTC(Utils.pInt(oJsonMessage.DateTimeStampInUTC)); this.hasAttachments(!!oJsonMessage.HasAttachments); this.attachmentsSpecData(Utils.isArray(oJsonMessage.AttachmentsSpecData) ? oJsonMessage.AttachmentsSpecData : []); this.fromEmailString(MessageHelper.emailArrayToString(this.from, true)); this.fromClearEmailString(MessageHelper.emailArrayToStringClear(this.from)); this.toEmailsString(MessageHelper.emailArrayToString(this.to, true)); this.toClearEmailsString(MessageHelper.emailArrayToStringClear(this.to)); this.threads(Utils.isArray(oJsonMessage.Threads) ? oJsonMessage.Threads : []); this.initFlagsByJson(oJsonMessage); this.computeSenderEmail(); bResult = true; } return bResult; };