2021-02-26 06:35:00 +01:00
|
|
|
!function(){"use strict";function c(e){"function"!=typeof e.then&&(angular.extend(this,e),_.forEach(this.identities,function(e){if(e.fullName&&e.email?e.full=e.fullName+" <"+e.email+">":e.email?e.full="<"+e.email+">":e.full="",e.signature){var t=angular.element("<div>"+e.signature+"</div>");e.textSignature=_.map(t.contents(),"textContent").join(" ").trim()}}),c.$log.debug("Account: "+JSON.stringify(e,void 0,2)))}c.$factory=["$q","$timeout","$log","sgSettings","Resource","Preferences","Mailbox","Message",function(e,t,n,s,i,o,a,r){return angular.extend(c,{$q:e,$timeout:t,$log:n,$$resource:new i(s.activeUser("folderURL")+"Mail",s.activeUser()),$Preferences:o,$Mailbox:a,$Message:r}),c}];try{angular.module("SOGo.MailerUI")}catch(e){angular.module("SOGo.MailerUI",["SOGo.Common"])}angular.module("SOGo.MailerUI").factory("Account",c.$factory),c.$findAll=function(e){return e?c.$unwrapCollection(e):c.$accounts?c.$q.when(c.$accounts):c.$$resource.fetch("","mailAccounts").then(function(e){return c.$unwrapCollection(e)})},c.$unwrapCollection=function(e){var n=[];return angular.forEach(e,function(e,t){e.id=t,n[t]=new c(e)}),c.$accounts=n},c.prototype.getLength=function(){return this.$expanded?this.$flattenMailboxes().length:0},c.prototype.getItemAtIndex=function(e){var t;return t=this.$flattenMailboxes(),0<=e&&e<t.length?t[e]:null},c.prototype.$getMailboxes=function(e){var o=this,t=e&&e.reload;return this.$mailboxes&&!t?c.$q.when(this.$mailboxes):(!t&&this.$futureMailboxesData||(this.$futureMailboxesData=c.$Mailbox.$find(this,e).then(function(e){var n=o.$flattenMailboxes({all:!0});o.$mailboxes=e,o.$expanded=!1;var s=function(e){_.forEach(e,function(e){var t=_.find(n,["id",e.id]);t&&(e.unseenCount=t.unseenCount),e.children&&0<e.children.length&&s(e.children)})};s(o.$mailboxes);var t,i=function(e){_.forEach(e,function(e){e.$expanded=0<=t.indexOf("/"+e.id),e.children&&0<e.children.length&&i(e.children)})};if(c.$Preferences.settings.Mail.ExpandedFolders){if(angular.isString(c.$Preferences.settings.Mail.ExpandedFolders))try{t=angular.fromJson(c.$Preferences.settings.Mail.ExpandedFolders)}catch(e){c.$log.warn("Can't parse list of expanded folders. String was: "+c.$Preferences.settings.Mail.ExpandedFolders),t=[]}else t=c.$Preferences.settings.Mail.ExpandedFolders;o.$expanded=0<=t.indexOf("/"+o.id),0<t.length&&i(o.$mailboxes)}return c.$accounts&&(o.$expanded|=1==c.$accounts.length),o.$flattenMailboxes({reload:!0}),o.$mailboxes})),this.$futureMailboxesData)},c.prototype.$flattenMailboxes=function(t){var n=[],s=[],i=function(e){_.forEach(e,function(e){n.push(e),(t&&t.all||e.$expanded)&&e.children&&0<e.children.length&&i(e.children)})};return!this.$$flattenMailboxes||t&&(t.reload||t.all)?(i(this.$mailboxes),t&&t.all||(this.$$flattenMailboxes=n,t&&t.saveState&&(_.forEach(c.$accounts,function(e){e.$expanded&&s.push("/"+e.id),_.reduce(e.$$flattenMailboxes,function(e,t){return t.$expanded&&e.push("/"+t.id),e},s)}),c.$$resource.post(null,"saveFoldersState",s)))):n=this.$$flattenMailboxes,n},c.prototype.$getMailboxByType=function(n){var s=function(e){var t=_.find(e,function(e){return e.type==n});return t||angular.forEach(e,function(e){!t&&e.children&&0<e.children.length&&(t=s(e.children))}),t};return s(this.$mailboxes)},c.prototype.$getMailboxByPath=function(n){var s=function(e){var t=_.find(e,function(e){return e.path==n});return t||angular.forEach(e,function(e){!t&&e.children&&0<e.children.length&&(t=s(e.children))}),t};return s(this.$mailboxes)},c.prototype.$newMailbox=function(e,t){var n=this;return c.$$resource.post(e.toString(),"createFolder",{name:t}).then(function(){n.$getMailboxes({reload:!0})})},c.prototype.getTextSignature=function(e){if(e.signature){var t=angular.element("<div>"+e.signature+"</div>");e.textSignature=_.map(t.contents(),"textContent").join(" ").trim()}else e.textSignature="";return e.textSignature},c.prototype.$certificate=function(){var t=this;return this.security&&this.security.hasCertificate?this.$$certificate?c.$q.when(this.$$certificate):c.$$resource.fetch(this.id.toString(),"certificate").then(function(e){return t.$$c
|