Built motion from commit (unavailable).|2.4.3
[motion2.git] / server / api / mailAccount / mailAccount.rpc.js
index 61a22f7..cf6fb2f 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xc70c=['MailInteraction','MailMessage','inReplyTo','Contact\x20not\x20found','spread','update','interaction','originTo','bcc','Attachments','UserId','User','name','unshift','agent','waitForTheAssignedAgent','Start','startRouting','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','register','request','then','info','request\x20sent','debug','MailAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','MailAccount,\x20%s,\x20%s','result','catch','GetMailAccount','MailAccount','findAll','options','raw','attributes','include','model','map','ShowMailAccount','find','where','NotifyMailAccount','body','difference','keys','rawAttributes','updatedAt','CompanyId','ListId','isNil','from','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','account','CmList','CmContact','Contacts','DESC','MailApplication','MailServerOut','Smtp','get','omit','Applications','applications','List','orderBy','asc','autoclose','push','length','*,*,*,*','create','List\x20not\x20found','contact','messageId','generate','subject','attach','format','YYYY-MM-DD\x20HH:mm:ss'];(function(_0x20deee,_0x493615){var _0x458387=function(_0x4c2802){while(--_0x4c2802){_0x20deee['push'](_0x20deee['shift']());}};_0x458387(++_0x493615);}(_0xc70c,0x1aa));var _0xcc70=function(_0x321bb2,_0x202794){_0x321bb2=_0x321bb2-0x0;var _0x9c12ed=_0xc70c[_0x321bb2];return _0x9c12ed;};'use strict';var _=require('lodash');var util=require(_0xcc70('0x0'));var moment=require(_0xcc70('0x1'));var BPromise=require(_0xcc70('0x2'));var rs=require(_0xcc70('0x3'));var fs=require('fs');var Redis=require(_0xcc70('0x4'));var db=require(_0xcc70('0x5'))['db'];var utils=require(_0xcc70('0x6'));var logger=require(_0xcc70('0x7'))(_0xcc70('0x8'));var config=require(_0xcc70('0x9'));var jayson=require(_0xcc70('0xa'));var client=jayson[_0xcc70('0xb')][_0xcc70('0xc')]({'port':0x232c});config[_0xcc70('0xd')]=_[_0xcc70('0xe')](config[_0xcc70('0xd')],{'host':_0xcc70('0xf'),'port':0x18eb});var socket=require(_0xcc70('0x10'))(new Redis(config['redis']));require('./mailAccount.socket')[_0xcc70('0x11')](socket);function respondWithRpcPromise(_0x4a9726,_0x4c70d1,_0xfb898f){return new BPromise(function(_0x2184be,_0x952144){return client[_0xcc70('0x12')](_0x4a9726,_0xfb898f)[_0xcc70('0x13')](function(_0x54f988){logger[_0xcc70('0x14')]('MailAccount,\x20%s,\x20%s',_0x4c70d1,_0xcc70('0x15'));logger[_0xcc70('0x16')](_0xcc70('0x17'),_0x4c70d1,_0xcc70('0x15'),JSON[_0xcc70('0x18')](_0x54f988));if(_0x54f988['error']){if(_0x54f988[_0xcc70('0x19')]['code']===0x1f4){logger[_0xcc70('0x19')]('MailAccount,\x20%s,\x20%s',_0x4c70d1,_0x54f988['error'][_0xcc70('0x1a')]);return _0x952144(_0x54f988[_0xcc70('0x19')][_0xcc70('0x1a')]);}logger[_0xcc70('0x19')](_0xcc70('0x1b'),_0x4c70d1,_0x54f988['error'][_0xcc70('0x1a')]);return _0x2184be(_0x54f988[_0xcc70('0x19')][_0xcc70('0x1a')]);}else{logger[_0xcc70('0x14')]('MailAccount,\x20%s,\x20%s',_0x4c70d1,_0xcc70('0x15'));_0x2184be(_0x54f988[_0xcc70('0x1c')]['message']);}})[_0xcc70('0x1d')](function(_0x42ca25){logger[_0xcc70('0x19')]('MailAccount,\x20%s,\x20%s',_0x4c70d1,_0x42ca25);_0x952144(_0x42ca25);});});}exports[_0xcc70('0x1e')]=function(_0x2e0edf){var _0x111224=this;return new Promise(function(_0x221333,_0x428b18){return db[_0xcc70('0x1f')][_0xcc70('0x20')]({'raw':_0x2e0edf[_0xcc70('0x21')]?_0x2e0edf[_0xcc70('0x21')][_0xcc70('0x22')]===undefined?!![]:![]:!![],'where':_0x2e0edf['options']?_0x2e0edf['options']['where']||null:null,'attributes':_0x2e0edf[_0xcc70('0x21')]?_0x2e0edf[_0xcc70('0x21')][_0xcc70('0x23')]||null:null,'limit':_0x2e0edf[_0xcc70('0x21')]?_0x2e0edf[_0xcc70('0x21')]['limit']||null:null,'include':_0x2e0edf[_0xcc70('0x21')]?_0x2e0edf[_0xcc70('0x21')][_0xcc70('0x24')]?_['map'](_0x2e0edf[_0xcc70('0x21')]['include'],function(_0x3a1efc){return{'model':db[_0x3a1efc['model']],'as':_0x3a1efc['as'],'attributes':_0x3a1efc[_0xcc70('0x23')],'include':_0x3a1efc['include']?_['map'](_0x3a1efc[_0xcc70('0x24')],function(_0x3c5b5e){return{'model':db[_0x3c5b5e[_0xcc70('0x25')]],'as':_0x3c5b5e['as'],'attributes':_0x3c5b5e[_0xcc70('0x23')],'include':_0x3c5b5e[_0xcc70('0x24')]?_[_0xcc70('0x26')](_0x3c5b5e[_0xcc70('0x24')],function(_0x465fb6){return{'model':db[_0x465fb6[_0xcc70('0x25')]],'as':_0x465fb6['as'],'attributes':_0x465fb6[_0xcc70('0x23')]};}):[]};}):[]};}):[]:[]})[_0xcc70('0x13')](function(_0x2d5456){logger[_0xcc70('0x14')](_0xcc70('0x1e'),_0x2e0edf);logger[_0xcc70('0x16')]('GetMailAccount',_0x2e0edf,JSON['stringify'](_0x2d5456));_0x221333(_0x2d5456);})[_0xcc70('0x1d')](function(_0x15f09f){logger['error'](_0xcc70('0x1e'),_0x15f09f[_0xcc70('0x1a')],_0x2e0edf);_0x428b18(_0x111224[_0xcc70('0x19')](0x1f4,_0x15f09f['message']));});});};exports[_0xcc70('0x27')]=function(_0x3e4f46){var _0x48efbf=this;return new Promise(function(_0x400084,_0x10727d){return db[_0xcc70('0x1f')][_0xcc70('0x28')]({'raw':_0x3e4f46['options']?_0x3e4f46['options'][_0xcc70('0x22')]===undefined?!![]:![]:!![],'where':_0x3e4f46[_0xcc70('0x21')]?_0x3e4f46['options'][_0xcc70('0x29')]||null:null,'attributes':_0x3e4f46[_0xcc70('0x21')]?_0x3e4f46['options'][_0xcc70('0x23')]||null:null,'include':_0x3e4f46['options']?_0x3e4f46[_0xcc70('0x21')]['include']?_[_0xcc70('0x26')](_0x3e4f46[_0xcc70('0x21')][_0xcc70('0x24')],function(_0x10f2b9){return{'model':db[_0x10f2b9[_0xcc70('0x25')]],'as':_0x10f2b9['as'],'attributes':_0x10f2b9[_0xcc70('0x23')],'include':_0x10f2b9[_0xcc70('0x24')]?_[_0xcc70('0x26')](_0x10f2b9[_0xcc70('0x24')],function(_0x3a5652){return{'model':db[_0x3a5652[_0xcc70('0x25')]],'as':_0x3a5652['as'],'attributes':_0x3a5652[_0xcc70('0x23')],'include':_0x3a5652['include']?_[_0xcc70('0x26')](_0x3a5652[_0xcc70('0x24')],function(_0x24fd28){return{'model':db[_0x24fd28[_0xcc70('0x25')]],'as':_0x24fd28['as'],'attributes':_0x24fd28[_0xcc70('0x23')]};}):[]};}):[]};}):[]:[]})[_0xcc70('0x13')](function(_0x525a7f){logger[_0xcc70('0x14')](_0xcc70('0x27'),_0x3e4f46);logger[_0xcc70('0x16')](_0xcc70('0x27'),_0x3e4f46,JSON[_0xcc70('0x18')](_0x525a7f));_0x400084(_0x525a7f);})[_0xcc70('0x1d')](function(_0x31fa26){logger['error'](_0xcc70('0x27'),_0x31fa26[_0xcc70('0x1a')],_0x3e4f46);_0x10727d(_0x48efbf['error'](0x1f4,_0x31fa26[_0xcc70('0x1a')]));});});};exports[_0xcc70('0x2a')]=function(_0x3cae74){var _0x3a31de=this;return new Promise(function(_0x1f29f3,_0x1eb4a1){var _0x4bd1a6={'body':_0x3cae74[_0xcc70('0x2b')],'channel':'mail'};var _0x5cf1c0=_[_0xcc70('0x2c')](_[_0xcc70('0x2d')](db['CmContact'][_0xcc70('0x2e')]),['createdAt',_0xcc70('0x2f'),_0xcc70('0x30'),_0xcc70('0x31')]);var _0x285ed9=![];if(_0x3cae74[_0xcc70('0x2b')]['id']){delete _0x3cae74[_0xcc70('0x2b')]['id'];}if(_[_0xcc70('0x32')](_0x3cae74[_0xcc70('0x2b')][_0xcc70('0x33')])){return _0x1eb4a1(_0x3a31de['error'](0x1f4,_0xcc70('0x34')));}if(_[_0xcc70('0x32')](_0x3cae74[_0xcc70('0x2b')][_0xcc70('0x2b')])||_0x3cae74[_0xcc70('0x2b')][_0xcc70('0x2b')]===''){return _0x1eb4a1(_0x3a31de[_0xcc70('0x19')](0x1f4,_0xcc70('0x35')));}if(_[_0xcc70('0x32')](_0x3cae74[_0xcc70('0x2b')][_0xcc70('0x36')])){return _0x1eb4a1(_0x3a31de[_0xcc70('0x19')](0x1f4,_0xcc70('0x37')+_0x5cf1c0));}if(!_['includes'](_0x5cf1c0,_0x3cae74['body'][_0xcc70('0x36')])){return _0x1eb4a1(_0x3a31de[_0xcc70('0x19')](0x1f4,'mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x5cf1c0));}var _0x4dedc2={};_0x4dedc2[_0x3cae74[_0xcc70('0x2b')][_0xcc70('0x36')]]=_0x3cae74['body']['from'];return db[_0xcc70('0x1f')]['find']({'where':{'id':_0x3cae74[_0xcc70('0x38')]['id']},'include':[{'model':db[_0xcc70('0x39')],'as':'List','include':[{'model':db[_0xcc70('0x3a')],'as':_0xcc70('0x3b'),'where':_0x4dedc2,'limit':0x1,'order':[[_0xcc70('0x2f'),_0xcc70('0x3c')]]}]},{'model':db[_0xcc70('0x3d')],'as':'Applications'},{'model':db[_0xcc70('0x3e')],'as':_0xcc70('0x3f')}]})[_0xcc70('0x13')](function(_0x3c27ce){if(_0x3c27ce&&_0x3c27ce['List']){var _0x470781=_0x3c27ce[_0xcc70('0x40')]({'plain':!![]});_0x4bd1a6[_0xcc70('0x38')]=_[_0xcc70('0x41')](_0x470781,[_0xcc70('0x42'),'List']);_0x4bd1a6[_0xcc70('0x43')]=_0x470781[_0xcc70('0x42')];_0x4bd1a6['list']=_0x470781[_0xcc70('0x44')];_0x4bd1a6[_0xcc70('0x43')]=_[_0xcc70('0x45')](_0x4bd1a6[_0xcc70('0x43')],['priority'],[_0xcc70('0x46')]);if(_0x4bd1a6[_0xcc70('0x38')]&&_0x4bd1a6[_0xcc70('0x38')][_0xcc70('0x47')]){_0x4bd1a6['applications'][_0xcc70('0x48')]({'id':0x0,'priority':_0x4bd1a6['applications'][_0xcc70('0x49')]+0x1,'app':'close','appdata':_0xcc70('0x47'),'interval':_0xcc70('0x4a')});}if(_0x4bd1a6[_0xcc70('0x38')]['Applications']){delete _0x4bd1a6[_0xcc70('0x38')][_0xcc70('0x42')];}if(_0x4bd1a6[_0xcc70('0x38')][_0xcc70('0x44')]){delete _0x4bd1a6[_0xcc70('0x38')][_0xcc70('0x44')];}if(_0x470781[_0xcc70('0x44')][_0xcc70('0x3b')]['length']){return _0x470781[_0xcc70('0x44')]['Contacts'][0x0];}var _0x573ec2=_['defaults'](_0x3cae74[_0xcc70('0x2b')],{'firstName':_0x3cae74[_0xcc70('0x2b')][_0xcc70('0x33')],'ListId':_0x470781[_0xcc70('0x31')]});_0x573ec2[_0x3cae74[_0xcc70('0x2b')][_0xcc70('0x36')]]=_0x3cae74[_0xcc70('0x2b')]['from'];return db[_0xcc70('0x3a')][_0xcc70('0x4b')](_0x573ec2);}else{throw new Error(_0xcc70('0x4c'));}})['then'](function(_0x2a1a23){_0x4bd1a6[_0xcc70('0x4d')]=_0x2a1a23;if(_0x2a1a23){if(!_0x3cae74[_0xcc70('0x2b')][_0xcc70('0x1a')]['messageId']){_0x3cae74['body'][_0xcc70('0x1a')][_0xcc70('0x4e')]=rs[_0xcc70('0x4f')]()+'\x20'+_0x3cae74[_0xcc70('0x2b')][_0xcc70('0x1a')][_0xcc70('0x33')];}var _0x4d3f80={'ContactId':_0x2a1a23['id'],'MailAccountId':_0x3cae74[_0xcc70('0x38')]['id'],'inReplyTo':_0x3cae74[_0xcc70('0x2b')][_0xcc70('0x1a')][_0xcc70('0x4e')],'to':_0x3cae74[_0xcc70('0x2b')][_0xcc70('0x1a')][_0xcc70('0x33')],'cc':_0x3cae74[_0xcc70('0x2b')][_0xcc70('0x1a')]['cc'],'subject':_0x3cae74[_0xcc70('0x2b')][_0xcc70('0x1a')][_0xcc70('0x50')],'attach':_0x3cae74[_0xcc70('0x2b')]['message'][_0xcc70('0x51')],'lastMsgAt':moment()[_0xcc70('0x52')](_0xcc70('0x53')),'lastMsgDirection':'in','lastMsgBody':_0x3cae74[_0xcc70('0x2b')]['body']};return db[_0xcc70('0x54')][_0xcc70('0x28')]({'where':{'closed':![],'MailAccountId':_0x3cae74[_0xcc70('0x38')]['id']},'include':[{'model':db[_0xcc70('0x55')],'as':'Messages','attributes':['messageId'],'where':{'messageId':_0x3cae74[_0xcc70('0x2b')][_0xcc70('0x1a')][_0xcc70('0x56')]}}]})[_0xcc70('0x13')](function(_0x4f3f8b){if(_0x4f3f8b){return[_0x4f3f8b,![]];}return db[_0xcc70('0x54')][_0xcc70('0x4b')](_0x4d3f80)['then'](function(_0x4e1794){return[_0x4e1794,!![]];});});}else{throw new Error(_0xcc70('0x57'));}})[_0xcc70('0x58')](function(_0x54d3a5,_0x3aaffd){if(_0x54d3a5){_0x285ed9=_0x3aaffd;if(!_0x3aaffd){return _0x54d3a5[_0xcc70('0x59')]({'inReplyTo':_0x3cae74[_0xcc70('0x2b')]['message'][_0xcc70('0x4e')],'to':_0x3cae74[_0xcc70('0x2b')][_0xcc70('0x1a')][_0xcc70('0x33')],'cc':_0x3cae74[_0xcc70('0x2b')][_0xcc70('0x1a')]['cc'],'subject':_0x3cae74['body']['message'][_0xcc70('0x50')],'attach':_0x54d3a5[_0xcc70('0x51')]?_0x54d3a5[_0xcc70('0x51')]:_0x3cae74[_0xcc70('0x2b')]['message'][_0xcc70('0x51')],'substatus':null,'substatusAt':moment()['format'](_0xcc70('0x53')),'lastMsgAt':moment()['format']('YYYY-MM-DD\x20HH:mm:ss'),'lastMsgDirection':'in','lastMsgBody':_0x3cae74[_0xcc70('0x2b')][_0xcc70('0x2b')]});}else{return _0x54d3a5;}}})['then'](function(_0x1a2fde){_0x4bd1a6[_0xcc70('0x5a')]=_0x1a2fde['get']({'plain':!![]});_0x4bd1a6['interaction']['created']=_0x285ed9;return db[_0xcc70('0x55')]['create']({'body':_0x3cae74['body'][_0xcc70('0x2b')],'MailAccountId':_0x3cae74['account']['id'],'MailInteractionId':_0x1a2fde['id'],'direction':'in','ContactId':_0x4bd1a6[_0xcc70('0x4d')]['id'],'messageId':_0x3cae74[_0xcc70('0x2b')]['message'][_0xcc70('0x4e')],'from':_0x3cae74[_0xcc70('0x2b')]['message']['from'],'to':_0x3cae74[_0xcc70('0x2b')][_0xcc70('0x1a')]['to'],'cc':_0x3cae74['body'][_0xcc70('0x1a')]['cc'],'subject':_0x3cae74[_0xcc70('0x2b')]['message']['subject'],'attach':_0x3cae74[_0xcc70('0x2b')][_0xcc70('0x1a')][_0xcc70('0x51')],'Attachments':_0x3cae74['body'][_0xcc70('0x1a')]['attachments'],'originTo':_0x3cae74[_0xcc70('0x2b')]['message'][_0xcc70('0x5b')],'originCc':_0x3cae74[_0xcc70('0x2b')][_0xcc70('0x1a')]['originCc'],'bcc':_0x3cae74[_0xcc70('0x2b')]['message'][_0xcc70('0x5c')]},{'include':[{'model':db['Attachment'],'as':_0xcc70('0x5d')}]});})[_0xcc70('0x13')](function(_0x486e59){_0x4bd1a6[_0xcc70('0x1a')]=_0x486e59;if(_0x4bd1a6[_0xcc70('0x5a')][_0xcc70('0x5e')]){return db[_0xcc70('0x5f')][_0xcc70('0x28')]({'attributes':['id',_0xcc70('0x60')],'where':{'id':_0x4bd1a6[_0xcc70('0x5a')]['UserId']}})[_0xcc70('0x13')](function(_0x35cbf0){if(_0x35cbf0){_0x4bd1a6[_0xcc70('0x43')][_0xcc70('0x61')]({'id':0x0,'priority':0x0,'app':_0xcc70('0x62'),'appdata':_0x35cbf0[_0xcc70('0x60')]+','+(_0x4bd1a6['account'][_0xcc70('0x63')]||0xa),'interval':_0xcc70('0x4a')});}return respondWithRpcPromise(_0xcc70('0x64'),_0xcc70('0x65'),_0x4bd1a6);});}return respondWithRpcPromise(_0xcc70('0x64'),_0xcc70('0x65'),_0x4bd1a6);})['then'](function(_0x18ac3d){_0x1f29f3(_0x18ac3d);})['catch'](function(_0x31cfb8){_0x1eb4a1(_0x3a31de['error'](0x1f4,_0x31cfb8[_0xcc70('0x1a')]));});});};
\ No newline at end of file
+var _0x1867=['Messages','Contact\x20not\x20found','spread','update','subject','create','originTo','originCc','bcc','Attachment','Attachments','interaction','UserId','User','unshift','agent','name','Start','startRouting','lodash','util','moment','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','redis','localhost','socket.io-emitter','./mailAccount.socket','register','request','then','MailAccount,\x20%s,\x20%s','request\x20sent','debug','MailAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','info','result','GetMailAccount','MailAccount','findAll','options','raw','where','attributes','limit','include','map','model','catch','ShowMailAccount','find','NotifyMailAccount','mail','keys','createdAt','updatedAt','CompanyId','ListId','body','isNil','from','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','account','CmList','CmContact','Contacts','DESC','Applications','List','get','omit','applications','orderBy','priority','asc','autoclose','push','length','close','defaults','List\x20not\x20found','messageId','generate','attach','format','YYYY-MM-DD\x20HH:mm:ss','MailInteraction','MailMessage'];(function(_0x8d9381,_0x3fc188){var _0x15ec14=function(_0x3fc6af){while(--_0x3fc6af){_0x8d9381['push'](_0x8d9381['shift']());}};_0x15ec14(++_0x3fc188);}(_0x1867,0x77));var _0x7186=function(_0x4d1b81,_0x31c8a4){_0x4d1b81=_0x4d1b81-0x0;var _0x12a337=_0x1867[_0x4d1b81];return _0x12a337;};'use strict';var _=require(_0x7186('0x0'));var util=require(_0x7186('0x1'));var moment=require(_0x7186('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x7186('0x3'));var db=require(_0x7186('0x4'))['db'];var utils=require(_0x7186('0x5'));var logger=require(_0x7186('0x6'))(_0x7186('0x7'));var config=require('../../config/environment');var jayson=require(_0x7186('0x8'));var client=jayson[_0x7186('0x9')][_0x7186('0xa')]({'port':0x232c});config[_0x7186('0xb')]=_['defaults'](config['redis'],{'host':_0x7186('0xc'),'port':0x18eb});var socket=require(_0x7186('0xd'))(new Redis(config['redis']));require(_0x7186('0xe'))[_0x7186('0xf')](socket);function respondWithRpcPromise(_0x212722,_0xffc348,_0x220c85){return new BPromise(function(_0x51a94d,_0x599a9e){return client[_0x7186('0x10')](_0x212722,_0x220c85)[_0x7186('0x11')](function(_0x51e015){logger['info'](_0x7186('0x12'),_0xffc348,_0x7186('0x13'));logger[_0x7186('0x14')](_0x7186('0x15'),_0xffc348,_0x7186('0x13'),JSON[_0x7186('0x16')](_0x51e015));if(_0x51e015[_0x7186('0x17')]){if(_0x51e015[_0x7186('0x17')]['code']===0x1f4){logger[_0x7186('0x17')](_0x7186('0x12'),_0xffc348,_0x51e015[_0x7186('0x17')][_0x7186('0x18')]);return _0x599a9e(_0x51e015['error'][_0x7186('0x18')]);}logger[_0x7186('0x17')]('MailAccount,\x20%s,\x20%s',_0xffc348,_0x51e015['error'][_0x7186('0x18')]);return _0x51a94d(_0x51e015[_0x7186('0x17')]['message']);}else{logger[_0x7186('0x19')]('MailAccount,\x20%s,\x20%s',_0xffc348,_0x7186('0x13'));_0x51a94d(_0x51e015[_0x7186('0x1a')][_0x7186('0x18')]);}})['catch'](function(_0x2b5601){logger[_0x7186('0x17')]('MailAccount,\x20%s,\x20%s',_0xffc348,_0x2b5601);_0x599a9e(_0x2b5601);});});}exports[_0x7186('0x1b')]=function(_0x563957){var _0x37a515=this;return new Promise(function(_0x5dd4dd,_0x39485c){return db[_0x7186('0x1c')][_0x7186('0x1d')]({'raw':_0x563957[_0x7186('0x1e')]?_0x563957['options'][_0x7186('0x1f')]===undefined?!![]:![]:!![],'where':_0x563957[_0x7186('0x1e')]?_0x563957[_0x7186('0x1e')][_0x7186('0x20')]||null:null,'attributes':_0x563957[_0x7186('0x1e')]?_0x563957['options'][_0x7186('0x21')]||null:null,'limit':_0x563957[_0x7186('0x1e')]?_0x563957['options'][_0x7186('0x22')]||null:null,'include':_0x563957[_0x7186('0x1e')]?_0x563957[_0x7186('0x1e')][_0x7186('0x23')]?_[_0x7186('0x24')](_0x563957[_0x7186('0x1e')][_0x7186('0x23')],function(_0x1f90c5){return{'model':db[_0x1f90c5[_0x7186('0x25')]],'as':_0x1f90c5['as'],'attributes':_0x1f90c5['attributes'],'include':_0x1f90c5[_0x7186('0x23')]?_[_0x7186('0x24')](_0x1f90c5[_0x7186('0x23')],function(_0x1027ab){return{'model':db[_0x1027ab[_0x7186('0x25')]],'as':_0x1027ab['as'],'attributes':_0x1027ab[_0x7186('0x21')],'include':_0x1027ab['include']?_[_0x7186('0x24')](_0x1027ab[_0x7186('0x23')],function(_0xf73e8f){return{'model':db[_0xf73e8f[_0x7186('0x25')]],'as':_0xf73e8f['as'],'attributes':_0xf73e8f[_0x7186('0x21')]};}):[]};}):[]};}):[]:[]})[_0x7186('0x11')](function(_0x22e90f){logger[_0x7186('0x19')](_0x7186('0x1b'),_0x563957);logger['debug'](_0x7186('0x1b'),_0x563957,JSON[_0x7186('0x16')](_0x22e90f));_0x5dd4dd(_0x22e90f);})[_0x7186('0x26')](function(_0x2b8b2c){logger['error']('GetMailAccount',_0x2b8b2c[_0x7186('0x18')],_0x563957);_0x39485c(_0x37a515[_0x7186('0x17')](0x1f4,_0x2b8b2c[_0x7186('0x18')]));});});};exports[_0x7186('0x27')]=function(_0x319b9e){var _0x548d41=this;return new Promise(function(_0x327ee5,_0xd1f0e6){return db[_0x7186('0x1c')][_0x7186('0x28')]({'raw':_0x319b9e[_0x7186('0x1e')]?_0x319b9e[_0x7186('0x1e')]['raw']===undefined?!![]:![]:!![],'where':_0x319b9e[_0x7186('0x1e')]?_0x319b9e[_0x7186('0x1e')][_0x7186('0x20')]||null:null,'attributes':_0x319b9e[_0x7186('0x1e')]?_0x319b9e[_0x7186('0x1e')][_0x7186('0x21')]||null:null,'include':_0x319b9e[_0x7186('0x1e')]?_0x319b9e['options'][_0x7186('0x23')]?_[_0x7186('0x24')](_0x319b9e[_0x7186('0x1e')][_0x7186('0x23')],function(_0xe63ff){return{'model':db[_0xe63ff['model']],'as':_0xe63ff['as'],'attributes':_0xe63ff[_0x7186('0x21')],'include':_0xe63ff[_0x7186('0x23')]?_[_0x7186('0x24')](_0xe63ff['include'],function(_0xaa06e){return{'model':db[_0xaa06e[_0x7186('0x25')]],'as':_0xaa06e['as'],'attributes':_0xaa06e['attributes'],'include':_0xaa06e['include']?_[_0x7186('0x24')](_0xaa06e[_0x7186('0x23')],function(_0x2f3355){return{'model':db[_0x2f3355[_0x7186('0x25')]],'as':_0x2f3355['as'],'attributes':_0x2f3355[_0x7186('0x21')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x16540a){logger[_0x7186('0x19')](_0x7186('0x27'),_0x319b9e);logger[_0x7186('0x14')]('ShowMailAccount',_0x319b9e,JSON[_0x7186('0x16')](_0x16540a));_0x327ee5(_0x16540a);})['catch'](function(_0x23224f){logger['error'](_0x7186('0x27'),_0x23224f[_0x7186('0x18')],_0x319b9e);_0xd1f0e6(_0x548d41[_0x7186('0x17')](0x1f4,_0x23224f[_0x7186('0x18')]));});});};exports[_0x7186('0x29')]=function(_0x7fd2af){var _0x1c848b=this;return new Promise(function(_0x28806b,_0x43a9fe){var _0x2bf42b={'body':_0x7fd2af['body'],'channel':_0x7186('0x2a')};var _0x2d94b1=_['difference'](_[_0x7186('0x2b')](db['CmContact']['rawAttributes']),[_0x7186('0x2c'),_0x7186('0x2d'),_0x7186('0x2e'),_0x7186('0x2f')]);var _0x92cfa5=![];if(_0x7fd2af[_0x7186('0x30')]['id']){delete _0x7fd2af[_0x7186('0x30')]['id'];}if(_[_0x7186('0x31')](_0x7fd2af['body'][_0x7186('0x32')])){return _0x43a9fe(_0x1c848b[_0x7186('0x17')](0x1f4,'from\x20is\x20mandatory'));}if(_[_0x7186('0x31')](_0x7fd2af[_0x7186('0x30')][_0x7186('0x30')])||_0x7fd2af['body'][_0x7186('0x30')]===''){return _0x43a9fe(_0x1c848b[_0x7186('0x17')](0x1f4,'body\x20is\x20mandatory\x20and\x20not\x20empty'));}if(_[_0x7186('0x31')](_0x7fd2af[_0x7186('0x30')][_0x7186('0x33')])){return _0x43a9fe(_0x1c848b[_0x7186('0x17')](0x1f4,_0x7186('0x34')+_0x2d94b1));}if(!_[_0x7186('0x35')](_0x2d94b1,_0x7fd2af[_0x7186('0x30')]['mapKey'])){return _0x43a9fe(_0x1c848b[_0x7186('0x17')](0x1f4,_0x7186('0x36')+_0x2d94b1));}var _0x3c137e={};_0x3c137e[_0x7fd2af[_0x7186('0x30')][_0x7186('0x33')]]=_0x7fd2af['body'][_0x7186('0x32')];return db[_0x7186('0x1c')][_0x7186('0x28')]({'where':{'id':_0x7fd2af[_0x7186('0x37')]['id']},'include':[{'model':db[_0x7186('0x38')],'as':'List','include':[{'model':db[_0x7186('0x39')],'as':_0x7186('0x3a'),'where':_0x3c137e,'limit':0x1,'order':[['updatedAt',_0x7186('0x3b')]]}]},{'model':db['MailApplication'],'as':_0x7186('0x3c')},{'model':db['MailServerOut'],'as':'Smtp'}]})[_0x7186('0x11')](function(_0x3362fe){if(_0x3362fe&&_0x3362fe[_0x7186('0x3d')]){var _0x5e0c38=_0x3362fe[_0x7186('0x3e')]({'plain':!![]});_0x2bf42b[_0x7186('0x37')]=_[_0x7186('0x3f')](_0x5e0c38,[_0x7186('0x3c'),_0x7186('0x3d')]);_0x2bf42b[_0x7186('0x40')]=_0x5e0c38[_0x7186('0x3c')];_0x2bf42b['list']=_0x5e0c38['List'];_0x2bf42b[_0x7186('0x40')]=_[_0x7186('0x41')](_0x2bf42b[_0x7186('0x40')],[_0x7186('0x42')],[_0x7186('0x43')]);if(_0x2bf42b[_0x7186('0x37')]&&_0x2bf42b[_0x7186('0x37')][_0x7186('0x44')]){_0x2bf42b[_0x7186('0x40')][_0x7186('0x45')]({'id':0x0,'priority':_0x2bf42b[_0x7186('0x40')][_0x7186('0x46')]+0x1,'app':_0x7186('0x47'),'appdata':_0x7186('0x44'),'interval':'*,*,*,*'});}if(_0x2bf42b[_0x7186('0x37')][_0x7186('0x3c')]){delete _0x2bf42b[_0x7186('0x37')]['Applications'];}if(_0x2bf42b[_0x7186('0x37')][_0x7186('0x3d')]){delete _0x2bf42b[_0x7186('0x37')][_0x7186('0x3d')];}if(_0x5e0c38[_0x7186('0x3d')][_0x7186('0x3a')][_0x7186('0x46')]){return _0x5e0c38['List'][_0x7186('0x3a')][0x0];}var _0x93e17b=_[_0x7186('0x48')](_0x7fd2af[_0x7186('0x30')],{'firstName':_0x7fd2af[_0x7186('0x30')]['from'],'ListId':_0x5e0c38['ListId']});_0x93e17b[_0x7fd2af['body']['mapKey']]=_0x7fd2af[_0x7186('0x30')][_0x7186('0x32')];return db[_0x7186('0x39')]['create'](_0x93e17b);}else{throw new Error(_0x7186('0x49'));}})[_0x7186('0x11')](function(_0xc307a9){_0x2bf42b['contact']=_0xc307a9;if(_0xc307a9){if(!_0x7fd2af[_0x7186('0x30')][_0x7186('0x18')][_0x7186('0x4a')]){_0x7fd2af['body']['message']['messageId']=rs[_0x7186('0x4b')]()+'\x20'+_0x7fd2af[_0x7186('0x30')]['message'][_0x7186('0x32')];}var _0x2099d7={'ContactId':_0xc307a9['id'],'MailAccountId':_0x7fd2af[_0x7186('0x37')]['id'],'inReplyTo':_0x7fd2af[_0x7186('0x30')][_0x7186('0x18')][_0x7186('0x4a')],'to':_0x7fd2af['body'][_0x7186('0x18')][_0x7186('0x32')],'cc':_0x7fd2af[_0x7186('0x30')][_0x7186('0x18')]['cc'],'subject':_0x7fd2af[_0x7186('0x30')][_0x7186('0x18')]['subject'],'attach':_0x7fd2af[_0x7186('0x30')][_0x7186('0x18')][_0x7186('0x4c')],'lastMsgAt':moment()[_0x7186('0x4d')](_0x7186('0x4e')),'lastMsgDirection':'in','lastMsgBody':_0x7fd2af[_0x7186('0x30')][_0x7186('0x30')]};return db[_0x7186('0x4f')]['find']({'where':{'closed':![],'MailAccountId':_0x7fd2af[_0x7186('0x37')]['id']},'include':[{'model':db[_0x7186('0x50')],'as':_0x7186('0x51'),'attributes':[_0x7186('0x4a')],'where':{'messageId':_0x7fd2af[_0x7186('0x30')][_0x7186('0x18')]['inReplyTo']}}]})[_0x7186('0x11')](function(_0x3516da){if(_0x3516da){return[_0x3516da,![]];}return db[_0x7186('0x4f')]['create'](_0x2099d7)['then'](function(_0x2b714f){return[_0x2b714f,!![]];});});}else{throw new Error(_0x7186('0x52'));}})[_0x7186('0x53')](function(_0x5e3b99,_0x52e4ac){if(_0x5e3b99){_0x92cfa5=_0x52e4ac;if(!_0x52e4ac){return _0x5e3b99[_0x7186('0x54')]({'inReplyTo':_0x7fd2af[_0x7186('0x30')][_0x7186('0x18')][_0x7186('0x4a')],'to':_0x7fd2af[_0x7186('0x30')][_0x7186('0x18')][_0x7186('0x32')],'cc':_0x7fd2af[_0x7186('0x30')][_0x7186('0x18')]['cc'],'subject':_0x7fd2af[_0x7186('0x30')][_0x7186('0x18')][_0x7186('0x55')],'attach':_0x5e3b99['attach']?_0x5e3b99[_0x7186('0x4c')]:_0x7fd2af[_0x7186('0x30')][_0x7186('0x18')][_0x7186('0x4c')],'substatus':null,'substatusAt':moment()[_0x7186('0x4d')]('YYYY-MM-DD\x20HH:mm:ss'),'lastMsgAt':moment()['format'](_0x7186('0x4e')),'lastMsgDirection':'in','lastMsgBody':_0x7fd2af['body'][_0x7186('0x30')]});}else{return _0x5e3b99;}}})[_0x7186('0x11')](function(_0x338cad){_0x2bf42b['interaction']=_0x338cad['get']({'plain':!![]});_0x2bf42b['interaction']['created']=_0x92cfa5;return db['MailMessage'][_0x7186('0x56')]({'body':_0x7fd2af[_0x7186('0x30')]['body'],'MailAccountId':_0x7fd2af['account']['id'],'MailInteractionId':_0x338cad['id'],'direction':'in','ContactId':_0x2bf42b['contact']['id'],'messageId':_0x7fd2af[_0x7186('0x30')][_0x7186('0x18')][_0x7186('0x4a')],'from':_0x7fd2af[_0x7186('0x30')]['message'][_0x7186('0x32')],'to':_0x7fd2af[_0x7186('0x30')][_0x7186('0x18')]['to'],'cc':_0x7fd2af[_0x7186('0x30')]['message']['cc'],'subject':_0x7fd2af['body'][_0x7186('0x18')][_0x7186('0x55')],'attach':_0x7fd2af['body'][_0x7186('0x18')][_0x7186('0x4c')],'Attachments':_0x7fd2af[_0x7186('0x30')][_0x7186('0x18')]['attachments'],'originTo':_0x7fd2af[_0x7186('0x30')][_0x7186('0x18')][_0x7186('0x57')],'originCc':_0x7fd2af[_0x7186('0x30')][_0x7186('0x18')][_0x7186('0x58')],'bcc':_0x7fd2af[_0x7186('0x30')][_0x7186('0x18')][_0x7186('0x59')]},{'include':[{'model':db[_0x7186('0x5a')],'as':_0x7186('0x5b')}]});})['then'](function(_0x4bf731){_0x2bf42b[_0x7186('0x18')]=_0x4bf731;if(_0x2bf42b[_0x7186('0x5c')][_0x7186('0x5d')]){return db[_0x7186('0x5e')]['find']({'attributes':['id','name'],'where':{'id':_0x2bf42b['interaction'][_0x7186('0x5d')]}})[_0x7186('0x11')](function(_0x2a96aa){if(_0x2a96aa){_0x2bf42b[_0x7186('0x40')][_0x7186('0x5f')]({'id':0x0,'priority':0x0,'app':_0x7186('0x60'),'appdata':_0x2a96aa[_0x7186('0x61')]+','+(_0x2bf42b[_0x7186('0x37')]['waitForTheAssignedAgent']||0xa),'interval':'*,*,*,*'});}return respondWithRpcPromise(_0x7186('0x62'),'startRouting',_0x2bf42b);});}return respondWithRpcPromise(_0x7186('0x62'),_0x7186('0x63'),_0x2bf42b);})[_0x7186('0x11')](function(_0xd90037){_0x28806b(_0xd90037);})[_0x7186('0x26')](function(_0x30bed6){_0x43a9fe(_0x1c848b[_0x7186('0x17')](0x1f4,_0x30bed6[_0x7186('0x18')]));});});};
\ No newline at end of file