Built motion from commit (unavailable).|2.3.98
[motion2.git] / server / api / mailAccount / mailAccount.rpc.js
index a01a7b6..188f7b8 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x88f0=['Applications','List\x20not\x20found','contact','messageId','generate','subject','format','YYYY-MM-DD\x20HH:mm:ss','MailInteraction','MailMessage','Messages','inReplyTo','Contact\x20not\x20found','spread','update','attach','interaction','created','create','attachments','originTo','originCc','bcc','Attachment','Attachments','User','name','UserId','unshift','agent','waitForTheAssignedAgent','Start','startRouting','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','client','redis','defaults','localhost','socket.io-emitter','./mailAccount.socket','register','request','then','info','MailAccount,\x20%s,\x20%s','debug','stringify','error','code','message','result','GetMailAccount','MailAccount','options','raw','attributes','limit','include','model','map','catch','ShowMailAccount','find','where','NotifyMailAccount','mail','rawAttributes','createdAt','ListId','body','isNil','from','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','account','CmList','CmContact','Contacts','updatedAt','DESC','MailApplication','Smtp','List','get','omit','list','orderBy','applications','priority','autoclose','push','length','close','*,*,*,*'];(function(_0x2a0183,_0x3fc93c){var _0x158c3a=function(_0x57a903){while(--_0x57a903){_0x2a0183['push'](_0x2a0183['shift']());}};_0x158c3a(++_0x3fc93c);}(_0x88f0,0x1c1));var _0x088f=function(_0x290b74,_0x4186b7){_0x290b74=_0x290b74-0x0;var _0x2cd1b0=_0x88f0[_0x290b74];return _0x2cd1b0;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x088f('0x0'));var BPromise=require(_0x088f('0x1'));var rs=require(_0x088f('0x2'));var fs=require('fs');var Redis=require(_0x088f('0x3'));var db=require(_0x088f('0x4'))['db'];var utils=require(_0x088f('0x5'));var logger=require('../../config/logger')(_0x088f('0x6'));var config=require(_0x088f('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x088f('0x8')]['http']({'port':0x232c});config[_0x088f('0x9')]=_[_0x088f('0xa')](config['redis'],{'host':_0x088f('0xb'),'port':0x18eb});var socket=require(_0x088f('0xc'))(new Redis(config[_0x088f('0x9')]));require(_0x088f('0xd'))[_0x088f('0xe')](socket);function respondWithRpcPromise(_0x182a19,_0x20d3e1,_0x5d1333){return new BPromise(function(_0xdf810a,_0x252825){return client[_0x088f('0xf')](_0x182a19,_0x5d1333)[_0x088f('0x10')](function(_0x5d7135){logger[_0x088f('0x11')](_0x088f('0x12'),_0x20d3e1,'request\x20sent');logger[_0x088f('0x13')]('MailAccount,\x20%s,\x20%s,\x20%s',_0x20d3e1,'request\x20sent',JSON[_0x088f('0x14')](_0x5d7135));if(_0x5d7135[_0x088f('0x15')]){if(_0x5d7135[_0x088f('0x15')][_0x088f('0x16')]===0x1f4){logger['error'](_0x088f('0x12'),_0x20d3e1,_0x5d7135[_0x088f('0x15')][_0x088f('0x17')]);return _0x252825(_0x5d7135['error']['message']);}logger[_0x088f('0x15')](_0x088f('0x12'),_0x20d3e1,_0x5d7135[_0x088f('0x15')][_0x088f('0x17')]);return _0xdf810a(_0x5d7135[_0x088f('0x15')][_0x088f('0x17')]);}else{logger[_0x088f('0x11')](_0x088f('0x12'),_0x20d3e1,'request\x20sent');_0xdf810a(_0x5d7135[_0x088f('0x18')][_0x088f('0x17')]);}})['catch'](function(_0x2f7f74){logger[_0x088f('0x15')](_0x088f('0x12'),_0x20d3e1,_0x2f7f74);_0x252825(_0x2f7f74);});});}exports[_0x088f('0x19')]=function(_0x29d2a2){var _0x3ff5a0=this;return new Promise(function(_0x4f508e,_0x2d1982){return db[_0x088f('0x1a')]['findAll']({'raw':_0x29d2a2[_0x088f('0x1b')]?_0x29d2a2[_0x088f('0x1b')][_0x088f('0x1c')]===undefined?!![]:![]:!![],'where':_0x29d2a2['options']?_0x29d2a2['options']['where']||null:null,'attributes':_0x29d2a2[_0x088f('0x1b')]?_0x29d2a2[_0x088f('0x1b')][_0x088f('0x1d')]||null:null,'limit':_0x29d2a2['options']?_0x29d2a2[_0x088f('0x1b')][_0x088f('0x1e')]||null:null,'include':_0x29d2a2[_0x088f('0x1b')]?_0x29d2a2['options'][_0x088f('0x1f')]?_['map'](_0x29d2a2['options'][_0x088f('0x1f')],function(_0x103537){return{'model':db[_0x103537[_0x088f('0x20')]],'as':_0x103537['as'],'attributes':_0x103537['attributes'],'include':_0x103537[_0x088f('0x1f')]?_['map'](_0x103537[_0x088f('0x1f')],function(_0x58cd8a){return{'model':db[_0x58cd8a[_0x088f('0x20')]],'as':_0x58cd8a['as'],'attributes':_0x58cd8a[_0x088f('0x1d')],'include':_0x58cd8a['include']?_[_0x088f('0x21')](_0x58cd8a[_0x088f('0x1f')],function(_0x37e2b6){return{'model':db[_0x37e2b6['model']],'as':_0x37e2b6['as'],'attributes':_0x37e2b6[_0x088f('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x088f('0x10')](function(_0xfebcf7){logger[_0x088f('0x11')](_0x088f('0x19'),_0x29d2a2);logger[_0x088f('0x13')](_0x088f('0x19'),_0x29d2a2,JSON[_0x088f('0x14')](_0xfebcf7));_0x4f508e(_0xfebcf7);})[_0x088f('0x22')](function(_0x1e7a9a){logger[_0x088f('0x15')](_0x088f('0x19'),_0x1e7a9a[_0x088f('0x17')],_0x29d2a2);_0x2d1982(_0x3ff5a0['error'](0x1f4,_0x1e7a9a[_0x088f('0x17')]));});});};exports[_0x088f('0x23')]=function(_0xeb2f3){var _0x387af4=this;return new Promise(function(_0x269c48,_0x33146e){return db['MailAccount'][_0x088f('0x24')]({'raw':_0xeb2f3['options']?_0xeb2f3['options'][_0x088f('0x1c')]===undefined?!![]:![]:!![],'where':_0xeb2f3['options']?_0xeb2f3[_0x088f('0x1b')][_0x088f('0x25')]||null:null,'attributes':_0xeb2f3[_0x088f('0x1b')]?_0xeb2f3[_0x088f('0x1b')]['attributes']||null:null,'include':_0xeb2f3[_0x088f('0x1b')]?_0xeb2f3[_0x088f('0x1b')][_0x088f('0x1f')]?_['map'](_0xeb2f3[_0x088f('0x1b')][_0x088f('0x1f')],function(_0x420361){return{'model':db[_0x420361[_0x088f('0x20')]],'as':_0x420361['as'],'attributes':_0x420361[_0x088f('0x1d')],'include':_0x420361[_0x088f('0x1f')]?_[_0x088f('0x21')](_0x420361[_0x088f('0x1f')],function(_0x13564e){return{'model':db[_0x13564e[_0x088f('0x20')]],'as':_0x13564e['as'],'attributes':_0x13564e['attributes'],'include':_0x13564e['include']?_[_0x088f('0x21')](_0x13564e['include'],function(_0x32a2d7){return{'model':db[_0x32a2d7[_0x088f('0x20')]],'as':_0x32a2d7['as'],'attributes':_0x32a2d7[_0x088f('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x088f('0x10')](function(_0x2cb773){logger[_0x088f('0x11')](_0x088f('0x23'),_0xeb2f3);logger[_0x088f('0x13')](_0x088f('0x23'),_0xeb2f3,JSON[_0x088f('0x14')](_0x2cb773));_0x269c48(_0x2cb773);})[_0x088f('0x22')](function(_0x5499c7){logger[_0x088f('0x15')](_0x088f('0x23'),_0x5499c7[_0x088f('0x17')],_0xeb2f3);_0x33146e(_0x387af4['error'](0x1f4,_0x5499c7[_0x088f('0x17')]));});});};exports[_0x088f('0x26')]=function(_0x2cd620){var _0x493398=this;return new Promise(function(_0x163c38,_0x424dd0){var _0x379d83={'body':_0x2cd620['body'],'channel':_0x088f('0x27')};var _0x510410=_['difference'](_['keys'](db['CmContact'][_0x088f('0x28')]),[_0x088f('0x29'),'updatedAt','CompanyId',_0x088f('0x2a')]);var _0x23be2f=![];if(_0x2cd620[_0x088f('0x2b')]['id']){delete _0x2cd620[_0x088f('0x2b')]['id'];}if(_[_0x088f('0x2c')](_0x2cd620[_0x088f('0x2b')][_0x088f('0x2d')])){return _0x424dd0(_0x493398[_0x088f('0x15')](0x1f4,'from\x20is\x20mandatory'));}if(_[_0x088f('0x2c')](_0x2cd620[_0x088f('0x2b')][_0x088f('0x2b')])||_0x2cd620[_0x088f('0x2b')]['body']===''){return _0x424dd0(_0x493398[_0x088f('0x15')](0x1f4,_0x088f('0x2e')));}if(_['isNil'](_0x2cd620[_0x088f('0x2b')][_0x088f('0x2f')])){return _0x424dd0(_0x493398[_0x088f('0x15')](0x1f4,_0x088f('0x30')+_0x510410));}if(!_[_0x088f('0x31')](_0x510410,_0x2cd620['body']['mapKey'])){return _0x424dd0(_0x493398[_0x088f('0x15')](0x1f4,_0x088f('0x32')+_0x510410));}var _0xa52280={};_0xa52280[_0x2cd620['body'][_0x088f('0x2f')]]=_0x2cd620[_0x088f('0x2b')][_0x088f('0x2d')];return db[_0x088f('0x1a')][_0x088f('0x24')]({'where':{'id':_0x2cd620[_0x088f('0x33')]['id']},'include':[{'model':db[_0x088f('0x34')],'as':'List','include':[{'model':db[_0x088f('0x35')],'as':_0x088f('0x36'),'where':_0xa52280,'limit':0x1,'order':[[_0x088f('0x37'),_0x088f('0x38')]]}]},{'model':db[_0x088f('0x39')],'as':'Applications'},{'model':db['MailServerOut'],'as':_0x088f('0x3a')}]})[_0x088f('0x10')](function(_0x31a107){if(_0x31a107&&_0x31a107[_0x088f('0x3b')]){var _0xddf1de=_0x31a107[_0x088f('0x3c')]({'plain':!![]});_0x379d83[_0x088f('0x33')]=_[_0x088f('0x3d')](_0xddf1de,['Applications',_0x088f('0x3b')]);_0x379d83['applications']=_0xddf1de['Applications'];_0x379d83[_0x088f('0x3e')]=_0xddf1de[_0x088f('0x3b')];_0x379d83['applications']=_[_0x088f('0x3f')](_0x379d83[_0x088f('0x40')],[_0x088f('0x41')],['asc']);if(_0x379d83['account']&&_0x379d83[_0x088f('0x33')][_0x088f('0x42')]){_0x379d83['applications'][_0x088f('0x43')]({'id':0x0,'priority':_0x379d83[_0x088f('0x40')][_0x088f('0x44')]+0x1,'app':_0x088f('0x45'),'appdata':_0x088f('0x42'),'interval':_0x088f('0x46')});}if(_0x379d83[_0x088f('0x33')][_0x088f('0x47')]){delete _0x379d83[_0x088f('0x33')][_0x088f('0x47')];}if(_0x379d83[_0x088f('0x33')][_0x088f('0x3b')]){delete _0x379d83['account'][_0x088f('0x3b')];}if(_0xddf1de[_0x088f('0x3b')]['Contacts'][_0x088f('0x44')]){return _0xddf1de[_0x088f('0x3b')][_0x088f('0x36')][0x0];}var _0x31345b=_['defaults'](_0x2cd620[_0x088f('0x2b')],{'firstName':_0x2cd620[_0x088f('0x2b')][_0x088f('0x2d')],'ListId':_0xddf1de['ListId']});_0x31345b[_0x2cd620[_0x088f('0x2b')]['mapKey']]=_0x2cd620[_0x088f('0x2b')][_0x088f('0x2d')];return db['CmContact']['create'](_0x31345b);}else{throw new Error(_0x088f('0x48'));}})[_0x088f('0x10')](function(_0x4edf7c){_0x379d83[_0x088f('0x49')]=_0x4edf7c;if(_0x4edf7c){if(!_0x2cd620[_0x088f('0x2b')][_0x088f('0x17')][_0x088f('0x4a')]){_0x2cd620[_0x088f('0x2b')][_0x088f('0x17')][_0x088f('0x4a')]=rs[_0x088f('0x4b')]()+'\x20'+_0x2cd620[_0x088f('0x2b')][_0x088f('0x17')][_0x088f('0x2d')];}var _0x2fd232={'ContactId':_0x4edf7c['id'],'MailAccountId':_0x2cd620[_0x088f('0x33')]['id'],'inReplyTo':_0x2cd620['body'][_0x088f('0x17')][_0x088f('0x4a')],'to':_0x2cd620['body'][_0x088f('0x17')][_0x088f('0x2d')],'cc':_0x2cd620[_0x088f('0x2b')][_0x088f('0x17')]['cc'],'subject':_0x2cd620[_0x088f('0x2b')]['message'][_0x088f('0x4c')],'attach':_0x2cd620['body'][_0x088f('0x17')]['attach'],'lastMsgAt':moment()[_0x088f('0x4d')](_0x088f('0x4e')),'lastMsgDirection':'in','lastMsgBody':_0x2cd620[_0x088f('0x2b')][_0x088f('0x2b')]};return db[_0x088f('0x4f')][_0x088f('0x24')]({'where':{'closed':![],'MailAccountId':_0x2cd620[_0x088f('0x33')]['id']},'include':[{'model':db[_0x088f('0x50')],'as':_0x088f('0x51'),'attributes':['messageId'],'where':{'messageId':_0x2cd620[_0x088f('0x2b')]['message'][_0x088f('0x52')]}}]})['then'](function(_0x3e6792){if(_0x3e6792){return[_0x3e6792,![]];}return db[_0x088f('0x4f')]['create'](_0x2fd232)['then'](function(_0x35357d){return[_0x35357d,!![]];});});}else{throw new Error(_0x088f('0x53'));}})[_0x088f('0x54')](function(_0x3d223d,_0x2e4e63){if(_0x3d223d){_0x23be2f=_0x2e4e63;if(!_0x2e4e63){return _0x3d223d[_0x088f('0x55')]({'inReplyTo':_0x2cd620[_0x088f('0x2b')][_0x088f('0x17')][_0x088f('0x4a')],'to':_0x2cd620[_0x088f('0x2b')][_0x088f('0x17')][_0x088f('0x2d')],'cc':_0x2cd620['body'][_0x088f('0x17')]['cc'],'subject':_0x2cd620[_0x088f('0x2b')][_0x088f('0x17')][_0x088f('0x4c')],'attach':_0x3d223d[_0x088f('0x56')]?_0x3d223d[_0x088f('0x56')]:_0x2cd620['body'][_0x088f('0x17')][_0x088f('0x56')],'substatus':null,'substatusAt':moment()[_0x088f('0x4d')](_0x088f('0x4e')),'lastMsgAt':moment()[_0x088f('0x4d')]('YYYY-MM-DD\x20HH:mm:ss'),'lastMsgDirection':'in','lastMsgBody':_0x2cd620[_0x088f('0x2b')][_0x088f('0x2b')]});}else{return _0x3d223d;}}})[_0x088f('0x10')](function(_0x15ffeb){_0x379d83[_0x088f('0x57')]=_0x15ffeb[_0x088f('0x3c')]({'plain':!![]});_0x379d83[_0x088f('0x57')][_0x088f('0x58')]=_0x23be2f;return db[_0x088f('0x50')][_0x088f('0x59')]({'body':_0x2cd620[_0x088f('0x2b')]['body'],'MailAccountId':_0x2cd620[_0x088f('0x33')]['id'],'MailInteractionId':_0x15ffeb['id'],'direction':'in','ContactId':_0x379d83[_0x088f('0x49')]['id'],'messageId':_0x2cd620[_0x088f('0x2b')][_0x088f('0x17')]['messageId'],'from':_0x2cd620[_0x088f('0x2b')][_0x088f('0x17')]['from'],'to':_0x2cd620['body'][_0x088f('0x17')]['to'],'cc':_0x2cd620[_0x088f('0x2b')][_0x088f('0x17')]['cc'],'subject':_0x2cd620[_0x088f('0x2b')]['message'][_0x088f('0x4c')],'attach':_0x2cd620['body'][_0x088f('0x17')]['attach'],'Attachments':_0x2cd620[_0x088f('0x2b')][_0x088f('0x17')][_0x088f('0x5a')],'originTo':_0x2cd620[_0x088f('0x2b')][_0x088f('0x17')][_0x088f('0x5b')],'originCc':_0x2cd620[_0x088f('0x2b')][_0x088f('0x17')][_0x088f('0x5c')],'bcc':_0x2cd620['body'][_0x088f('0x17')][_0x088f('0x5d')]},{'include':[{'model':db[_0x088f('0x5e')],'as':_0x088f('0x5f')}]});})[_0x088f('0x10')](function(_0x2d1e26){_0x379d83['message']=_0x2d1e26;if(_0x379d83[_0x088f('0x57')]['UserId']){return db[_0x088f('0x60')][_0x088f('0x24')]({'attributes':['id',_0x088f('0x61')],'where':{'id':_0x379d83[_0x088f('0x57')][_0x088f('0x62')]}})[_0x088f('0x10')](function(_0x37997d){if(_0x37997d){_0x379d83[_0x088f('0x40')][_0x088f('0x63')]({'id':0x0,'priority':0x0,'app':_0x088f('0x64'),'appdata':_0x37997d['name']+','+(_0x379d83[_0x088f('0x33')][_0x088f('0x65')]||0xa),'interval':'*,*,*,*'});}return respondWithRpcPromise(_0x088f('0x66'),_0x088f('0x67'),_0x379d83);});}return respondWithRpcPromise(_0x088f('0x66'),_0x088f('0x67'),_0x379d83);})[_0x088f('0x10')](function(_0x59fba4){_0x163c38(_0x59fba4);})[_0x088f('0x22')](function(_0x3506de){_0x424dd0(_0x493398[_0x088f('0x15')](0x1f4,_0x3506de[_0x088f('0x17')]));});});};
\ No newline at end of file
+var _0xa8e8=['waitForTheAssignedAgent','startRouting','Start','lodash','util','moment','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','client','redis','defaults','localhost','socket.io-emitter','./mailAccount.socket','request','then','info','MailAccount,\x20%s,\x20%s','request\x20sent','debug','MailAccount,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','GetMailAccount','MailAccount','findAll','options','raw','attributes','limit','map','include','model','stringify','ShowMailAccount','find','NotifyMailAccount','body','difference','keys','rawAttributes','createdAt','updatedAt','ListId','isNil','from','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','account','CmList','List','CmContact','Contacts','DESC','MailApplication','Applications','MailServerOut','Smtp','omit','applications','list','orderBy','priority','autoclose','length','*,*,*,*','create','contact','messageId','subject','format','YYYY-MM-DD\x20HH:mm:ss','MailInteraction','MailMessage','Messages','inReplyTo','Contact\x20not\x20found','spread','update','attach','interaction','get','created','attachments','originTo','originCc','bcc','Attachment','Attachments','UserId','User','agent','name'];(function(_0x9bfc6c,_0x159ef2){var _0x1f8376=function(_0x475856){while(--_0x475856){_0x9bfc6c['push'](_0x9bfc6c['shift']());}};_0x1f8376(++_0x159ef2);}(_0xa8e8,0x138));var _0x8a8e=function(_0x1d603a,_0x2b814e){_0x1d603a=_0x1d603a-0x0;var _0x4b76b4=_0xa8e8[_0x1d603a];return _0x4b76b4;};'use strict';var _=require(_0x8a8e('0x0'));var util=require(_0x8a8e('0x1'));var moment=require(_0x8a8e('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x8a8e('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x8a8e('0x4'));var logger=require(_0x8a8e('0x5'))(_0x8a8e('0x6'));var config=require(_0x8a8e('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x8a8e('0x8')]['http']({'port':0x232c});config[_0x8a8e('0x9')]=_[_0x8a8e('0xa')](config[_0x8a8e('0x9')],{'host':_0x8a8e('0xb'),'port':0x18eb});var socket=require(_0x8a8e('0xc'))(new Redis(config[_0x8a8e('0x9')]));require(_0x8a8e('0xd'))['register'](socket);function respondWithRpcPromise(_0x5de672,_0xfa6782,_0x50c1f8){return new BPromise(function(_0x41c9d5,_0x21e864){return client[_0x8a8e('0xe')](_0x5de672,_0x50c1f8)[_0x8a8e('0xf')](function(_0x5cffac){logger[_0x8a8e('0x10')](_0x8a8e('0x11'),_0xfa6782,_0x8a8e('0x12'));logger[_0x8a8e('0x13')](_0x8a8e('0x14'),_0xfa6782,_0x8a8e('0x12'),JSON['stringify'](_0x5cffac));if(_0x5cffac[_0x8a8e('0x15')]){if(_0x5cffac[_0x8a8e('0x15')][_0x8a8e('0x16')]===0x1f4){logger[_0x8a8e('0x15')]('MailAccount,\x20%s,\x20%s',_0xfa6782,_0x5cffac[_0x8a8e('0x15')]['message']);return _0x21e864(_0x5cffac['error'][_0x8a8e('0x17')]);}logger[_0x8a8e('0x15')](_0x8a8e('0x11'),_0xfa6782,_0x5cffac['error'][_0x8a8e('0x17')]);return _0x41c9d5(_0x5cffac['error']['message']);}else{logger[_0x8a8e('0x10')]('MailAccount,\x20%s,\x20%s',_0xfa6782,'request\x20sent');_0x41c9d5(_0x5cffac[_0x8a8e('0x18')][_0x8a8e('0x17')]);}})[_0x8a8e('0x19')](function(_0x2a8652){logger[_0x8a8e('0x15')]('MailAccount,\x20%s,\x20%s',_0xfa6782,_0x2a8652);_0x21e864(_0x2a8652);});});}exports[_0x8a8e('0x1a')]=function(_0x200570){var _0x440cc3=this;return new Promise(function(_0x19f80f,_0x1b147f){return db[_0x8a8e('0x1b')][_0x8a8e('0x1c')]({'raw':_0x200570[_0x8a8e('0x1d')]?_0x200570[_0x8a8e('0x1d')][_0x8a8e('0x1e')]===undefined?!![]:![]:!![],'where':_0x200570[_0x8a8e('0x1d')]?_0x200570[_0x8a8e('0x1d')]['where']||null:null,'attributes':_0x200570[_0x8a8e('0x1d')]?_0x200570['options'][_0x8a8e('0x1f')]||null:null,'limit':_0x200570['options']?_0x200570[_0x8a8e('0x1d')][_0x8a8e('0x20')]||null:null,'include':_0x200570['options']?_0x200570[_0x8a8e('0x1d')]['include']?_[_0x8a8e('0x21')](_0x200570[_0x8a8e('0x1d')][_0x8a8e('0x22')],function(_0x31839d){return{'model':db[_0x31839d[_0x8a8e('0x23')]],'as':_0x31839d['as'],'attributes':_0x31839d['attributes'],'include':_0x31839d[_0x8a8e('0x22')]?_['map'](_0x31839d[_0x8a8e('0x22')],function(_0x383c36){return{'model':db[_0x383c36[_0x8a8e('0x23')]],'as':_0x383c36['as'],'attributes':_0x383c36[_0x8a8e('0x1f')],'include':_0x383c36[_0x8a8e('0x22')]?_[_0x8a8e('0x21')](_0x383c36['include'],function(_0x326bbf){return{'model':db[_0x326bbf[_0x8a8e('0x23')]],'as':_0x326bbf['as'],'attributes':_0x326bbf[_0x8a8e('0x1f')]};}):[]};}):[]};}):[]:[]})[_0x8a8e('0xf')](function(_0x5f22d2){logger[_0x8a8e('0x10')](_0x8a8e('0x1a'),_0x200570);logger[_0x8a8e('0x13')](_0x8a8e('0x1a'),_0x200570,JSON[_0x8a8e('0x24')](_0x5f22d2));_0x19f80f(_0x5f22d2);})[_0x8a8e('0x19')](function(_0x3c8ea7){logger[_0x8a8e('0x15')](_0x8a8e('0x1a'),_0x3c8ea7['message'],_0x200570);_0x1b147f(_0x440cc3[_0x8a8e('0x15')](0x1f4,_0x3c8ea7[_0x8a8e('0x17')]));});});};exports[_0x8a8e('0x25')]=function(_0x11aa52){var _0x28bea8=this;return new Promise(function(_0x465b73,_0x5129a7){return db[_0x8a8e('0x1b')][_0x8a8e('0x26')]({'raw':_0x11aa52[_0x8a8e('0x1d')]?_0x11aa52[_0x8a8e('0x1d')][_0x8a8e('0x1e')]===undefined?!![]:![]:!![],'where':_0x11aa52['options']?_0x11aa52[_0x8a8e('0x1d')]['where']||null:null,'attributes':_0x11aa52[_0x8a8e('0x1d')]?_0x11aa52[_0x8a8e('0x1d')]['attributes']||null:null,'include':_0x11aa52[_0x8a8e('0x1d')]?_0x11aa52['options'][_0x8a8e('0x22')]?_['map'](_0x11aa52['options']['include'],function(_0x15e80e){return{'model':db[_0x15e80e[_0x8a8e('0x23')]],'as':_0x15e80e['as'],'attributes':_0x15e80e[_0x8a8e('0x1f')],'include':_0x15e80e[_0x8a8e('0x22')]?_['map'](_0x15e80e[_0x8a8e('0x22')],function(_0x1c2163){return{'model':db[_0x1c2163[_0x8a8e('0x23')]],'as':_0x1c2163['as'],'attributes':_0x1c2163[_0x8a8e('0x1f')],'include':_0x1c2163[_0x8a8e('0x22')]?_[_0x8a8e('0x21')](_0x1c2163[_0x8a8e('0x22')],function(_0x11de4b){return{'model':db[_0x11de4b[_0x8a8e('0x23')]],'as':_0x11de4b['as'],'attributes':_0x11de4b[_0x8a8e('0x1f')]};}):[]};}):[]};}):[]:[]})[_0x8a8e('0xf')](function(_0x26c947){logger['info']('ShowMailAccount',_0x11aa52);logger[_0x8a8e('0x13')]('ShowMailAccount',_0x11aa52,JSON[_0x8a8e('0x24')](_0x26c947));_0x465b73(_0x26c947);})['catch'](function(_0x47ca1f){logger['error'](_0x8a8e('0x25'),_0x47ca1f[_0x8a8e('0x17')],_0x11aa52);_0x5129a7(_0x28bea8[_0x8a8e('0x15')](0x1f4,_0x47ca1f['message']));});});};exports[_0x8a8e('0x27')]=function(_0x50ce51){var _0x1ed8a3=this;return new Promise(function(_0x3a9645,_0x112840){var _0x4e0874={'body':_0x50ce51[_0x8a8e('0x28')],'channel':'mail'};var _0x5f08cc=_[_0x8a8e('0x29')](_[_0x8a8e('0x2a')](db['CmContact'][_0x8a8e('0x2b')]),[_0x8a8e('0x2c'),_0x8a8e('0x2d'),'CompanyId',_0x8a8e('0x2e')]);var _0x18c40f=![];if(_0x50ce51[_0x8a8e('0x28')]['id']){delete _0x50ce51[_0x8a8e('0x28')]['id'];}if(_[_0x8a8e('0x2f')](_0x50ce51[_0x8a8e('0x28')][_0x8a8e('0x30')])){return _0x112840(_0x1ed8a3['error'](0x1f4,_0x8a8e('0x31')));}if(_[_0x8a8e('0x2f')](_0x50ce51[_0x8a8e('0x28')][_0x8a8e('0x28')])||_0x50ce51['body'][_0x8a8e('0x28')]===''){return _0x112840(_0x1ed8a3['error'](0x1f4,_0x8a8e('0x32')));}if(_[_0x8a8e('0x2f')](_0x50ce51[_0x8a8e('0x28')][_0x8a8e('0x33')])){return _0x112840(_0x1ed8a3[_0x8a8e('0x15')](0x1f4,_0x8a8e('0x34')+_0x5f08cc));}if(!_[_0x8a8e('0x35')](_0x5f08cc,_0x50ce51[_0x8a8e('0x28')][_0x8a8e('0x33')])){return _0x112840(_0x1ed8a3[_0x8a8e('0x15')](0x1f4,_0x8a8e('0x36')+_0x5f08cc));}var _0x16d48f={};_0x16d48f[_0x50ce51[_0x8a8e('0x28')]['mapKey']]=_0x50ce51[_0x8a8e('0x28')][_0x8a8e('0x30')];return db[_0x8a8e('0x1b')][_0x8a8e('0x26')]({'where':{'id':_0x50ce51[_0x8a8e('0x37')]['id']},'include':[{'model':db[_0x8a8e('0x38')],'as':_0x8a8e('0x39'),'include':[{'model':db[_0x8a8e('0x3a')],'as':_0x8a8e('0x3b'),'where':_0x16d48f,'limit':0x1,'order':[['updatedAt',_0x8a8e('0x3c')]]}]},{'model':db[_0x8a8e('0x3d')],'as':_0x8a8e('0x3e')},{'model':db[_0x8a8e('0x3f')],'as':_0x8a8e('0x40')}]})[_0x8a8e('0xf')](function(_0x46a400){if(_0x46a400&&_0x46a400[_0x8a8e('0x39')]){var _0x13183a=_0x46a400['get']({'plain':!![]});_0x4e0874['account']=_[_0x8a8e('0x41')](_0x13183a,[_0x8a8e('0x3e'),'List']);_0x4e0874[_0x8a8e('0x42')]=_0x13183a[_0x8a8e('0x3e')];_0x4e0874[_0x8a8e('0x43')]=_0x13183a[_0x8a8e('0x39')];_0x4e0874['applications']=_[_0x8a8e('0x44')](_0x4e0874[_0x8a8e('0x42')],[_0x8a8e('0x45')],['asc']);if(_0x4e0874[_0x8a8e('0x37')]&&_0x4e0874[_0x8a8e('0x37')][_0x8a8e('0x46')]){_0x4e0874[_0x8a8e('0x42')]['push']({'id':0x0,'priority':_0x4e0874[_0x8a8e('0x42')][_0x8a8e('0x47')]+0x1,'app':'close','appdata':'autoclose','interval':_0x8a8e('0x48')});}if(_0x4e0874['account']['Applications']){delete _0x4e0874[_0x8a8e('0x37')][_0x8a8e('0x3e')];}if(_0x4e0874[_0x8a8e('0x37')]['List']){delete _0x4e0874[_0x8a8e('0x37')]['List'];}if(_0x13183a['List'][_0x8a8e('0x3b')]['length']){return _0x13183a[_0x8a8e('0x39')]['Contacts'][0x0];}var _0xebdbf0=_[_0x8a8e('0xa')](_0x50ce51[_0x8a8e('0x28')],{'firstName':_0x50ce51['body']['from'],'ListId':_0x13183a[_0x8a8e('0x2e')]});_0xebdbf0[_0x50ce51[_0x8a8e('0x28')][_0x8a8e('0x33')]]=_0x50ce51[_0x8a8e('0x28')]['from'];return db[_0x8a8e('0x3a')][_0x8a8e('0x49')](_0xebdbf0);}else{throw new Error('List\x20not\x20found');}})[_0x8a8e('0xf')](function(_0x312dba){_0x4e0874[_0x8a8e('0x4a')]=_0x312dba;if(_0x312dba){if(!_0x50ce51['body'][_0x8a8e('0x17')]['messageId']){_0x50ce51[_0x8a8e('0x28')][_0x8a8e('0x17')][_0x8a8e('0x4b')]=rs['generate']()+'\x20'+_0x50ce51[_0x8a8e('0x28')][_0x8a8e('0x17')][_0x8a8e('0x30')];}var _0x4096b4={'ContactId':_0x312dba['id'],'MailAccountId':_0x50ce51['account']['id'],'inReplyTo':_0x50ce51[_0x8a8e('0x28')][_0x8a8e('0x17')][_0x8a8e('0x4b')],'to':_0x50ce51[_0x8a8e('0x28')][_0x8a8e('0x17')][_0x8a8e('0x30')],'cc':_0x50ce51[_0x8a8e('0x28')][_0x8a8e('0x17')]['cc'],'subject':_0x50ce51['body'][_0x8a8e('0x17')][_0x8a8e('0x4c')],'attach':_0x50ce51[_0x8a8e('0x28')][_0x8a8e('0x17')]['attach'],'lastMsgAt':moment()[_0x8a8e('0x4d')](_0x8a8e('0x4e')),'lastMsgDirection':'in','lastMsgBody':_0x50ce51[_0x8a8e('0x28')][_0x8a8e('0x28')]};return db[_0x8a8e('0x4f')]['find']({'where':{'closed':![],'MailAccountId':_0x50ce51[_0x8a8e('0x37')]['id']},'include':[{'model':db[_0x8a8e('0x50')],'as':_0x8a8e('0x51'),'attributes':['messageId'],'where':{'messageId':_0x50ce51[_0x8a8e('0x28')][_0x8a8e('0x17')][_0x8a8e('0x52')]}}]})[_0x8a8e('0xf')](function(_0x5d683e){if(_0x5d683e){return[_0x5d683e,![]];}return db['MailInteraction'][_0x8a8e('0x49')](_0x4096b4)[_0x8a8e('0xf')](function(_0x11ea8f){return[_0x11ea8f,!![]];});});}else{throw new Error(_0x8a8e('0x53'));}})[_0x8a8e('0x54')](function(_0x46f383,_0x4468a6){if(_0x46f383){_0x18c40f=_0x4468a6;if(!_0x4468a6){return _0x46f383[_0x8a8e('0x55')]({'inReplyTo':_0x50ce51[_0x8a8e('0x28')]['message'][_0x8a8e('0x4b')],'to':_0x50ce51[_0x8a8e('0x28')][_0x8a8e('0x17')][_0x8a8e('0x30')],'cc':_0x50ce51[_0x8a8e('0x28')][_0x8a8e('0x17')]['cc'],'subject':_0x50ce51['body'][_0x8a8e('0x17')]['subject'],'attach':_0x46f383['attach']?_0x46f383[_0x8a8e('0x56')]:_0x50ce51[_0x8a8e('0x28')][_0x8a8e('0x17')]['attach'],'substatus':null,'substatusAt':moment()['format'](_0x8a8e('0x4e')),'lastMsgAt':moment()['format'](_0x8a8e('0x4e')),'lastMsgDirection':'in','lastMsgBody':_0x50ce51[_0x8a8e('0x28')][_0x8a8e('0x28')]});}else{return _0x46f383;}}})[_0x8a8e('0xf')](function(_0x1a58c6){_0x4e0874[_0x8a8e('0x57')]=_0x1a58c6[_0x8a8e('0x58')]({'plain':!![]});_0x4e0874[_0x8a8e('0x57')][_0x8a8e('0x59')]=_0x18c40f;return db[_0x8a8e('0x50')][_0x8a8e('0x49')]({'body':_0x50ce51['body'][_0x8a8e('0x28')],'MailAccountId':_0x50ce51[_0x8a8e('0x37')]['id'],'MailInteractionId':_0x1a58c6['id'],'direction':'in','ContactId':_0x4e0874[_0x8a8e('0x4a')]['id'],'messageId':_0x50ce51[_0x8a8e('0x28')][_0x8a8e('0x17')][_0x8a8e('0x4b')],'from':_0x50ce51[_0x8a8e('0x28')][_0x8a8e('0x17')][_0x8a8e('0x30')],'to':_0x50ce51[_0x8a8e('0x28')][_0x8a8e('0x17')]['to'],'cc':_0x50ce51['body'][_0x8a8e('0x17')]['cc'],'subject':_0x50ce51['body'][_0x8a8e('0x17')]['subject'],'attach':_0x50ce51['body'][_0x8a8e('0x17')][_0x8a8e('0x56')],'Attachments':_0x50ce51[_0x8a8e('0x28')][_0x8a8e('0x17')][_0x8a8e('0x5a')],'originTo':_0x50ce51[_0x8a8e('0x28')][_0x8a8e('0x17')][_0x8a8e('0x5b')],'originCc':_0x50ce51[_0x8a8e('0x28')][_0x8a8e('0x17')][_0x8a8e('0x5c')],'bcc':_0x50ce51[_0x8a8e('0x28')][_0x8a8e('0x17')][_0x8a8e('0x5d')]},{'include':[{'model':db[_0x8a8e('0x5e')],'as':_0x8a8e('0x5f')}]});})['then'](function(_0x5a791a){_0x4e0874[_0x8a8e('0x17')]=_0x5a791a;if(_0x4e0874[_0x8a8e('0x57')][_0x8a8e('0x60')]){return db[_0x8a8e('0x61')]['find']({'attributes':['id','name'],'where':{'id':_0x4e0874[_0x8a8e('0x57')][_0x8a8e('0x60')]}})[_0x8a8e('0xf')](function(_0x4b4b63){if(_0x4b4b63){_0x4e0874[_0x8a8e('0x42')]['unshift']({'id':0x0,'priority':0x0,'app':_0x8a8e('0x62'),'appdata':_0x4b4b63[_0x8a8e('0x63')]+','+(_0x4e0874['account'][_0x8a8e('0x64')]||0xa),'interval':'*,*,*,*'});}return respondWithRpcPromise('Start',_0x8a8e('0x65'),_0x4e0874);});}return respondWithRpcPromise(_0x8a8e('0x66'),_0x8a8e('0x65'),_0x4e0874);})[_0x8a8e('0xf')](function(_0x2d08f8){_0x3a9645(_0x2d08f8);})[_0x8a8e('0x19')](function(_0x1d5e9f){_0x112840(_0x1ed8a3[_0x8a8e('0x15')](0x1f4,_0x1d5e9f['message']));});});};
\ No newline at end of file