Built motion from commit c116dc8b.|2.6.30
[motion2.git] / server / api / mailAccount / mailAccount.rpc.js
index e439c3c..fcd211a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x9fe7=['length','List\x20not\x20found','contact','messageId','subject','format','YYYY-MM-DD\x20HH:mm:ss','MailInteraction','MailMessage','Messages','inReplyTo','Contact\x20not\x20found','spread','update','attach','interaction','created','create','attachments','originTo','originCc','ChatWebsiteId','Email','ChatOfflineMessageId','Attachments','UserId','User','name','unshift','waitForTheAssignedAgent','MailQueue','queue','waitForTheAssignedQueue','Start','startRouting','lodash','moment','randomstring','../../mysqldb','../../config/logger','rpc','jayson/promise','client','http','defaults','redis','localhost','./mailAccount.socket','register','then','info','MailAccount,\x20%s,\x20%s','debug','MailAccount,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','GetMailAccount','MailAccount','options','raw','where','include','model','attributes','map','ShowMailAccount','find','smtp','setDataValue','smtpOptions','getSmtpOptions','NotifyMailAccount','body','mail','difference','rawAttributes','createdAt','updatedAt','CompanyId','ListId','from','from\x20is\x20mandatory','isNil','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey','List','CmContact','Contacts','DESC','MailApplication','Applications','MailServerOut','Smtp','CloudProvider','get','account','omit','list','orderBy','applications','priority','asc','autoclose','*,*,*,*'];(function(_0x29b609,_0x19d388){var _0x54c952=function(_0xb3c38d){while(--_0xb3c38d){_0x29b609['push'](_0x29b609['shift']());}};_0x54c952(++_0x19d388);}(_0x9fe7,0x1df));var _0x79fe=function(_0x3b5a4b,_0x2a2ee1){_0x3b5a4b=_0x3b5a4b-0x0;var _0x32258a=_0x9fe7[_0x3b5a4b];return _0x32258a;};'use strict';var _=require(_0x79fe('0x0'));var moment=require(_0x79fe('0x1'));var BPromise=require('bluebird');var rs=require(_0x79fe('0x2'));var Redis=require('ioredis');var db=require(_0x79fe('0x3'))['db'];var logger=require(_0x79fe('0x4'))(_0x79fe('0x5'));var config=require('../../config/environment');var jayson=require(_0x79fe('0x6'));var client=jayson[_0x79fe('0x7')][_0x79fe('0x8')]({'port':0x232c});config['redis']=_[_0x79fe('0x9')](config[_0x79fe('0xa')],{'host':_0x79fe('0xb'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x79fe('0xa')]));require(_0x79fe('0xc'))[_0x79fe('0xd')](socket);function respondWithRpcPromise(_0x26d723,_0xafc7cd,_0x5b914a){return new BPromise(function(_0x34c217,_0x253f7d){return client['request'](_0x26d723,_0x5b914a)[_0x79fe('0xe')](function(_0x3c79f8){logger[_0x79fe('0xf')](_0x79fe('0x10'),_0xafc7cd,'request\x20sent');logger[_0x79fe('0x11')](_0x79fe('0x12'),_0xafc7cd,_0x79fe('0x13'),JSON[_0x79fe('0x14')](_0x3c79f8));if(_0x3c79f8[_0x79fe('0x15')]){if(_0x3c79f8[_0x79fe('0x15')][_0x79fe('0x16')]===0x1f4){logger[_0x79fe('0x15')]('MailAccount,\x20%s,\x20%s',_0xafc7cd,_0x3c79f8[_0x79fe('0x15')][_0x79fe('0x17')]);return _0x253f7d(_0x3c79f8[_0x79fe('0x15')][_0x79fe('0x17')]);}logger[_0x79fe('0x15')](_0x79fe('0x10'),_0xafc7cd,_0x3c79f8['error'][_0x79fe('0x17')]);return _0x34c217(_0x3c79f8[_0x79fe('0x15')][_0x79fe('0x17')]);}else{logger[_0x79fe('0xf')]('MailAccount,\x20%s,\x20%s',_0xafc7cd,_0x79fe('0x13'));_0x34c217(_0x3c79f8[_0x79fe('0x18')][_0x79fe('0x17')]);}})[_0x79fe('0x19')](function(_0x536641){logger['error'](_0x79fe('0x10'),_0xafc7cd,_0x536641);_0x253f7d(_0x536641);});});}exports[_0x79fe('0x1a')]=function(_0x25e51f){var _0x4bca4d=this;return new Promise(function(_0x891611,_0x4141ec){return db[_0x79fe('0x1b')]['findAll']({'raw':_0x25e51f[_0x79fe('0x1c')]?_0x25e51f['options'][_0x79fe('0x1d')]===undefined?!![]:![]:!![],'where':_0x25e51f[_0x79fe('0x1c')]?_0x25e51f[_0x79fe('0x1c')][_0x79fe('0x1e')]||null:null,'attributes':_0x25e51f[_0x79fe('0x1c')]?_0x25e51f[_0x79fe('0x1c')]['attributes']||null:null,'limit':_0x25e51f['options']?_0x25e51f[_0x79fe('0x1c')]['limit']||null:null,'include':_0x25e51f[_0x79fe('0x1c')]?_0x25e51f[_0x79fe('0x1c')]['include']?_['map'](_0x25e51f[_0x79fe('0x1c')][_0x79fe('0x1f')],function(_0x59339b){return{'model':db[_0x59339b[_0x79fe('0x20')]],'as':_0x59339b['as'],'attributes':_0x59339b[_0x79fe('0x21')],'include':_0x59339b['include']?_['map'](_0x59339b['include'],function(_0x3720fa){return{'model':db[_0x3720fa[_0x79fe('0x20')]],'as':_0x3720fa['as'],'attributes':_0x3720fa[_0x79fe('0x21')],'include':_0x3720fa['include']?_[_0x79fe('0x22')](_0x3720fa[_0x79fe('0x1f')],function(_0x3bc5bc){return{'model':db[_0x3bc5bc['model']],'as':_0x3bc5bc['as'],'attributes':_0x3bc5bc['attributes']};}):[]};}):[]};}):[]:[]})[_0x79fe('0xe')](function(_0x51200f){logger[_0x79fe('0xf')]('GetMailAccount',_0x25e51f);logger['debug']('GetMailAccount',_0x25e51f,JSON['stringify'](_0x51200f));_0x891611(_0x51200f);})[_0x79fe('0x19')](function(_0xd2ec88){logger['error'](_0x79fe('0x1a'),_0xd2ec88['message'],_0x25e51f);_0x4141ec(_0x4bca4d[_0x79fe('0x15')](0x1f4,_0xd2ec88[_0x79fe('0x17')]));});});};exports[_0x79fe('0x23')]=function(_0x3558f2){var _0x128ca3=this;return new Promise(function(_0x5ac1c4,_0x436279){return db[_0x79fe('0x1b')][_0x79fe('0x24')]({'raw':_0x3558f2[_0x79fe('0x1c')]?_0x3558f2[_0x79fe('0x1c')][_0x79fe('0x1d')]===undefined?!![]:![]:!![],'where':_0x3558f2['options']?_0x3558f2[_0x79fe('0x1c')][_0x79fe('0x1e')]||null:null,'attributes':_0x3558f2[_0x79fe('0x1c')]?_0x3558f2[_0x79fe('0x1c')][_0x79fe('0x21')]||null:null,'include':_0x3558f2[_0x79fe('0x1c')]?_0x3558f2['options'][_0x79fe('0x1f')]?_['map'](_0x3558f2[_0x79fe('0x1c')]['include'],function(_0x2a533b){return{'model':db[_0x2a533b['model']],'as':_0x2a533b['as'],'attributes':_0x2a533b[_0x79fe('0x21')],'include':_0x2a533b[_0x79fe('0x1f')]?_[_0x79fe('0x22')](_0x2a533b['include'],function(_0x174423){return{'model':db[_0x174423[_0x79fe('0x20')]],'as':_0x174423['as'],'attributes':_0x174423[_0x79fe('0x21')],'include':_0x174423[_0x79fe('0x1f')]?_[_0x79fe('0x22')](_0x174423['include'],function(_0x53957b){return{'model':db[_0x53957b[_0x79fe('0x20')]],'as':_0x53957b['as'],'attributes':_0x53957b['attributes']};}):[]};}):[]};}):[]:[]})[_0x79fe('0xe')](function(_0x44d97e){if(_0x3558f2['options'][_0x79fe('0x25')]===!![])_0x44d97e[_0x79fe('0x26')](_0x79fe('0x27'),_0x44d97e[_0x79fe('0x28')]());logger[_0x79fe('0xf')](_0x79fe('0x23'),_0x3558f2);logger['debug'](_0x79fe('0x23'),_0x3558f2,JSON[_0x79fe('0x14')](_0x44d97e));_0x5ac1c4(_0x44d97e);})[_0x79fe('0x19')](function(_0x2d2908){logger['error'](_0x79fe('0x23'),_0x2d2908['message'],_0x3558f2);_0x436279(_0x128ca3[_0x79fe('0x15')](0x1f4,_0x2d2908['message']));});});};exports[_0x79fe('0x29')]=function(_0x4ab42e){var _0x83737e=this;return new Promise(function(_0x132662,_0x577341){var _0x5e27bc={'body':_0x4ab42e[_0x79fe('0x2a')],'channel':_0x79fe('0x2b')};var _0x69ae72=_[_0x79fe('0x2c')](_['keys'](db['CmContact'][_0x79fe('0x2d')]),[_0x79fe('0x2e'),_0x79fe('0x2f'),_0x79fe('0x30'),_0x79fe('0x31')]);var _0x3feb46=![];if(_0x4ab42e[_0x79fe('0x2a')]['id']){delete _0x4ab42e[_0x79fe('0x2a')]['id'];}if(_['isNil'](_0x4ab42e[_0x79fe('0x2a')][_0x79fe('0x32')])){return _0x577341(_0x83737e[_0x79fe('0x15')](0x1f4,_0x79fe('0x33')));}if(_[_0x79fe('0x34')](_0x4ab42e[_0x79fe('0x2a')]['body'])||_0x4ab42e[_0x79fe('0x2a')][_0x79fe('0x2a')]===''){return _0x577341(_0x83737e[_0x79fe('0x15')](0x1f4,_0x79fe('0x35')));}if(_[_0x79fe('0x34')](_0x4ab42e[_0x79fe('0x2a')]['mapKey'])){return _0x577341(_0x83737e[_0x79fe('0x15')](0x1f4,_0x79fe('0x36')+_0x69ae72));}if(!_[_0x79fe('0x37')](_0x69ae72,_0x4ab42e['body'][_0x79fe('0x38')])){return _0x577341(_0x83737e['error'](0x1f4,'mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x69ae72));}var _0x28068f={};_0x28068f[_0x4ab42e[_0x79fe('0x2a')][_0x79fe('0x38')]]=_0x4ab42e['body'][_0x79fe('0x32')];return db[_0x79fe('0x1b')][_0x79fe('0x24')]({'where':{'id':_0x4ab42e['account']['id']},'include':[{'model':db['CmList'],'as':_0x79fe('0x39'),'include':[{'model':db[_0x79fe('0x3a')],'as':_0x79fe('0x3b'),'where':_0x28068f,'limit':0x1,'order':[[_0x79fe('0x2f'),_0x79fe('0x3c')]]}]},{'model':db[_0x79fe('0x3d')],'as':_0x79fe('0x3e')},{'model':db[_0x79fe('0x3f')],'as':_0x79fe('0x40'),'include':[{'model':db['CloudProvider'],'as':_0x79fe('0x41')}]}]})[_0x79fe('0xe')](function(_0x496486){if(_0x496486&&_0x496486[_0x79fe('0x39')]){var _0x4bd648=_0x496486[_0x79fe('0x42')]({'plain':!![]});_0x5e27bc[_0x79fe('0x43')]=_[_0x79fe('0x44')](_0x4bd648,[_0x79fe('0x3e'),'List']);_0x5e27bc[_0x79fe('0x43')][_0x79fe('0x27')]=_0x496486[_0x79fe('0x28')]();_0x5e27bc['applications']=_0x4bd648['Applications'];_0x5e27bc[_0x79fe('0x45')]=_0x4bd648[_0x79fe('0x39')];_0x5e27bc['applications']=_[_0x79fe('0x46')](_0x5e27bc[_0x79fe('0x47')],[_0x79fe('0x48')],[_0x79fe('0x49')]);if(_0x5e27bc['account']&&_0x5e27bc[_0x79fe('0x43')][_0x79fe('0x4a')]){_0x5e27bc[_0x79fe('0x47')]['push']({'id':0x0,'priority':_0x5e27bc['applications']['length']+0x1,'app':'close','appdata':'autoclose','interval':_0x79fe('0x4b')});}if(_0x5e27bc[_0x79fe('0x43')]['Applications']){delete _0x5e27bc[_0x79fe('0x43')][_0x79fe('0x3e')];}if(_0x5e27bc[_0x79fe('0x43')]['List']){delete _0x5e27bc['account']['List'];}if(_0x4bd648[_0x79fe('0x39')]['Contacts'][_0x79fe('0x4c')]){return _0x4bd648[_0x79fe('0x39')][_0x79fe('0x3b')][0x0];}var _0x1ac188=_[_0x79fe('0x9')](_0x4ab42e[_0x79fe('0x2a')],{'firstName':_0x4ab42e[_0x79fe('0x2a')][_0x79fe('0x32')],'ListId':_0x4bd648[_0x79fe('0x31')]});_0x1ac188[_0x4ab42e[_0x79fe('0x2a')][_0x79fe('0x38')]]=_0x4ab42e['body'][_0x79fe('0x32')];return db[_0x79fe('0x3a')]['create'](_0x1ac188);}else{throw new Error(_0x79fe('0x4d'));}})['then'](function(_0xc1ec58){_0x5e27bc[_0x79fe('0x4e')]=_0xc1ec58;if(_0xc1ec58){if(!_0x4ab42e['body'][_0x79fe('0x17')]['messageId']){_0x4ab42e[_0x79fe('0x2a')]['message']['messageId']=rs['generate']()+'\x20'+_0x4ab42e[_0x79fe('0x2a')][_0x79fe('0x17')][_0x79fe('0x32')];}var _0x350da0={'ContactId':_0xc1ec58['id'],'MailAccountId':_0x4ab42e[_0x79fe('0x43')]['id'],'inReplyTo':_0x4ab42e[_0x79fe('0x2a')][_0x79fe('0x17')][_0x79fe('0x4f')],'to':_0x4ab42e[_0x79fe('0x2a')]['message'][_0x79fe('0x32')],'cc':_0x4ab42e[_0x79fe('0x2a')][_0x79fe('0x17')]['cc'],'subject':_0x4ab42e[_0x79fe('0x2a')]['message'][_0x79fe('0x50')],'attach':_0x4ab42e['body'][_0x79fe('0x17')]['attach'],'lastMsgAt':moment()[_0x79fe('0x51')](_0x79fe('0x52')),'lastMsgDirection':'in'};return db[_0x79fe('0x53')][_0x79fe('0x24')]({'where':{'closed':![],'MailAccountId':_0x4ab42e['account']['id']},'include':[{'model':db[_0x79fe('0x54')],'as':_0x79fe('0x55'),'attributes':[_0x79fe('0x4f')],'where':{'messageId':_0x4ab42e[_0x79fe('0x2a')]['message'][_0x79fe('0x56')]}}]})[_0x79fe('0xe')](function(_0x50ed6c){if(_0x50ed6c){return[_0x50ed6c,![]];}return db[_0x79fe('0x53')]['create'](_0x350da0)['then'](function(_0x37ccea){return[_0x37ccea,!![]];});});}else{throw new Error(_0x79fe('0x57'));}})[_0x79fe('0x58')](function(_0x49de47,_0x58adb7){if(_0x49de47){_0x3feb46=_0x58adb7;if(!_0x58adb7){return _0x49de47[_0x79fe('0x59')]({'inReplyTo':_0x4ab42e['body']['message'][_0x79fe('0x4f')],'to':_0x4ab42e[_0x79fe('0x2a')][_0x79fe('0x17')][_0x79fe('0x32')],'cc':_0x4ab42e[_0x79fe('0x2a')][_0x79fe('0x17')]['cc'],'subject':_0x4ab42e[_0x79fe('0x2a')][_0x79fe('0x17')][_0x79fe('0x50')],'attach':_0x49de47['attach']?_0x49de47[_0x79fe('0x5a')]:_0x4ab42e[_0x79fe('0x2a')]['message'][_0x79fe('0x5a')],'substatus':null,'substatusAt':moment()[_0x79fe('0x51')](_0x79fe('0x52')),'lastMsgAt':moment()[_0x79fe('0x51')](_0x79fe('0x52')),'lastMsgDirection':'in'});}else{return _0x49de47;}}})[_0x79fe('0xe')](function(_0x6cf38e){_0x5e27bc[_0x79fe('0x5b')]=_0x6cf38e[_0x79fe('0x42')]({'plain':!![]});_0x5e27bc[_0x79fe('0x5b')][_0x79fe('0x5c')]=_0x3feb46;return db['MailMessage'][_0x79fe('0x5d')]({'body':_0x4ab42e[_0x79fe('0x2a')][_0x79fe('0x2a')],'MailAccountId':_0x4ab42e[_0x79fe('0x43')]['id'],'MailInteractionId':_0x6cf38e['id'],'direction':'in','ContactId':_0x5e27bc[_0x79fe('0x4e')]['id'],'messageId':_0x4ab42e[_0x79fe('0x2a')][_0x79fe('0x17')]['messageId'],'from':_0x4ab42e[_0x79fe('0x2a')][_0x79fe('0x17')][_0x79fe('0x32')],'to':_0x4ab42e['body']['message']['to'],'cc':_0x4ab42e['body']['message']['cc'],'subject':_0x4ab42e[_0x79fe('0x2a')]['message'][_0x79fe('0x50')],'attach':_0x4ab42e[_0x79fe('0x2a')][_0x79fe('0x17')][_0x79fe('0x5a')],'Attachments':_0x4ab42e[_0x79fe('0x2a')]['message'][_0x79fe('0x5e')],'originTo':_0x4ab42e['body'][_0x79fe('0x17')][_0x79fe('0x5f')],'originCc':_0x4ab42e[_0x79fe('0x2a')][_0x79fe('0x17')][_0x79fe('0x60')],'bcc':_0x4ab42e[_0x79fe('0x2a')][_0x79fe('0x17')]['bcc'],'ChatWebsiteId':_0x4ab42e[_0x79fe('0x2a')]['message'][_0x79fe('0x61')]||null,'originChannel':_0x4ab42e[_0x79fe('0x2a')][_0x79fe('0x17')]['originChannel']||_0x79fe('0x62'),'ChatOfflineMessageId':_0x4ab42e[_0x79fe('0x2a')][_0x79fe('0x17')][_0x79fe('0x63')]||null},{'include':[{'model':db['Attachment'],'as':_0x79fe('0x64')}]});})[_0x79fe('0xe')](function(_0x2d4bfa){_0x5e27bc['message']=_0x2d4bfa;if(!_0x5e27bc[_0x79fe('0x5b')][_0x79fe('0x65')]){return;}return db[_0x79fe('0x66')][_0x79fe('0x24')]({'attributes':['id',_0x79fe('0x67')],'where':{'id':_0x5e27bc[_0x79fe('0x5b')][_0x79fe('0x65')]}});})[_0x79fe('0xe')](function(_0x25edcd){if(_0x25edcd){_0x5e27bc['applications'][_0x79fe('0x68')]({'id':0x0,'priority':0x0,'app':'agent','appdata':_0x25edcd[_0x79fe('0x67')]+','+(_0x5e27bc[_0x79fe('0x43')][_0x79fe('0x69')]||0xa),'interval':_0x79fe('0x4b')});}if(!_0x5e27bc[_0x79fe('0x5b')]['queueId']){return;}return db[_0x79fe('0x6a')]['find']({'attributes':['id',_0x79fe('0x67')],'where':{'id':_0x5e27bc[_0x79fe('0x5b')]['queueId']}});})[_0x79fe('0xe')](function(_0x3d7392){if(_0x3d7392){_0x5e27bc[_0x79fe('0x47')][_0x79fe('0x68')]({'id':0x0,'priority':0x1,'app':_0x79fe('0x6b'),'appdata':_0x3d7392['name']+','+(_0x5e27bc[_0x79fe('0x43')][_0x79fe('0x6c')]||0x12c),'interval':_0x79fe('0x4b')});}return respondWithRpcPromise(_0x79fe('0x6d'),_0x79fe('0x6e'),_0x5e27bc);})[_0x79fe('0xe')](function(_0x477c6f){_0x132662(_0x477c6f);})[_0x79fe('0x19')](function(_0x38fc15){_0x577341(_0x83737e[_0x79fe('0x15')](0x1f4,_0x38fc15['message']));});});};
\ No newline at end of file
+var _0x4351=['ChatWebsiteId','originChannel','Attachment','User','name','UserId','unshift','agent','queueId','queue','waitForTheAssignedQueue','Start','startRouting','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','socket.io-emitter','register','request','then','MailAccount,\x20%s,\x20%s','debug','request\x20sent','code','error','message','info','result','catch','findAll','options','raw','attributes','limit','include','map','model','GetMailAccount','stringify','find','smtp','setDataValue','smtpOptions','getSmtpOptions','ShowMailAccount','mail','difference','CmContact','rawAttributes','CompanyId','ListId','isNil','from','from\x20is\x20mandatory','body','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey','account','List','Contacts','MailApplication','MailServerOut','CloudProvider','get','omit','Applications','applications','list','orderBy','priority','asc','push','length','close','autoclose','*,*,*,*','create','contact','messageId','generate','subject','attach','MailInteraction','MailMessage','inReplyTo','update','format','YYYY-MM-DD\x20HH:mm:ss','interaction','attachments','originTo','originCc','bcc'];(function(_0x198c12,_0xc60219){var _0x2ddc79=function(_0xa058b0){while(--_0xa058b0){_0x198c12['push'](_0x198c12['shift']());}};_0x2ddc79(++_0xc60219);}(_0x4351,0x1b5));var _0x1435=function(_0x334841,_0x2bbc4c){_0x334841=_0x334841-0x0;var _0x5beb4b=_0x4351[_0x334841];return _0x5beb4b;};'use strict';var _=require(_0x1435('0x0'));var moment=require(_0x1435('0x1'));var BPromise=require(_0x1435('0x2'));var rs=require(_0x1435('0x3'));var Redis=require(_0x1435('0x4'));var db=require(_0x1435('0x5'))['db'];var logger=require(_0x1435('0x6'))(_0x1435('0x7'));var config=require(_0x1435('0x8'));var jayson=require(_0x1435('0x9'));var client=jayson[_0x1435('0xa')][_0x1435('0xb')]({'port':0x232c});config[_0x1435('0xc')]=_[_0x1435('0xd')](config[_0x1435('0xc')],{'host':'localhost','port':0x18eb});var socket=require(_0x1435('0xe'))(new Redis(config['redis']));require('./mailAccount.socket')[_0x1435('0xf')](socket);function respondWithRpcPromise(_0x22a221,_0x14a9e1,_0x35a509){return new BPromise(function(_0xade491,_0x55cd88){return client[_0x1435('0x10')](_0x22a221,_0x35a509)[_0x1435('0x11')](function(_0x5a64a4){logger['info'](_0x1435('0x12'),_0x14a9e1,'request\x20sent');logger[_0x1435('0x13')]('MailAccount,\x20%s,\x20%s,\x20%s',_0x14a9e1,_0x1435('0x14'),JSON['stringify'](_0x5a64a4));if(_0x5a64a4['error']){if(_0x5a64a4['error'][_0x1435('0x15')]===0x1f4){logger[_0x1435('0x16')](_0x1435('0x12'),_0x14a9e1,_0x5a64a4['error']['message']);return _0x55cd88(_0x5a64a4[_0x1435('0x16')]['message']);}logger[_0x1435('0x16')](_0x1435('0x12'),_0x14a9e1,_0x5a64a4[_0x1435('0x16')][_0x1435('0x17')]);return _0xade491(_0x5a64a4[_0x1435('0x16')][_0x1435('0x17')]);}else{logger[_0x1435('0x18')](_0x1435('0x12'),_0x14a9e1,_0x1435('0x14'));_0xade491(_0x5a64a4[_0x1435('0x19')][_0x1435('0x17')]);}})[_0x1435('0x1a')](function(_0x68f503){logger[_0x1435('0x16')](_0x1435('0x12'),_0x14a9e1,_0x68f503);_0x55cd88(_0x68f503);});});}exports['GetMailAccount']=function(_0x26da28){var _0x34f555=this;return new Promise(function(_0x4cf63f,_0x4694cb){return db['MailAccount'][_0x1435('0x1b')]({'raw':_0x26da28[_0x1435('0x1c')]?_0x26da28[_0x1435('0x1c')][_0x1435('0x1d')]===undefined?!![]:![]:!![],'where':_0x26da28[_0x1435('0x1c')]?_0x26da28[_0x1435('0x1c')]['where']||null:null,'attributes':_0x26da28[_0x1435('0x1c')]?_0x26da28[_0x1435('0x1c')][_0x1435('0x1e')]||null:null,'limit':_0x26da28[_0x1435('0x1c')]?_0x26da28[_0x1435('0x1c')][_0x1435('0x1f')]||null:null,'include':_0x26da28[_0x1435('0x1c')]?_0x26da28[_0x1435('0x1c')][_0x1435('0x20')]?_[_0x1435('0x21')](_0x26da28[_0x1435('0x1c')]['include'],function(_0x523792){return{'model':db[_0x523792[_0x1435('0x22')]],'as':_0x523792['as'],'attributes':_0x523792[_0x1435('0x1e')],'include':_0x523792[_0x1435('0x20')]?_['map'](_0x523792[_0x1435('0x20')],function(_0x25cf29){return{'model':db[_0x25cf29[_0x1435('0x22')]],'as':_0x25cf29['as'],'attributes':_0x25cf29[_0x1435('0x1e')],'include':_0x25cf29[_0x1435('0x20')]?_['map'](_0x25cf29[_0x1435('0x20')],function(_0x7a2f63){return{'model':db[_0x7a2f63[_0x1435('0x22')]],'as':_0x7a2f63['as'],'attributes':_0x7a2f63[_0x1435('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x1435('0x11')](function(_0x108c25){logger[_0x1435('0x18')]('GetMailAccount',_0x26da28);logger[_0x1435('0x13')](_0x1435('0x23'),_0x26da28,JSON[_0x1435('0x24')](_0x108c25));_0x4cf63f(_0x108c25);})[_0x1435('0x1a')](function(_0x297edf){logger['error'](_0x1435('0x23'),_0x297edf[_0x1435('0x17')],_0x26da28);_0x4694cb(_0x34f555[_0x1435('0x16')](0x1f4,_0x297edf[_0x1435('0x17')]));});});};exports['ShowMailAccount']=function(_0x2afc79){var _0x1dc553=this;return new Promise(function(_0x49209a,_0x4503a1){return db['MailAccount'][_0x1435('0x25')]({'raw':_0x2afc79[_0x1435('0x1c')]?_0x2afc79['options'][_0x1435('0x1d')]===undefined?!![]:![]:!![],'where':_0x2afc79[_0x1435('0x1c')]?_0x2afc79['options']['where']||null:null,'attributes':_0x2afc79['options']?_0x2afc79[_0x1435('0x1c')]['attributes']||null:null,'include':_0x2afc79[_0x1435('0x1c')]?_0x2afc79['options'][_0x1435('0x20')]?_['map'](_0x2afc79[_0x1435('0x1c')][_0x1435('0x20')],function(_0x249edc){return{'model':db[_0x249edc[_0x1435('0x22')]],'as':_0x249edc['as'],'attributes':_0x249edc[_0x1435('0x1e')],'include':_0x249edc[_0x1435('0x20')]?_['map'](_0x249edc[_0x1435('0x20')],function(_0x138597){return{'model':db[_0x138597[_0x1435('0x22')]],'as':_0x138597['as'],'attributes':_0x138597[_0x1435('0x1e')],'include':_0x138597[_0x1435('0x20')]?_['map'](_0x138597[_0x1435('0x20')],function(_0x578845){return{'model':db[_0x578845[_0x1435('0x22')]],'as':_0x578845['as'],'attributes':_0x578845[_0x1435('0x1e')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x11cf64){if(_0x2afc79[_0x1435('0x1c')][_0x1435('0x26')]===!![])_0x11cf64[_0x1435('0x27')](_0x1435('0x28'),_0x11cf64[_0x1435('0x29')]());logger[_0x1435('0x18')](_0x1435('0x2a'),_0x2afc79);logger[_0x1435('0x13')](_0x1435('0x2a'),_0x2afc79,JSON[_0x1435('0x24')](_0x11cf64));_0x49209a(_0x11cf64);})[_0x1435('0x1a')](function(_0x552a61){logger[_0x1435('0x16')]('ShowMailAccount',_0x552a61[_0x1435('0x17')],_0x2afc79);_0x4503a1(_0x1dc553['error'](0x1f4,_0x552a61[_0x1435('0x17')]));});});};exports['NotifyMailAccount']=function(_0x473d6){var _0x516e44=this;return new Promise(function(_0x36bc74,_0x186e7a){var _0x398d3c={'body':_0x473d6['body'],'channel':_0x1435('0x2b')};var _0x1fe164=_[_0x1435('0x2c')](_['keys'](db[_0x1435('0x2d')][_0x1435('0x2e')]),['createdAt','updatedAt',_0x1435('0x2f'),_0x1435('0x30')]);var _0x2dd1f5=![];if(_0x473d6['body']['id']){delete _0x473d6['body']['id'];}if(_[_0x1435('0x31')](_0x473d6['body'][_0x1435('0x32')])){return _0x186e7a(_0x516e44['error'](0x1f4,_0x1435('0x33')));}if(_['isNil'](_0x473d6[_0x1435('0x34')]['body'])||_0x473d6[_0x1435('0x34')]['body']===''){return _0x186e7a(_0x516e44[_0x1435('0x16')](0x1f4,_0x1435('0x35')));}if(_['isNil'](_0x473d6[_0x1435('0x34')]['mapKey'])){return _0x186e7a(_0x516e44[_0x1435('0x16')](0x1f4,_0x1435('0x36')+_0x1fe164));}if(!_[_0x1435('0x37')](_0x1fe164,_0x473d6['body'][_0x1435('0x38')])){return _0x186e7a(_0x516e44[_0x1435('0x16')](0x1f4,'mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x1fe164));}var _0x1f73f4={};_0x1f73f4[_0x473d6[_0x1435('0x34')]['mapKey']]=_0x473d6[_0x1435('0x34')][_0x1435('0x32')];return db['MailAccount'][_0x1435('0x25')]({'where':{'id':_0x473d6[_0x1435('0x39')]['id']},'include':[{'model':db['CmList'],'as':_0x1435('0x3a'),'include':[{'model':db[_0x1435('0x2d')],'as':_0x1435('0x3b'),'where':_0x1f73f4,'limit':0x1,'order':[['updatedAt','DESC']]}]},{'model':db[_0x1435('0x3c')],'as':'Applications'},{'model':db[_0x1435('0x3d')],'as':'Smtp','include':[{'model':db[_0x1435('0x3e')],'as':_0x1435('0x3e')}]}]})[_0x1435('0x11')](function(_0x148862){if(_0x148862&&_0x148862[_0x1435('0x3a')]){var _0x3d2346=_0x148862[_0x1435('0x3f')]({'plain':!![]});_0x398d3c['account']=_[_0x1435('0x40')](_0x3d2346,[_0x1435('0x41'),_0x1435('0x3a')]);_0x398d3c['account'][_0x1435('0x28')]=_0x148862[_0x1435('0x29')]();_0x398d3c[_0x1435('0x42')]=_0x3d2346[_0x1435('0x41')];_0x398d3c[_0x1435('0x43')]=_0x3d2346[_0x1435('0x3a')];_0x398d3c[_0x1435('0x42')]=_[_0x1435('0x44')](_0x398d3c['applications'],[_0x1435('0x45')],[_0x1435('0x46')]);if(_0x398d3c[_0x1435('0x39')]&&_0x398d3c[_0x1435('0x39')]['autoclose']){_0x398d3c['applications'][_0x1435('0x47')]({'id':0x0,'priority':_0x398d3c[_0x1435('0x42')][_0x1435('0x48')]+0x1,'app':_0x1435('0x49'),'appdata':_0x1435('0x4a'),'interval':_0x1435('0x4b')});}if(_0x398d3c[_0x1435('0x39')][_0x1435('0x41')]){delete _0x398d3c[_0x1435('0x39')]['Applications'];}if(_0x398d3c['account'][_0x1435('0x3a')]){delete _0x398d3c['account'][_0x1435('0x3a')];}if(_0x3d2346[_0x1435('0x3a')][_0x1435('0x3b')][_0x1435('0x48')]){return _0x3d2346[_0x1435('0x3a')][_0x1435('0x3b')][0x0];}var _0xd776e6=_['defaults'](_0x473d6[_0x1435('0x34')],{'firstName':_0x473d6['body'][_0x1435('0x32')],'ListId':_0x3d2346[_0x1435('0x30')]});_0xd776e6[_0x473d6['body'][_0x1435('0x38')]]=_0x473d6[_0x1435('0x34')][_0x1435('0x32')];return db[_0x1435('0x2d')][_0x1435('0x4c')](_0xd776e6);}else{throw new Error('List\x20not\x20found');}})[_0x1435('0x11')](function(_0x3da03e){_0x398d3c[_0x1435('0x4d')]=_0x3da03e;if(_0x3da03e){if(!_0x473d6[_0x1435('0x34')][_0x1435('0x17')][_0x1435('0x4e')]){_0x473d6['body']['message'][_0x1435('0x4e')]=rs[_0x1435('0x4f')]()+'\x20'+_0x473d6[_0x1435('0x34')][_0x1435('0x17')][_0x1435('0x32')];}var _0x12c603={'ContactId':_0x3da03e['id'],'MailAccountId':_0x473d6[_0x1435('0x39')]['id'],'inReplyTo':_0x473d6[_0x1435('0x34')]['message'][_0x1435('0x4e')],'to':_0x473d6['body'][_0x1435('0x17')][_0x1435('0x32')],'cc':_0x473d6['body'][_0x1435('0x17')]['cc'],'subject':_0x473d6[_0x1435('0x34')]['message'][_0x1435('0x50')],'attach':_0x473d6[_0x1435('0x34')]['message'][_0x1435('0x51')],'lastMsgAt':moment()['format']('YYYY-MM-DD\x20HH:mm:ss'),'lastMsgDirection':'in'};return db[_0x1435('0x52')][_0x1435('0x25')]({'where':{'closed':![],'MailAccountId':_0x473d6[_0x1435('0x39')]['id']},'include':[{'model':db[_0x1435('0x53')],'as':'Messages','attributes':[_0x1435('0x4e')],'where':{'messageId':_0x473d6[_0x1435('0x34')]['message'][_0x1435('0x54')]}}]})[_0x1435('0x11')](function(_0x5d4807){if(_0x5d4807){return[_0x5d4807,![]];}return db[_0x1435('0x52')][_0x1435('0x4c')](_0x12c603)[_0x1435('0x11')](function(_0x44b211){return[_0x44b211,!![]];});});}else{throw new Error('Contact\x20not\x20found');}})['spread'](function(_0x3e40d,_0x21bc66){if(_0x3e40d){_0x2dd1f5=_0x21bc66;if(!_0x21bc66){return _0x3e40d[_0x1435('0x55')]({'inReplyTo':_0x473d6[_0x1435('0x34')]['message'][_0x1435('0x4e')],'to':_0x473d6[_0x1435('0x34')][_0x1435('0x17')][_0x1435('0x32')],'cc':_0x473d6['body'][_0x1435('0x17')]['cc'],'subject':_0x473d6[_0x1435('0x34')][_0x1435('0x17')]['subject'],'attach':_0x3e40d[_0x1435('0x51')]?_0x3e40d[_0x1435('0x51')]:_0x473d6[_0x1435('0x34')][_0x1435('0x17')][_0x1435('0x51')],'substatus':null,'substatusAt':moment()[_0x1435('0x56')](_0x1435('0x57')),'lastMsgAt':moment()[_0x1435('0x56')](_0x1435('0x57')),'lastMsgDirection':'in'});}else{return _0x3e40d;}}})['then'](function(_0x1347a6){_0x398d3c[_0x1435('0x58')]=_0x1347a6[_0x1435('0x3f')]({'plain':!![]});_0x398d3c[_0x1435('0x58')]['created']=_0x2dd1f5;return db['MailMessage'][_0x1435('0x4c')]({'body':_0x473d6['body']['body'],'MailAccountId':_0x473d6['account']['id'],'MailInteractionId':_0x1347a6['id'],'direction':'in','ContactId':_0x398d3c[_0x1435('0x4d')]['id'],'messageId':_0x473d6['body']['message'][_0x1435('0x4e')],'from':_0x473d6[_0x1435('0x34')][_0x1435('0x17')][_0x1435('0x32')],'to':_0x473d6[_0x1435('0x34')]['message']['to'],'cc':_0x473d6[_0x1435('0x34')][_0x1435('0x17')]['cc'],'subject':_0x473d6[_0x1435('0x34')][_0x1435('0x17')]['subject'],'attach':_0x473d6[_0x1435('0x34')]['message'][_0x1435('0x51')],'Attachments':_0x473d6[_0x1435('0x34')]['message'][_0x1435('0x59')],'originTo':_0x473d6[_0x1435('0x34')][_0x1435('0x17')][_0x1435('0x5a')],'originCc':_0x473d6[_0x1435('0x34')][_0x1435('0x17')][_0x1435('0x5b')],'bcc':_0x473d6[_0x1435('0x34')][_0x1435('0x17')][_0x1435('0x5c')],'ChatWebsiteId':_0x473d6[_0x1435('0x34')][_0x1435('0x17')][_0x1435('0x5d')]||null,'originChannel':_0x473d6[_0x1435('0x34')][_0x1435('0x17')][_0x1435('0x5e')]||'Email','ChatOfflineMessageId':_0x473d6[_0x1435('0x34')][_0x1435('0x17')]['ChatOfflineMessageId']||null},{'include':[{'model':db[_0x1435('0x5f')],'as':'Attachments'}]});})['then'](function(_0x1d0b14){_0x398d3c[_0x1435('0x17')]=_0x1d0b14;if(!_0x398d3c['interaction']['UserId']){return;}return db[_0x1435('0x60')]['find']({'attributes':['id',_0x1435('0x61')],'where':{'id':_0x398d3c[_0x1435('0x58')][_0x1435('0x62')]}});})['then'](function(_0x332d5a){if(_0x332d5a){_0x398d3c[_0x1435('0x42')][_0x1435('0x63')]({'id':0x0,'priority':0x0,'app':_0x1435('0x64'),'appdata':_0x332d5a[_0x1435('0x61')]+','+(_0x398d3c[_0x1435('0x39')]['waitForTheAssignedAgent']||0xa),'interval':_0x1435('0x4b')});}if(!_0x398d3c[_0x1435('0x58')][_0x1435('0x65')]){return;}return db['MailQueue']['find']({'attributes':['id','name'],'where':{'id':_0x398d3c[_0x1435('0x58')][_0x1435('0x65')]}});})['then'](function(_0x15fd08){if(_0x15fd08){_0x398d3c[_0x1435('0x42')][_0x1435('0x63')]({'id':0x0,'priority':0x1,'app':_0x1435('0x66'),'appdata':_0x15fd08[_0x1435('0x61')]+','+(_0x398d3c[_0x1435('0x39')][_0x1435('0x67')]||0x12c),'interval':_0x1435('0x4b')});}return respondWithRpcPromise(_0x1435('0x68'),_0x1435('0x69'),_0x398d3c);})['then'](function(_0x2a3f87){_0x36bc74(_0x2a3f87);})[_0x1435('0x1a')](function(_0x1f1acc){_0x186e7a(_0x516e44['error'](0x1f4,_0x1f1acc[_0x1435('0x17')]));});});};
\ No newline at end of file