Built motion from commit 1fa89557.|2.6.10
[motion2.git] / server / api / chatMessage / chatMessage.controller.js
index 2af49b0..4b37ce6 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x9a4a=['fullname','email','internal','interface','SIP/%s','motionChannel','channel','EventManager','acceptmessage','parse','agent','[CHATMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','role','RejectMessage','rejectMessage','event','rejectmessage','formData','eml-format','rimraf','fast-json-patch','moment','bluebird','util','sox','lodash','squel','crypto','desk.js','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/logger','api','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./chatMessage.socket','register','http','request','then','info','ChatMessage,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','sendStatus','status','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','destroy','end','stack','name','send','index','map','ChatMessage','rawAttributes','type','key','query','keys','intersection','model','fields','attributes','length','nolimit','order','sort','where','filters','filter','merge','options','include','findAll','rows','catch','show','params','find','create','body','describe','chat-interactions','accept','chat','read','readAt','format','YYYY-MM-DD\x20HH:mm:ss','UserId','user','get','ChatInteractionId','isNil','interaction','[CHATMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','null','AcceptMessage','acceptMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','ContactId','sequelize','Sequelize','QueryTypes','SELECT','contact','User'];(function(_0x560389,_0x2e440a){var _0x217c99=function(_0x123845){while(--_0x123845){_0x560389['push'](_0x560389['shift']());}};_0x217c99(++_0x2e440a);}(_0x9a4a,0x18f));var _0xa9a4=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x9a4a[_0x3dd15e];return _0x231fd0;};'use strict';var emlformat=require(_0xa9a4('0x0'));var rimraf=require(_0xa9a4('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xa9a4('0x2'));var rp=require('request-promise');var moment=require(_0xa9a4('0x3'));var BPromise=require(_0xa9a4('0x4'));var Mustache=require('mustache');var util=require(_0xa9a4('0x5'));var path=require('path');var sox=require(_0xa9a4('0x6'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xa9a4('0x7'));var squel=require(_0xa9a4('0x8'));var crypto=require(_0xa9a4('0x9'));var jsforce=require('jsforce');var deskjs=require(_0xa9a4('0xa'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0xa9a4('0xb'));var authService=require(_0xa9a4('0xc'));var qs=require(_0xa9a4('0xd'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0xa9a4('0xe'))(_0xa9a4('0xf'));var utils=require('../../config/utils');var config=require(_0xa9a4('0x10'));var licenseUtil=require('../../config/license/util');var db=require(_0xa9a4('0x11'))['db'];config[_0xa9a4('0x12')]=_[_0xa9a4('0x13')](config[_0xa9a4('0x12')],{'host':_0xa9a4('0x14'),'port':0x18eb});var socket=require(_0xa9a4('0x15'))(new Redis(config[_0xa9a4('0x12')]));require(_0xa9a4('0x16'))[_0xa9a4('0x17')](socket);var jayson=require('jayson/promise');var client=jayson['client']['http']({'port':0x232c});var client9002=jayson['client'][_0xa9a4('0x18')]({'port':0x232a});function respondWithRpcPromise(_0x44b292,_0x36f1fb,_0x27f565,_0x481757){return new BPromise(function(_0x3dd817,_0x351383){var _0x5a9d9e=_0x481757||client;return _0x5a9d9e[_0xa9a4('0x19')](_0x44b292,_0x27f565)[_0xa9a4('0x1a')](function(_0x2822a5){logger[_0xa9a4('0x1b')](_0xa9a4('0x1c'),_0x36f1fb,_0xa9a4('0x1d'));logger['debug']('ChatMessage,\x20%s,\x20%s,\x20%s',_0x36f1fb,_0xa9a4('0x1d'),JSON[_0xa9a4('0x1e')](_0x2822a5));if(_0x2822a5['error']){if(_0x2822a5[_0xa9a4('0x1f')][_0xa9a4('0x20')]===0x1f4){logger[_0xa9a4('0x1f')](_0xa9a4('0x1c'),_0x36f1fb,_0x2822a5[_0xa9a4('0x1f')][_0xa9a4('0x21')]);return _0x351383(_0x2822a5[_0xa9a4('0x1f')][_0xa9a4('0x21')]);}logger[_0xa9a4('0x1f')]('ChatMessage,\x20%s,\x20%s',_0x36f1fb,_0x2822a5[_0xa9a4('0x1f')][_0xa9a4('0x21')]);return _0x3dd817(_0x2822a5[_0xa9a4('0x1f')][_0xa9a4('0x21')]);}else{logger['info'](_0xa9a4('0x1c'),_0x36f1fb,_0xa9a4('0x1d'));_0x3dd817(_0x2822a5[_0xa9a4('0x22')][_0xa9a4('0x21')]);}})['catch'](function(_0x4173cd){logger[_0xa9a4('0x1f')](_0xa9a4('0x1c'),_0x36f1fb,_0x4173cd);_0x351383(_0x4173cd);});});}function respondWithStatusCode(_0x1f8369,_0x1a2c14){_0x1a2c14=_0x1a2c14||0xcc;return function(_0x44e910){if(_0x44e910){return _0x1f8369[_0xa9a4('0x23')](_0x1a2c14);}return _0x1f8369[_0xa9a4('0x24')](_0x1a2c14)['end']();};}function respondWithResult(_0x4c63f3,_0x103678){_0x103678=_0x103678||0xc8;return function(_0x78b145){if(_0x78b145){return _0x4c63f3[_0xa9a4('0x24')](_0x103678)[_0xa9a4('0x25')](_0x78b145);}};}function respondWithFilteredResult(_0x297104,_0x54e60d){return function(_0x567f45){if(_0x567f45){var _0x5634a9=typeof _0x54e60d[_0xa9a4('0x26')]===_0xa9a4('0x27')&&typeof _0x54e60d[_0xa9a4('0x28')]===_0xa9a4('0x27');var _0x599bcc=_0x567f45[_0xa9a4('0x29')];var _0x1b461e=_0x5634a9?0x0:_0x54e60d['offset'];var _0x92192e=_0x5634a9?_0x567f45['count']:_0x54e60d[_0xa9a4('0x26')]+_0x54e60d['limit'];var _0x96a00b;if(_0x92192e>=_0x599bcc){_0x92192e=_0x599bcc;_0x96a00b=0xc8;}else{_0x96a00b=0xce;}_0x297104[_0xa9a4('0x24')](_0x96a00b);return _0x297104[_0xa9a4('0x2a')](_0xa9a4('0x2b'),_0x1b461e+'-'+_0x92192e+'/'+_0x599bcc)['json'](_0x567f45);}return null;};}function patchUpdates(_0x2c0c8b){return function(_0x4ea02b){try{jsonpatch[_0xa9a4('0x2c')](_0x4ea02b,_0x2c0c8b,!![]);}catch(_0x45214b){return BPromise[_0xa9a4('0x2d')](_0x45214b);}return _0x4ea02b[_0xa9a4('0x2e')]();};}function saveUpdates(_0x1fd523,_0x154eff){return function(_0xac9678){if(_0xac9678){return _0xac9678[_0xa9a4('0x2f')](_0x1fd523)['then'](function(_0x4ca8a5){return _0x4ca8a5;});}return null;};}function removeEntity(_0xc7c7d1,_0x79692b){return function(_0x35a2f7){if(_0x35a2f7){return _0x35a2f7[_0xa9a4('0x30')]()[_0xa9a4('0x1a')](function(){_0xc7c7d1['status'](0xcc)[_0xa9a4('0x31')]();});}};}function handleEntityNotFound(_0x53b5d1,_0x3966f9){return function(_0x668d76){if(!_0x668d76){_0x53b5d1[_0xa9a4('0x23')](0x194);}return _0x668d76;};}function handleError(_0x2b15fb,_0x25ccc6){_0x25ccc6=_0x25ccc6||0x1f4;return function(_0x5e43c9){logger[_0xa9a4('0x1f')](_0x5e43c9[_0xa9a4('0x32')]);if(_0x5e43c9[_0xa9a4('0x33')]){delete _0x5e43c9[_0xa9a4('0x33')];}_0x2b15fb[_0xa9a4('0x24')](_0x25ccc6)[_0xa9a4('0x34')](_0x5e43c9);};}exports[_0xa9a4('0x35')]=function(_0x250da5,_0x151bb8){var _0x39610={},_0x165d82={},_0xdd581d={'count':0x0,'rows':[]};var _0x1a5a12=_[_0xa9a4('0x36')](db[_0xa9a4('0x37')][_0xa9a4('0x38')],function(_0x16569e){return{'name':_0x16569e['fieldName'],'type':_0x16569e[_0xa9a4('0x39')][_0xa9a4('0x3a')]};});_0x165d82['model']=_[_0xa9a4('0x36')](_0x1a5a12,_0xa9a4('0x33'));_0x165d82[_0xa9a4('0x3b')]=_[_0xa9a4('0x3c')](_0x250da5[_0xa9a4('0x3b')]);_0x165d82['filters']=_[_0xa9a4('0x3d')](_0x165d82[_0xa9a4('0x3e')],_0x165d82[_0xa9a4('0x3b')]);_0x39610['attributes']=_[_0xa9a4('0x3d')](_0x165d82['model'],qs['fields'](_0x250da5[_0xa9a4('0x3b')][_0xa9a4('0x3f')]));_0x39610['attributes']=_0x39610[_0xa9a4('0x40')][_0xa9a4('0x41')]?_0x39610[_0xa9a4('0x40')]:_0x165d82[_0xa9a4('0x3e')];if(!_0x250da5[_0xa9a4('0x3b')]['hasOwnProperty'](_0xa9a4('0x42'))){_0x39610[_0xa9a4('0x28')]=qs[_0xa9a4('0x28')](_0x250da5['query']['limit']);_0x39610[_0xa9a4('0x26')]=qs[_0xa9a4('0x26')](_0x250da5['query'][_0xa9a4('0x26')]);}_0x39610[_0xa9a4('0x43')]=qs[_0xa9a4('0x44')](_0x250da5[_0xa9a4('0x3b')][_0xa9a4('0x44')]);_0x39610[_0xa9a4('0x45')]=qs[_0xa9a4('0x46')](_['pick'](_0x250da5[_0xa9a4('0x3b')],_0x165d82[_0xa9a4('0x46')]),_0x1a5a12);if(_0x250da5[_0xa9a4('0x3b')][_0xa9a4('0x47')]){_0x39610[_0xa9a4('0x45')]=_[_0xa9a4('0x48')](_0x39610[_0xa9a4('0x45')],{'$or':_['map'](_0x1a5a12,function(_0x5b0c3e){if(_0x5b0c3e['type']!=='VIRTUAL'){var _0x33f4d3={};_0x33f4d3[_0x5b0c3e[_0xa9a4('0x33')]]={'$like':'%'+_0x250da5[_0xa9a4('0x3b')][_0xa9a4('0x47')]+'%'};return _0x33f4d3;}})});}_0x39610=_[_0xa9a4('0x48')]({},_0x39610,_0x250da5[_0xa9a4('0x49')]);var _0xb03670={'where':_0x39610['where']};return db['ChatMessage'][_0xa9a4('0x29')](_0xb03670)[_0xa9a4('0x1a')](function(_0x32df48){_0xdd581d[_0xa9a4('0x29')]=_0x32df48;if(_0x250da5[_0xa9a4('0x3b')]['includeAll']){_0x39610[_0xa9a4('0x4a')]=[{'all':!![]}];}return db[_0xa9a4('0x37')][_0xa9a4('0x4b')](_0x39610);})['then'](function(_0x4c41ef){_0xdd581d[_0xa9a4('0x4c')]=_0x4c41ef;return _0xdd581d;})[_0xa9a4('0x1a')](respondWithFilteredResult(_0x151bb8,_0x39610))[_0xa9a4('0x4d')](handleError(_0x151bb8,null));};exports[_0xa9a4('0x4e')]=function(_0xb47060,_0x463236){var _0x2c2965={'raw':!![],'where':{'id':_0xb47060[_0xa9a4('0x4f')]['id']}},_0x95a8da={};_0x95a8da[_0xa9a4('0x3e')]=_[_0xa9a4('0x3c')](db[_0xa9a4('0x37')]['rawAttributes']);_0x95a8da[_0xa9a4('0x3b')]=_['keys'](_0xb47060[_0xa9a4('0x3b')]);_0x95a8da['filters']=_[_0xa9a4('0x3d')](_0x95a8da[_0xa9a4('0x3e')],_0x95a8da[_0xa9a4('0x3b')]);_0x2c2965['attributes']=_[_0xa9a4('0x3d')](_0x95a8da['model'],qs['fields'](_0xb47060[_0xa9a4('0x3b')][_0xa9a4('0x3f')]));_0x2c2965[_0xa9a4('0x40')]=_0x2c2965[_0xa9a4('0x40')][_0xa9a4('0x41')]?_0x2c2965[_0xa9a4('0x40')]:_0x95a8da[_0xa9a4('0x3e')];if(_0xb47060[_0xa9a4('0x3b')]['includeAll']){_0x2c2965['include']=[{'all':!![]}];}_0x2c2965=_[_0xa9a4('0x48')]({},_0x2c2965,_0xb47060[_0xa9a4('0x49')]);return db['ChatMessage'][_0xa9a4('0x50')](_0x2c2965)[_0xa9a4('0x1a')](handleEntityNotFound(_0x463236,null))[_0xa9a4('0x1a')](respondWithResult(_0x463236,null))[_0xa9a4('0x4d')](handleError(_0x463236,null));};exports[_0xa9a4('0x51')]=function(_0x2448bf,_0x44a819){return db['ChatMessage'][_0xa9a4('0x51')](_0x2448bf[_0xa9a4('0x52')],{})[_0xa9a4('0x1a')](respondWithResult(_0x44a819,0xc9))[_0xa9a4('0x4d')](handleError(_0x44a819,null));};exports['update']=function(_0x404ed9,_0x266411){if(_0x404ed9['body']['id']){delete _0x404ed9[_0xa9a4('0x52')]['id'];}return db['ChatMessage'][_0xa9a4('0x50')]({'where':{'id':_0x404ed9[_0xa9a4('0x4f')]['id']}})[_0xa9a4('0x1a')](handleEntityNotFound(_0x266411,null))[_0xa9a4('0x1a')](saveUpdates(_0x404ed9[_0xa9a4('0x52')],null))[_0xa9a4('0x1a')](respondWithResult(_0x266411,null))[_0xa9a4('0x4d')](handleError(_0x266411,null));};exports[_0xa9a4('0x30')]=function(_0x2dc8c8,_0x5c1cef){return db[_0xa9a4('0x37')]['find']({'where':{'id':_0x2dc8c8['params']['id']}})[_0xa9a4('0x1a')](handleEntityNotFound(_0x5c1cef,null))[_0xa9a4('0x1a')](removeEntity(_0x5c1cef,null))['catch'](handleError(_0x5c1cef,null));};exports[_0xa9a4('0x53')]=function(_0x40e084,_0x43428d){return db[_0xa9a4('0x37')]['describe']()[_0xa9a4('0x1a')](respondWithResult(_0x43428d,null))[_0xa9a4('0x4d')](handleError(_0x43428d,null));};var interaction_log=require('../../config/logger')(_0xa9a4('0x54'));exports[_0xa9a4('0x55')]=function(_0x33e46c,_0x45188d,_0x392323){var _0x3551dc={'agent':{},'channel':_0xa9a4('0x56')};if(_0x33e46c[_0xa9a4('0x52')]['id']){delete _0x33e46c['body']['id'];}_0x33e46c['body'][_0xa9a4('0x57')]=!![];_0x33e46c[_0xa9a4('0x52')][_0xa9a4('0x58')]=moment()[_0xa9a4('0x59')](_0xa9a4('0x5a'));_0x33e46c['body']['UserId']=_0x33e46c[_0xa9a4('0x52')][_0xa9a4('0x5b')]||_0x33e46c[_0xa9a4('0x5c')]['id'];_0x3551dc['agent']['id']=_0x33e46c[_0xa9a4('0x52')][_0xa9a4('0x5b')];return db[_0xa9a4('0x37')]['find']({'where':{'id':_0x33e46c['params']['id'],'UserId':null}})['then'](handleEntityNotFound(_0x45188d,null))['then'](saveUpdates(_0x33e46c[_0xa9a4('0x52')],null))[_0xa9a4('0x1a')](function(_0x3f0021){if(_0x3f0021){_0x3551dc[_0xa9a4('0x21')]=_0x3f0021[_0xa9a4('0x5d')]({'plain':!![]});return db['ChatInteraction'][_0xa9a4('0x50')]({'where':{'id':_0x3f0021[_0xa9a4('0x5e')]}});}return null;})[_0xa9a4('0x1a')](handleEntityNotFound(_0x45188d,null))['then'](function(_0x53fa74){if(_0x53fa74){return _0x53fa74[_0xa9a4('0x2f')]({'UserId':_0x33e46c['body']['UserId'],'read1stAt':_[_0xa9a4('0x5f')](_0x53fa74['read1stAt'])?moment()[_0xa9a4('0x59')](_0xa9a4('0x5a')):undefined});}return null;})['then'](function(_0x26fa79){if(_0x26fa79){_0x3551dc[_0xa9a4('0x60')]=_0x26fa79['get']({'plain':!![]});interaction_log['info'](_0xa9a4('0x61'),_0x33e46c[_0xa9a4('0x5c')]['id'],_0x33e46c[_0xa9a4('0x5c')][_0xa9a4('0x33')],_0x33e46c['user']['role'],_0x3551dc[_0xa9a4('0x60')]['id'],_0x33e46c[_0xa9a4('0x52')]?JSON[_0xa9a4('0x1e')](_0x33e46c[_0xa9a4('0x52')]):_0xa9a4('0x62'));return respondWithRpcPromise(_0xa9a4('0x63'),_0xa9a4('0x64'),_0x3551dc);}return null;})[_0xa9a4('0x1a')](function(_0x11088f){var _0x2593e8=_0xa9a4('0x65')+_0x11088f['message'][_0xa9a4('0x66')];return db[_0xa9a4('0x67')][_0xa9a4('0x3b')](_0x2593e8,{'type':db[_0xa9a4('0x68')][_0xa9a4('0x69')][_0xa9a4('0x6a')],'raw':!![]})['then'](function(_0x56a47d){return _0x56a47d;});})[_0xa9a4('0x1a')](function(_0x3497c8){if(_0x3497c8){_0x3551dc[_0xa9a4('0x21')][_0xa9a4('0x6b')]=_0x3497c8[0x0];if(!_0x33e46c[_0xa9a4('0x52')][_0xa9a4('0x5b')])return;return db[_0xa9a4('0x6c')][_0xa9a4('0x50')]({'where':{'id':_0x33e46c[_0xa9a4('0x52')][_0xa9a4('0x5b')],'role':'agent'},'attributes':['id',_0xa9a4('0x33'),_0xa9a4('0x6d'),_0xa9a4('0x6e'),_0xa9a4('0x6f')],'raw':!![]});}return null;})['then'](function(_0x45a9e0){if(!_0x45a9e0)return null;_0x3551dc['message']['agent']=_0x45a9e0;return _0x3551dc;})['then'](function(_0x340072){if(_0x340072){if(_0x33e46c[_0xa9a4('0x52')]['manual']){_0x3551dc[_0xa9a4('0x21')][_0xa9a4('0x70')]=util[_0xa9a4('0x59')](_0xa9a4('0x71'),_0x33e46c[_0xa9a4('0x5c')]['name']);_0x3551dc[_0xa9a4('0x21')]['channel']=_0x3551dc['channel'];_0x3551dc[_0xa9a4('0x21')][_0xa9a4('0x72')]=_0x3551dc[_0xa9a4('0x73')];_0x3551dc[_0xa9a4('0x21')]['event']=_0xa9a4('0x55');return respondWithRpcPromise(_0xa9a4('0x74'),_0xa9a4('0x74'),{'event':_0xa9a4('0x75'),'message':_[_0xa9a4('0x48')](_0x3551dc[_0xa9a4('0x21')],JSON[_0xa9a4('0x76')](_0x3551dc[_0xa9a4('0x60')]['formData']))},client9002)[_0xa9a4('0x1a')](function(){return _0x3551dc;});}return _0x3551dc;}return null;})[_0xa9a4('0x1a')](respondWithResult(_0x45188d,null))[_0xa9a4('0x4d')](handleError(_0x45188d,null));};var interaction_log=require(_0xa9a4('0xe'))(_0xa9a4('0x54'));exports[_0xa9a4('0x2d')]=function(_0x540b8d,_0x5395c9,_0x52bb91){var _0x5c4d43={'agent':{},'channel':_0xa9a4('0x56')};if(_0x540b8d[_0xa9a4('0x52')]['id']){delete _0x540b8d['body']['id'];}_0x540b8d[_0xa9a4('0x52')][_0xa9a4('0x5b')]=_0x540b8d[_0xa9a4('0x52')][_0xa9a4('0x5b')]||_0x540b8d[_0xa9a4('0x5c')]['id'];_0x5c4d43[_0xa9a4('0x77')]['id']=_0x540b8d[_0xa9a4('0x52')][_0xa9a4('0x5b')];return db[_0xa9a4('0x37')][_0xa9a4('0x50')]({'where':{'id':_0x540b8d['params']['id'],'UserId':null}})[_0xa9a4('0x1a')](handleEntityNotFound(_0x5395c9,null))[_0xa9a4('0x1a')](function(_0x7b2891){if(_0x7b2891){_0x5c4d43['message']=_0x7b2891[_0xa9a4('0x5d')]({'plain':!![]});return db['ChatInteraction'][_0xa9a4('0x50')]({'where':{'id':_0x7b2891[_0xa9a4('0x5e')]}});}return null;})[_0xa9a4('0x1a')](handleEntityNotFound(_0x5395c9,null))[_0xa9a4('0x1a')](function(_0x57fb9f){if(_0x57fb9f){_0x5c4d43[_0xa9a4('0x60')]=_0x57fb9f['get']({'plain':!![]});interaction_log[_0xa9a4('0x1b')](_0xa9a4('0x78'),_0x540b8d[_0xa9a4('0x5c')]['id'],_0x540b8d['user'][_0xa9a4('0x33')],_0x540b8d['user'][_0xa9a4('0x79')],_0x5c4d43['interaction']['id'],_0x540b8d[_0xa9a4('0x52')]?JSON[_0xa9a4('0x1e')](_0x540b8d[_0xa9a4('0x52')]):_0xa9a4('0x62'));return respondWithRpcPromise(_0xa9a4('0x7a'),_0xa9a4('0x7b'),_0x5c4d43);}return null;})['then'](function(_0x168fc0){var _0x141019='SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20'+_0x168fc0[_0xa9a4('0x21')][_0xa9a4('0x66')];return db[_0xa9a4('0x67')][_0xa9a4('0x3b')](_0x141019,{'type':db[_0xa9a4('0x68')]['QueryTypes'][_0xa9a4('0x6a')],'raw':!![]})['then'](function(_0x1c34a2){return _0x1c34a2;});})[_0xa9a4('0x1a')](function(_0x358187){if(_0x358187){_0x5c4d43[_0xa9a4('0x21')]['contact']=_0x358187[0x0];if(!_0x540b8d[_0xa9a4('0x52')][_0xa9a4('0x5b')])return;return db['User']['find']({'where':{'id':_0x540b8d[_0xa9a4('0x52')][_0xa9a4('0x5b')],'role':_0xa9a4('0x77')},'attributes':['id',_0xa9a4('0x33'),_0xa9a4('0x6d'),_0xa9a4('0x6e'),'internal'],'raw':!![]});}return null;})[_0xa9a4('0x1a')](function(_0x43a2c7){if(!_0x43a2c7)return null;_0x5c4d43[_0xa9a4('0x21')][_0xa9a4('0x77')]=_0x43a2c7;return _0x5c4d43;})['then'](function(_0x4b6c06){if(_0x4b6c06){_0x4b6c06['message']['interface']=util['format'](_0xa9a4('0x71'),_0x540b8d['user'][_0xa9a4('0x33')]);_0x4b6c06[_0xa9a4('0x21')]['channel']=_0x5c4d43['channel'];_0x4b6c06[_0xa9a4('0x21')][_0xa9a4('0x72')]=_0x5c4d43[_0xa9a4('0x73')];_0x4b6c06[_0xa9a4('0x21')][_0xa9a4('0x7c')]=_0xa9a4('0x2d');respondWithRpcPromise(_0xa9a4('0x74'),_0xa9a4('0x74'),{'event':_0xa9a4('0x7d'),'message':_[_0xa9a4('0x48')](_0x5c4d43[_0xa9a4('0x21')],JSON[_0xa9a4('0x76')](_0x5c4d43['interaction'][_0xa9a4('0x7e')]))},client9002);return _0x5c4d43;}return null;})[_0xa9a4('0x1a')](respondWithResult(_0x5395c9,null))['catch'](handleError(_0x5395c9,null));};
\ No newline at end of file
+var _0xce13=['register','jayson/promise','client','http','request','then','info','request\x20sent','debug','ChatMessage,\x20%s,\x20%s,\x20%s','stringify','error','ChatMessage,\x20%s,\x20%s','message','result','catch','sendStatus','status','offset','undefined','count','limit','Content-Range','json','apply','reject','save','update','destroy','stack','send','index','map','ChatMessage','rawAttributes','fieldName','type','key','model','name','query','keys','filters','attributes','intersection','fields','hasOwnProperty','nolimit','order','sort','where','filter','merge','VIRTUAL','options','includeAll','include','findAll','params','length','create','body','find','describe','chat','read','YYYY-MM-DD\x20HH:mm:ss','UserId','user','agent','get','ChatInteraction','isNil','read1stAt','interaction','[CHATMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','null','acceptMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','sequelize','Sequelize','SELECT','contact','User','internal','manual','channel','motionChannel','event','accept','EventManager','acceptmessage','[CHATMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','role','RejectMessage','ContactId','QueryTypes','fullname','email','rejectmessage','parse','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','path','to-csv','ejs','fs-extra','lodash','crypto','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/license/util','redis','socket.io-emitter','./chatMessage.socket'];(function(_0x486f4a,_0x478dc7){var _0x135d99=function(_0x434008){while(--_0x434008){_0x486f4a['push'](_0x486f4a['shift']());}};_0x135d99(++_0x478dc7);}(_0xce13,0xe3));var _0x3ce1=function(_0x195723,_0x1c0d7b){_0x195723=_0x195723-0x0;var _0x271c4b=_0xce13[_0x195723];return _0x271c4b;};'use strict';var emlformat=require(_0x3ce1('0x0'));var rimraf=require(_0x3ce1('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x3ce1('0x2'));var rp=require(_0x3ce1('0x3'));var moment=require(_0x3ce1('0x4'));var BPromise=require(_0x3ce1('0x5'));var Mustache=require(_0x3ce1('0x6'));var util=require('util');var path=require(_0x3ce1('0x7'));var sox=require('sox');var csv=require(_0x3ce1('0x8'));var ejs=require(_0x3ce1('0x9'));var fs=require('fs');var fs_extra=require(_0x3ce1('0xa'));var _=require(_0x3ce1('0xb'));var squel=require('squel');var crypto=require(_0x3ce1('0xc'));var jsforce=require('jsforce');var deskjs=require(_0x3ce1('0xd'));var toCsv=require(_0x3ce1('0x8'));var querystring=require('querystring');var Papa=require(_0x3ce1('0xe'));var Redis=require(_0x3ce1('0xf'));var authService=require(_0x3ce1('0x10'));var qs=require(_0x3ce1('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x3ce1('0x12'));var logger=require(_0x3ce1('0x13'))(_0x3ce1('0x14'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x3ce1('0x15'));var db=require('../../mysqldb')['db'];config['redis']=_['defaults'](config[_0x3ce1('0x16')],{'host':'localhost','port':0x18eb});var socket=require(_0x3ce1('0x17'))(new Redis(config[_0x3ce1('0x16')]));require(_0x3ce1('0x18'))[_0x3ce1('0x19')](socket);var jayson=require(_0x3ce1('0x1a'));var client=jayson[_0x3ce1('0x1b')]['http']({'port':0x232c});var client9002=jayson[_0x3ce1('0x1b')][_0x3ce1('0x1c')]({'port':0x232a});function respondWithRpcPromise(_0x266ed1,_0x78504c,_0xcb2096,_0x381d39){return new BPromise(function(_0xf3170b,_0x358c0b){var _0x47b9b2=_0x381d39||client;return _0x47b9b2[_0x3ce1('0x1d')](_0x266ed1,_0xcb2096)[_0x3ce1('0x1e')](function(_0x50f840){logger[_0x3ce1('0x1f')]('ChatMessage,\x20%s,\x20%s',_0x78504c,_0x3ce1('0x20'));logger[_0x3ce1('0x21')](_0x3ce1('0x22'),_0x78504c,_0x3ce1('0x20'),JSON[_0x3ce1('0x23')](_0x50f840));if(_0x50f840[_0x3ce1('0x24')]){if(_0x50f840[_0x3ce1('0x24')]['code']===0x1f4){logger['error']('ChatMessage,\x20%s,\x20%s',_0x78504c,_0x50f840['error']['message']);return _0x358c0b(_0x50f840['error']['message']);}logger[_0x3ce1('0x24')](_0x3ce1('0x25'),_0x78504c,_0x50f840[_0x3ce1('0x24')][_0x3ce1('0x26')]);return _0xf3170b(_0x50f840[_0x3ce1('0x24')][_0x3ce1('0x26')]);}else{logger[_0x3ce1('0x1f')](_0x3ce1('0x25'),_0x78504c,_0x3ce1('0x20'));_0xf3170b(_0x50f840[_0x3ce1('0x27')]['message']);}})[_0x3ce1('0x28')](function(_0x1fc0f0){logger['error'](_0x3ce1('0x25'),_0x78504c,_0x1fc0f0);_0x358c0b(_0x1fc0f0);});});}function respondWithStatusCode(_0x42afb5,_0x33dddc){_0x33dddc=_0x33dddc||0xcc;return function(_0x32697c){if(_0x32697c){return _0x42afb5[_0x3ce1('0x29')](_0x33dddc);}return _0x42afb5[_0x3ce1('0x2a')](_0x33dddc)['end']();};}function respondWithResult(_0x57b5c4,_0x54db38){_0x54db38=_0x54db38||0xc8;return function(_0x21fe12){if(_0x21fe12){return _0x57b5c4['status'](_0x54db38)['json'](_0x21fe12);}};}function respondWithFilteredResult(_0x53aa1,_0x5c61c9){return function(_0x3e2dba){if(_0x3e2dba){var _0x327a77=typeof _0x5c61c9[_0x3ce1('0x2b')]===_0x3ce1('0x2c')&&typeof _0x5c61c9['limit']===_0x3ce1('0x2c');var _0x479086=_0x3e2dba[_0x3ce1('0x2d')];var _0x532f4b=_0x327a77?0x0:_0x5c61c9['offset'];var _0x3e96af=_0x327a77?_0x3e2dba[_0x3ce1('0x2d')]:_0x5c61c9[_0x3ce1('0x2b')]+_0x5c61c9[_0x3ce1('0x2e')];var _0x507f0a;if(_0x3e96af>=_0x479086){_0x3e96af=_0x479086;_0x507f0a=0xc8;}else{_0x507f0a=0xce;}_0x53aa1['status'](_0x507f0a);return _0x53aa1['set'](_0x3ce1('0x2f'),_0x532f4b+'-'+_0x3e96af+'/'+_0x479086)[_0x3ce1('0x30')](_0x3e2dba);}return null;};}function patchUpdates(_0x2bf4e5){return function(_0x5e6a4e){try{jsonpatch[_0x3ce1('0x31')](_0x5e6a4e,_0x2bf4e5,!![]);}catch(_0x310615){return BPromise[_0x3ce1('0x32')](_0x310615);}return _0x5e6a4e[_0x3ce1('0x33')]();};}function saveUpdates(_0x1eb000,_0x3513dd){return function(_0x154a7a){if(_0x154a7a){return _0x154a7a[_0x3ce1('0x34')](_0x1eb000)[_0x3ce1('0x1e')](function(_0x53a7ab){return _0x53a7ab;});}return null;};}function removeEntity(_0x5d8fa6,_0x37d8c6){return function(_0xe3aea4){if(_0xe3aea4){return _0xe3aea4[_0x3ce1('0x35')]()[_0x3ce1('0x1e')](function(){_0x5d8fa6[_0x3ce1('0x2a')](0xcc)['end']();});}};}function handleEntityNotFound(_0x532ef7,_0x9b3268){return function(_0x2ee8a0){if(!_0x2ee8a0){_0x532ef7[_0x3ce1('0x29')](0x194);}return _0x2ee8a0;};}function handleError(_0xb87344,_0x2a1ab6){_0x2a1ab6=_0x2a1ab6||0x1f4;return function(_0x26a608){logger[_0x3ce1('0x24')](_0x26a608[_0x3ce1('0x36')]);if(_0x26a608['name']){delete _0x26a608['name'];}_0xb87344[_0x3ce1('0x2a')](_0x2a1ab6)[_0x3ce1('0x37')](_0x26a608);};}exports[_0x3ce1('0x38')]=function(_0x75d92f,_0x457c14){var _0x1e0055={},_0x160e72={},_0x3f4caa={'count':0x0,'rows':[]};var _0x2be0d3=_[_0x3ce1('0x39')](db[_0x3ce1('0x3a')][_0x3ce1('0x3b')],function(_0x3b166d){return{'name':_0x3b166d[_0x3ce1('0x3c')],'type':_0x3b166d[_0x3ce1('0x3d')][_0x3ce1('0x3e')]};});_0x160e72[_0x3ce1('0x3f')]=_[_0x3ce1('0x39')](_0x2be0d3,_0x3ce1('0x40'));_0x160e72[_0x3ce1('0x41')]=_[_0x3ce1('0x42')](_0x75d92f['query']);_0x160e72[_0x3ce1('0x43')]=_['intersection'](_0x160e72[_0x3ce1('0x3f')],_0x160e72['query']);_0x1e0055[_0x3ce1('0x44')]=_[_0x3ce1('0x45')](_0x160e72['model'],qs[_0x3ce1('0x46')](_0x75d92f[_0x3ce1('0x41')][_0x3ce1('0x46')]));_0x1e0055[_0x3ce1('0x44')]=_0x1e0055[_0x3ce1('0x44')]['length']?_0x1e0055['attributes']:_0x160e72[_0x3ce1('0x3f')];if(!_0x75d92f[_0x3ce1('0x41')][_0x3ce1('0x47')](_0x3ce1('0x48'))){_0x1e0055['limit']=qs['limit'](_0x75d92f['query']['limit']);_0x1e0055[_0x3ce1('0x2b')]=qs[_0x3ce1('0x2b')](_0x75d92f[_0x3ce1('0x41')]['offset']);}_0x1e0055[_0x3ce1('0x49')]=qs['sort'](_0x75d92f[_0x3ce1('0x41')][_0x3ce1('0x4a')]);_0x1e0055[_0x3ce1('0x4b')]=qs['filters'](_['pick'](_0x75d92f[_0x3ce1('0x41')],_0x160e72[_0x3ce1('0x43')]),_0x2be0d3);if(_0x75d92f[_0x3ce1('0x41')][_0x3ce1('0x4c')]){_0x1e0055['where']=_[_0x3ce1('0x4d')](_0x1e0055['where'],{'$or':_[_0x3ce1('0x39')](_0x2be0d3,function(_0x4b0a9d){if(_0x4b0a9d[_0x3ce1('0x3d')]!==_0x3ce1('0x4e')){var _0x514b46={};_0x514b46[_0x4b0a9d[_0x3ce1('0x40')]]={'$like':'%'+_0x75d92f[_0x3ce1('0x41')][_0x3ce1('0x4c')]+'%'};return _0x514b46;}})});}_0x1e0055=_['merge']({},_0x1e0055,_0x75d92f[_0x3ce1('0x4f')]);var _0x984314={'where':_0x1e0055[_0x3ce1('0x4b')]};return db[_0x3ce1('0x3a')][_0x3ce1('0x2d')](_0x984314)[_0x3ce1('0x1e')](function(_0x33ddc0){_0x3f4caa[_0x3ce1('0x2d')]=_0x33ddc0;if(_0x75d92f['query'][_0x3ce1('0x50')]){_0x1e0055[_0x3ce1('0x51')]=[{'all':!![]}];}return db[_0x3ce1('0x3a')][_0x3ce1('0x52')](_0x1e0055);})[_0x3ce1('0x1e')](function(_0x5526da){_0x3f4caa['rows']=_0x5526da;return _0x3f4caa;})[_0x3ce1('0x1e')](respondWithFilteredResult(_0x457c14,_0x1e0055))[_0x3ce1('0x28')](handleError(_0x457c14,null));};exports['show']=function(_0x206805,_0x4d57c2){var _0x43354e={'raw':!![],'where':{'id':_0x206805[_0x3ce1('0x53')]['id']}},_0x17c99b={};_0x17c99b[_0x3ce1('0x3f')]=_['keys'](db[_0x3ce1('0x3a')][_0x3ce1('0x3b')]);_0x17c99b[_0x3ce1('0x41')]=_[_0x3ce1('0x42')](_0x206805['query']);_0x17c99b[_0x3ce1('0x43')]=_['intersection'](_0x17c99b[_0x3ce1('0x3f')],_0x17c99b['query']);_0x43354e[_0x3ce1('0x44')]=_[_0x3ce1('0x45')](_0x17c99b[_0x3ce1('0x3f')],qs['fields'](_0x206805['query']['fields']));_0x43354e[_0x3ce1('0x44')]=_0x43354e['attributes'][_0x3ce1('0x54')]?_0x43354e[_0x3ce1('0x44')]:_0x17c99b['model'];if(_0x206805[_0x3ce1('0x41')]['includeAll']){_0x43354e[_0x3ce1('0x51')]=[{'all':!![]}];}_0x43354e=_[_0x3ce1('0x4d')]({},_0x43354e,_0x206805[_0x3ce1('0x4f')]);return db['ChatMessage']['find'](_0x43354e)[_0x3ce1('0x1e')](handleEntityNotFound(_0x4d57c2,null))[_0x3ce1('0x1e')](respondWithResult(_0x4d57c2,null))['catch'](handleError(_0x4d57c2,null));};exports[_0x3ce1('0x55')]=function(_0x540d6a,_0x15e0be){return db[_0x3ce1('0x3a')][_0x3ce1('0x55')](_0x540d6a['body'],{})[_0x3ce1('0x1e')](respondWithResult(_0x15e0be,0xc9))[_0x3ce1('0x28')](handleError(_0x15e0be,null));};exports['update']=function(_0x47ac87,_0x4c0095){if(_0x47ac87['body']['id']){delete _0x47ac87[_0x3ce1('0x56')]['id'];}return db[_0x3ce1('0x3a')][_0x3ce1('0x57')]({'where':{'id':_0x47ac87[_0x3ce1('0x53')]['id']}})[_0x3ce1('0x1e')](handleEntityNotFound(_0x4c0095,null))[_0x3ce1('0x1e')](saveUpdates(_0x47ac87['body'],null))['then'](respondWithResult(_0x4c0095,null))[_0x3ce1('0x28')](handleError(_0x4c0095,null));};exports[_0x3ce1('0x35')]=function(_0x410d1a,_0x34b2af){return db[_0x3ce1('0x3a')][_0x3ce1('0x57')]({'where':{'id':_0x410d1a[_0x3ce1('0x53')]['id']}})[_0x3ce1('0x1e')](handleEntityNotFound(_0x34b2af,null))[_0x3ce1('0x1e')](removeEntity(_0x34b2af,null))['catch'](handleError(_0x34b2af,null));};exports[_0x3ce1('0x58')]=function(_0x3d8e87,_0x3e3afb){return db['ChatMessage']['describe']()[_0x3ce1('0x1e')](respondWithResult(_0x3e3afb,null))['catch'](handleError(_0x3e3afb,null));};var interaction_log=require(_0x3ce1('0x13'))('chat-interactions');exports['accept']=function(_0x1013aa,_0x23a82a,_0x5138f6){var _0x594d52={'agent':{},'channel':_0x3ce1('0x59')};if(_0x1013aa[_0x3ce1('0x56')]['id']){delete _0x1013aa[_0x3ce1('0x56')]['id'];}_0x1013aa[_0x3ce1('0x56')][_0x3ce1('0x5a')]=!![];_0x1013aa[_0x3ce1('0x56')]['readAt']=moment()['format'](_0x3ce1('0x5b'));_0x1013aa['body']['UserId']=_0x1013aa[_0x3ce1('0x56')][_0x3ce1('0x5c')]||_0x1013aa[_0x3ce1('0x5d')]['id'];_0x594d52[_0x3ce1('0x5e')]['id']=_0x1013aa['body'][_0x3ce1('0x5c')];return db[_0x3ce1('0x3a')][_0x3ce1('0x57')]({'where':{'id':_0x1013aa['params']['id'],'UserId':null}})['then'](handleEntityNotFound(_0x23a82a,null))[_0x3ce1('0x1e')](saveUpdates(_0x1013aa['body'],null))[_0x3ce1('0x1e')](function(_0x4412ae){if(_0x4412ae){_0x594d52['message']=_0x4412ae[_0x3ce1('0x5f')]({'plain':!![]});return db[_0x3ce1('0x60')][_0x3ce1('0x57')]({'where':{'id':_0x4412ae['ChatInteractionId']}});}return null;})[_0x3ce1('0x1e')](handleEntityNotFound(_0x23a82a,null))[_0x3ce1('0x1e')](function(_0x2971e2){if(_0x2971e2){return _0x2971e2[_0x3ce1('0x34')]({'UserId':_0x1013aa[_0x3ce1('0x56')][_0x3ce1('0x5c')],'read1stAt':_[_0x3ce1('0x61')](_0x2971e2[_0x3ce1('0x62')])?moment()['format'](_0x3ce1('0x5b')):undefined});}return null;})[_0x3ce1('0x1e')](function(_0x4a743a){if(_0x4a743a){_0x594d52[_0x3ce1('0x63')]=_0x4a743a[_0x3ce1('0x5f')]({'plain':!![]});interaction_log['info'](_0x3ce1('0x64'),_0x1013aa[_0x3ce1('0x5d')]['id'],_0x1013aa[_0x3ce1('0x5d')]['name'],_0x1013aa[_0x3ce1('0x5d')]['role'],_0x594d52[_0x3ce1('0x63')]['id'],_0x1013aa[_0x3ce1('0x56')]?JSON[_0x3ce1('0x23')](_0x1013aa[_0x3ce1('0x56')]):_0x3ce1('0x65'));return respondWithRpcPromise('AcceptMessage',_0x3ce1('0x66'),_0x594d52);}return null;})['then'](function(_0x3e8791){var _0x30dbfb=_0x3ce1('0x67')+_0x3e8791[_0x3ce1('0x26')]['ContactId'];return db[_0x3ce1('0x68')][_0x3ce1('0x41')](_0x30dbfb,{'type':db[_0x3ce1('0x69')]['QueryTypes'][_0x3ce1('0x6a')],'raw':!![]})[_0x3ce1('0x1e')](function(_0x12add2){return _0x12add2;});})[_0x3ce1('0x1e')](function(_0x3444e2){if(_0x3444e2){_0x594d52[_0x3ce1('0x26')][_0x3ce1('0x6b')]=_0x3444e2[0x0];if(!_0x1013aa[_0x3ce1('0x56')][_0x3ce1('0x5c')])return;return db[_0x3ce1('0x6c')][_0x3ce1('0x57')]({'where':{'id':_0x1013aa[_0x3ce1('0x56')][_0x3ce1('0x5c')],'role':'agent'},'attributes':['id','name','fullname','email',_0x3ce1('0x6d')],'raw':!![]});}return null;})['then'](function(_0x2c98e4){if(!_0x2c98e4)return null;_0x594d52['message'][_0x3ce1('0x5e')]=_0x2c98e4;return _0x594d52;})[_0x3ce1('0x1e')](function(_0xeb1996){if(_0xeb1996){if(_0x1013aa[_0x3ce1('0x56')][_0x3ce1('0x6e')]){_0x594d52['message']['interface']=util['format']('SIP/%s',_0x1013aa[_0x3ce1('0x5d')]['name']);_0x594d52[_0x3ce1('0x26')][_0x3ce1('0x6f')]=_0x594d52['channel'];_0x594d52[_0x3ce1('0x26')][_0x3ce1('0x70')]=_0x594d52[_0x3ce1('0x6f')];_0x594d52[_0x3ce1('0x26')][_0x3ce1('0x71')]=_0x3ce1('0x72');return respondWithRpcPromise(_0x3ce1('0x73'),_0x3ce1('0x73'),{'event':_0x3ce1('0x74'),'message':_[_0x3ce1('0x4d')](_0x594d52[_0x3ce1('0x26')],JSON['parse'](_0x594d52[_0x3ce1('0x63')]['formData']))},client9002)['then'](function(){return _0x594d52;});}return _0x594d52;}return null;})['then'](respondWithResult(_0x23a82a,null))['catch'](handleError(_0x23a82a,null));};var interaction_log=require(_0x3ce1('0x13'))('chat-interactions');exports[_0x3ce1('0x32')]=function(_0x365595,_0x573433,_0x4f91a7){var _0x42999f={'agent':{},'channel':'chat'};if(_0x365595[_0x3ce1('0x56')]['id']){delete _0x365595[_0x3ce1('0x56')]['id'];}_0x365595[_0x3ce1('0x56')]['UserId']=_0x365595[_0x3ce1('0x56')]['UserId']||_0x365595[_0x3ce1('0x5d')]['id'];_0x42999f['agent']['id']=_0x365595['body'][_0x3ce1('0x5c')];return db[_0x3ce1('0x3a')][_0x3ce1('0x57')]({'where':{'id':_0x365595[_0x3ce1('0x53')]['id'],'UserId':null}})['then'](handleEntityNotFound(_0x573433,null))[_0x3ce1('0x1e')](function(_0x181aeb){if(_0x181aeb){_0x42999f[_0x3ce1('0x26')]=_0x181aeb[_0x3ce1('0x5f')]({'plain':!![]});return db[_0x3ce1('0x60')][_0x3ce1('0x57')]({'where':{'id':_0x181aeb['ChatInteractionId']}});}return null;})[_0x3ce1('0x1e')](handleEntityNotFound(_0x573433,null))[_0x3ce1('0x1e')](function(_0x4a0aef){if(_0x4a0aef){_0x42999f[_0x3ce1('0x63')]=_0x4a0aef[_0x3ce1('0x5f')]({'plain':!![]});interaction_log['info'](_0x3ce1('0x75'),_0x365595[_0x3ce1('0x5d')]['id'],_0x365595[_0x3ce1('0x5d')][_0x3ce1('0x40')],_0x365595[_0x3ce1('0x5d')][_0x3ce1('0x76')],_0x42999f[_0x3ce1('0x63')]['id'],_0x365595[_0x3ce1('0x56')]?JSON[_0x3ce1('0x23')](_0x365595[_0x3ce1('0x56')]):_0x3ce1('0x65'));return respondWithRpcPromise(_0x3ce1('0x77'),'rejectMessage',_0x42999f);}return null;})[_0x3ce1('0x1e')](function(_0x57cb88){var _0xc7013d=_0x3ce1('0x67')+_0x57cb88[_0x3ce1('0x26')][_0x3ce1('0x78')];return db[_0x3ce1('0x68')][_0x3ce1('0x41')](_0xc7013d,{'type':db['Sequelize'][_0x3ce1('0x79')][_0x3ce1('0x6a')],'raw':!![]})[_0x3ce1('0x1e')](function(_0x458079){return _0x458079;});})[_0x3ce1('0x1e')](function(_0x2eea32){if(_0x2eea32){_0x42999f['message'][_0x3ce1('0x6b')]=_0x2eea32[0x0];if(!_0x365595['body']['UserId'])return;return db[_0x3ce1('0x6c')][_0x3ce1('0x57')]({'where':{'id':_0x365595[_0x3ce1('0x56')][_0x3ce1('0x5c')],'role':_0x3ce1('0x5e')},'attributes':['id',_0x3ce1('0x40'),_0x3ce1('0x7a'),_0x3ce1('0x7b'),_0x3ce1('0x6d')],'raw':!![]});}return null;})[_0x3ce1('0x1e')](function(_0x1af494){if(!_0x1af494)return null;_0x42999f[_0x3ce1('0x26')][_0x3ce1('0x5e')]=_0x1af494;return _0x42999f;})[_0x3ce1('0x1e')](function(_0x562ca3){if(_0x562ca3){_0x562ca3['message']['interface']=util['format']('SIP/%s',_0x365595[_0x3ce1('0x5d')][_0x3ce1('0x40')]);_0x562ca3[_0x3ce1('0x26')][_0x3ce1('0x6f')]=_0x42999f['channel'];_0x562ca3[_0x3ce1('0x26')]['motionChannel']=_0x42999f[_0x3ce1('0x6f')];_0x562ca3[_0x3ce1('0x26')][_0x3ce1('0x71')]=_0x3ce1('0x32');respondWithRpcPromise(_0x3ce1('0x73'),_0x3ce1('0x73'),{'event':_0x3ce1('0x7c'),'message':_[_0x3ce1('0x4d')](_0x42999f[_0x3ce1('0x26')],JSON[_0x3ce1('0x7d')](_0x42999f[_0x3ce1('0x63')]['formData']))},client9002);return _0x42999f;}return null;})[_0x3ce1('0x1e')](respondWithResult(_0x573433,null))[_0x3ce1('0x28')](handleError(_0x573433,null));};
\ No newline at end of file