Built motion from commit b0a9a629.|2.6.33
[motion2.git] / server / api / chatMessage / chatMessage.controller.js
index 62dbf2b..8bca6a4 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x638f=['sox','to-csv','ejs','lodash','crypto','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../mysqldb','redis','localhost','./chatMessage.socket','register','jayson/promise','client','http','ChatMessage,\x20%s,\x20%s','request\x20sent','debug','ChatMessage,\x20%s,\x20%s,\x20%s','error','code','message','info','result','catch','sendStatus','end','status','count','offset','limit','Content-Range','apply','reject','save','destroy','then','stack','name','send','index','ChatMessage','rawAttributes','fieldName','type','key','model','map','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','pick','where','merge','VIRTUAL','filter','options','includeAll','include','findAll','rows','params','find','create','body','update','describe','accept','read','readAt','format','YYYY-MM-DD\x20HH:mm:ss','user','agent','CmContact','get','ChatInteractionId','UserId','read1stAt','interaction','stringify','null','acceptMessage','manual','interface','SIP/%s','channel','event','EventManager','acceptmessage','parse','formData','chat-interactions','chat','ChatInteraction','html-pdf','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util'];(function(_0x389cda,_0x31155c){var _0x5889bc=function(_0x32f473){while(--_0x32f473){_0x389cda['push'](_0x389cda['shift']());}};_0x5889bc(++_0x31155c);}(_0x638f,0xe5));var _0xf638=function(_0xabca41,_0xbfdf4a){_0xabca41=_0xabca41-0x0;var _0x404ccb=_0x638f[_0xabca41];return _0x404ccb;};'use strict';var pdf=require(_0xf638('0x0'));var emlformat=require(_0xf638('0x1'));var rimraf=require(_0xf638('0x2'));var zipdir=require(_0xf638('0x3'));var jsonpatch=require('fast-json-patch');var rp=require(_0xf638('0x4'));var moment=require(_0xf638('0x5'));var BPromise=require(_0xf638('0x6'));var Mustache=require(_0xf638('0x7'));var util=require(_0xf638('0x8'));var path=require('path');var sox=require(_0xf638('0x9'));var csv=require(_0xf638('0xa'));var ejs=require(_0xf638('0xb'));var fs=require('fs');var _=require(_0xf638('0xc'));var squel=require('squel');var crypto=require(_0xf638('0xd'));var jsforce=require('jsforce');var deskjs=require(_0xf638('0xe'));var toCsv=require(_0xf638('0xa'));var querystring=require(_0xf638('0xf'));var Papa=require(_0xf638('0x10'));var Redis=require('ioredis');var authService=require(_0xf638('0x11'));var qs=require(_0xf638('0x12'));var as=require(_0xf638('0x13'));var hardwareService=require(_0xf638('0x14'));var logger=require(_0xf638('0x15'))(_0xf638('0x16'));var utils=require(_0xf638('0x17'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0xf638('0x18'))['db'];config[_0xf638('0x19')]=_['defaults'](config['redis'],{'host':_0xf638('0x1a'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xf638('0x19')]));require(_0xf638('0x1b'))[_0xf638('0x1c')](socket);var jayson=require(_0xf638('0x1d'));var client=jayson[_0xf638('0x1e')][_0xf638('0x1f')]({'port':0x232c});var client9002=jayson[_0xf638('0x1e')][_0xf638('0x1f')]({'port':0x232a});function respondWithRpcPromise(_0x5d79f1,_0x1d7740,_0x5741f2,_0x57956a){return new BPromise(function(_0x127d60,_0x88fd3){var _0x17dd2f=_0x57956a||client;return _0x17dd2f['request'](_0x5d79f1,_0x5741f2)['then'](function(_0x481f0d){logger['info'](_0xf638('0x20'),_0x1d7740,_0xf638('0x21'));logger[_0xf638('0x22')](_0xf638('0x23'),_0x1d7740,_0xf638('0x21'),JSON['stringify'](_0x481f0d));if(_0x481f0d['error']){if(_0x481f0d[_0xf638('0x24')][_0xf638('0x25')]===0x1f4){logger['error'](_0xf638('0x20'),_0x1d7740,_0x481f0d[_0xf638('0x24')][_0xf638('0x26')]);return _0x88fd3(_0x481f0d[_0xf638('0x24')][_0xf638('0x26')]);}logger[_0xf638('0x24')](_0xf638('0x20'),_0x1d7740,_0x481f0d[_0xf638('0x24')]['message']);return _0x127d60(_0x481f0d[_0xf638('0x24')][_0xf638('0x26')]);}else{logger[_0xf638('0x27')]('ChatMessage,\x20%s,\x20%s',_0x1d7740,_0xf638('0x21'));_0x127d60(_0x481f0d[_0xf638('0x28')]['message']);}})[_0xf638('0x29')](function(_0x395d5b){logger[_0xf638('0x24')](_0xf638('0x20'),_0x1d7740,_0x395d5b);_0x88fd3(_0x395d5b);});});}function respondWithStatusCode(_0x2fbd7a,_0x57431f){_0x57431f=_0x57431f||0xcc;return function(_0x3cb9eb){if(_0x3cb9eb){return _0x2fbd7a[_0xf638('0x2a')](_0x57431f);}return _0x2fbd7a['status'](_0x57431f)[_0xf638('0x2b')]();};}function respondWithResult(_0x23a969,_0xcf68a1){_0xcf68a1=_0xcf68a1||0xc8;return function(_0x2c2e42){if(_0x2c2e42){return _0x23a969[_0xf638('0x2c')](_0xcf68a1)['json'](_0x2c2e42);}};}function respondWithFilteredResult(_0x49fd8b,_0x248e1b){return function(_0x14cbda){if(_0x14cbda){var _0x2a2d6d=_0x14cbda[_0xf638('0x2d')],_0x11f04b=_0x248e1b[_0xf638('0x2e')],_0x5f4200=_0x248e1b['offset']+_0x248e1b[_0xf638('0x2f')],_0x50cd79;if(_0x5f4200>=_0x2a2d6d){_0x5f4200=_0x2a2d6d;_0x50cd79=0xc8;}else{_0x50cd79=0xce;}_0x49fd8b['status'](_0x50cd79);return _0x49fd8b['set'](_0xf638('0x30'),_0x11f04b+'-'+_0x5f4200+'/'+_0x2a2d6d)['json'](_0x14cbda);}return null;};}function patchUpdates(_0xdbf6aa){return function(_0x16a9ef){try{jsonpatch[_0xf638('0x31')](_0x16a9ef,_0xdbf6aa,!![]);}catch(_0x3ad03b){return BPromise[_0xf638('0x32')](_0x3ad03b);}return _0x16a9ef[_0xf638('0x33')]();};}function saveUpdates(_0x55c0c4,_0x80c264){return function(_0x5a1e37){if(_0x5a1e37){return _0x5a1e37['update'](_0x55c0c4)['then'](function(_0x1444f4){return _0x1444f4;});}return null;};}function removeEntity(_0x3e7849,_0x3485d0){return function(_0x56b90e){if(_0x56b90e){return _0x56b90e[_0xf638('0x34')]()[_0xf638('0x35')](function(){_0x3e7849[_0xf638('0x2c')](0xcc)[_0xf638('0x2b')]();});}};}function handleEntityNotFound(_0x2696a2,_0xa495fd){return function(_0x2288f2){if(!_0x2288f2){_0x2696a2[_0xf638('0x2a')](0x194);}return _0x2288f2;};}function handleError(_0xf0ee96,_0x55c468){_0x55c468=_0x55c468||0x1f4;return function(_0x4e7cf8){logger['error'](_0x4e7cf8[_0xf638('0x36')]);if(_0x4e7cf8[_0xf638('0x37')]){delete _0x4e7cf8[_0xf638('0x37')];}_0xf0ee96['status'](_0x55c468)[_0xf638('0x38')](_0x4e7cf8);};}exports[_0xf638('0x39')]=function(_0x14b022,_0x1371e2){var _0x13c57e={},_0x78fe25={},_0x13ea6c={'count':0x0,'rows':[]};var _0x452f74=_['map'](db[_0xf638('0x3a')][_0xf638('0x3b')],function(_0x5d4b2f){return{'name':_0x5d4b2f[_0xf638('0x3c')],'type':_0x5d4b2f[_0xf638('0x3d')][_0xf638('0x3e')]};});_0x78fe25[_0xf638('0x3f')]=_[_0xf638('0x40')](_0x452f74,'name');_0x78fe25[_0xf638('0x41')]=_[_0xf638('0x42')](_0x14b022['query']);_0x78fe25[_0xf638('0x43')]=_[_0xf638('0x44')](_0x78fe25[_0xf638('0x3f')],_0x78fe25['query']);_0x13c57e[_0xf638('0x45')]=_['intersection'](_0x78fe25[_0xf638('0x3f')],qs[_0xf638('0x46')](_0x14b022[_0xf638('0x41')][_0xf638('0x46')]));_0x13c57e[_0xf638('0x45')]=_0x13c57e[_0xf638('0x45')][_0xf638('0x47')]?_0x13c57e[_0xf638('0x45')]:_0x78fe25[_0xf638('0x3f')];if(!_0x14b022[_0xf638('0x41')][_0xf638('0x48')]('nolimit')){_0x13c57e[_0xf638('0x2f')]=qs[_0xf638('0x2f')](_0x14b022[_0xf638('0x41')]['limit']);_0x13c57e[_0xf638('0x2e')]=qs[_0xf638('0x2e')](_0x14b022[_0xf638('0x41')]['offset']);}_0x13c57e[_0xf638('0x49')]=qs[_0xf638('0x4a')](_0x14b022[_0xf638('0x41')][_0xf638('0x4a')]);_0x13c57e['where']=qs[_0xf638('0x43')](_[_0xf638('0x4b')](_0x14b022['query'],_0x78fe25[_0xf638('0x43')]),_0x452f74);if(_0x14b022['query']['filter']){_0x13c57e[_0xf638('0x4c')]=_[_0xf638('0x4d')](_0x13c57e[_0xf638('0x4c')],{'$or':_['map'](_0x452f74,function(_0x584381){if(_0x584381[_0xf638('0x3d')]!==_0xf638('0x4e')){var _0x4c5783={};_0x4c5783[_0x584381[_0xf638('0x37')]]={'$like':'%'+_0x14b022['query'][_0xf638('0x4f')]+'%'};return _0x4c5783;}})});}_0x13c57e=_['merge']({},_0x13c57e,_0x14b022[_0xf638('0x50')]);var _0x5b9c13={'where':_0x13c57e[_0xf638('0x4c')]};return db[_0xf638('0x3a')][_0xf638('0x2d')](_0x5b9c13)['then'](function(_0x7b4b34){_0x13ea6c['count']=_0x7b4b34;if(_0x14b022[_0xf638('0x41')][_0xf638('0x51')]){_0x13c57e[_0xf638('0x52')]=[{'all':!![]}];}return db[_0xf638('0x3a')][_0xf638('0x53')](_0x13c57e);})[_0xf638('0x35')](function(_0xabb7c6){_0x13ea6c[_0xf638('0x54')]=_0xabb7c6;return _0x13ea6c;})[_0xf638('0x35')](respondWithFilteredResult(_0x1371e2,_0x13c57e))[_0xf638('0x29')](handleError(_0x1371e2,null));};exports['show']=function(_0x518306,_0x89025d){var _0xf62d7d={'raw':!![],'where':{'id':_0x518306[_0xf638('0x55')]['id']}},_0x22416b={};_0x22416b[_0xf638('0x3f')]=_[_0xf638('0x42')](db['ChatMessage'][_0xf638('0x3b')]);_0x22416b[_0xf638('0x41')]=_[_0xf638('0x42')](_0x518306['query']);_0x22416b['filters']=_[_0xf638('0x44')](_0x22416b[_0xf638('0x3f')],_0x22416b[_0xf638('0x41')]);_0xf62d7d[_0xf638('0x45')]=_[_0xf638('0x44')](_0x22416b[_0xf638('0x3f')],qs[_0xf638('0x46')](_0x518306[_0xf638('0x41')][_0xf638('0x46')]));_0xf62d7d['attributes']=_0xf62d7d[_0xf638('0x45')][_0xf638('0x47')]?_0xf62d7d[_0xf638('0x45')]:_0x22416b['model'];if(_0x518306[_0xf638('0x41')][_0xf638('0x51')]){_0xf62d7d['include']=[{'all':!![]}];}_0xf62d7d=_[_0xf638('0x4d')]({},_0xf62d7d,_0x518306['options']);return db[_0xf638('0x3a')][_0xf638('0x56')](_0xf62d7d)['then'](handleEntityNotFound(_0x89025d,null))[_0xf638('0x35')](respondWithResult(_0x89025d,null))[_0xf638('0x29')](handleError(_0x89025d,null));};exports[_0xf638('0x57')]=function(_0x2917ed,_0x4cf69e){return db[_0xf638('0x3a')]['create'](_0x2917ed[_0xf638('0x58')],{})[_0xf638('0x35')](respondWithResult(_0x4cf69e,0xc9))[_0xf638('0x29')](handleError(_0x4cf69e,null));};exports[_0xf638('0x59')]=function(_0x379cfa,_0x5b8f89){if(_0x379cfa[_0xf638('0x58')]['id']){delete _0x379cfa[_0xf638('0x58')]['id'];}return db[_0xf638('0x3a')][_0xf638('0x56')]({'where':{'id':_0x379cfa[_0xf638('0x55')]['id']}})[_0xf638('0x35')](handleEntityNotFound(_0x5b8f89,null))['then'](saveUpdates(_0x379cfa['body'],null))[_0xf638('0x35')](respondWithResult(_0x5b8f89,null))[_0xf638('0x29')](handleError(_0x5b8f89,null));};exports['destroy']=function(_0x1bca61,_0x553680){return db['ChatMessage'][_0xf638('0x56')]({'where':{'id':_0x1bca61[_0xf638('0x55')]['id']}})['then'](handleEntityNotFound(_0x553680,null))[_0xf638('0x35')](removeEntity(_0x553680,null))['catch'](handleError(_0x553680,null));};exports[_0xf638('0x5a')]=function(_0x19027e,_0x421640){return db[_0xf638('0x3a')][_0xf638('0x5a')]()['then'](respondWithResult(_0x421640,null))['catch'](handleError(_0x421640,null));};var interaction_log=require(_0xf638('0x15'))('chat-interactions');exports[_0xf638('0x5b')]=function(_0x19d956,_0x5d282f,_0x5a7dda){var _0x52b79c={'agent':{},'channel':'chat'};if(_0x19d956[_0xf638('0x58')]['id']){delete _0x19d956[_0xf638('0x58')]['id'];}_0x19d956[_0xf638('0x58')][_0xf638('0x5c')]=!![];_0x19d956['body'][_0xf638('0x5d')]=moment()[_0xf638('0x5e')](_0xf638('0x5f'));_0x19d956[_0xf638('0x58')]['UserId']=_0x19d956[_0xf638('0x58')]['UserId']||_0x19d956[_0xf638('0x60')]['id'];_0x52b79c[_0xf638('0x61')]['id']=_0x19d956[_0xf638('0x58')]['UserId'];return db[_0xf638('0x3a')][_0xf638('0x56')]({'where':{'id':_0x19d956[_0xf638('0x55')]['id'],'UserId':null},'include':[{'model':db[_0xf638('0x62')],'as':'Contact'}]})['then'](handleEntityNotFound(_0x5d282f,null))[_0xf638('0x35')](saveUpdates(_0x19d956[_0xf638('0x58')],null))[_0xf638('0x35')](function(_0x305e92){if(_0x305e92){_0x52b79c[_0xf638('0x26')]=_0x305e92[_0xf638('0x63')]({'plain':!![]});return db['ChatInteraction']['find']({'where':{'id':_0x305e92[_0xf638('0x64')]}});}return null;})[_0xf638('0x35')](handleEntityNotFound(_0x5d282f,null))[_0xf638('0x35')](function(_0x1934de){if(_0x1934de){return _0x1934de[_0xf638('0x59')]({'UserId':_0x19d956[_0xf638('0x58')][_0xf638('0x65')],'read1stAt':_['isNil'](_0x1934de[_0xf638('0x66')])?moment()[_0xf638('0x5e')](_0xf638('0x5f')):undefined});}return null;})[_0xf638('0x35')](function(_0x1da7eb){if(_0x1da7eb){_0x52b79c[_0xf638('0x67')]=_0x1da7eb[_0xf638('0x63')]({'plain':!![]});interaction_log['info']('[CHATMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0x19d956['user']['id'],_0x19d956[_0xf638('0x60')]['name'],_0x19d956[_0xf638('0x60')]['role'],_0x52b79c['interaction']['id'],_0x19d956[_0xf638('0x58')]?JSON[_0xf638('0x68')](_0x19d956[_0xf638('0x58')]):_0xf638('0x69'));return respondWithRpcPromise('AcceptMessage',_0xf638('0x6a'),_0x52b79c);}return null;})[_0xf638('0x35')](function(_0x320e7b){if(_0x320e7b){if(_0x19d956['body'][_0xf638('0x6b')]){_0x52b79c[_0xf638('0x26')][_0xf638('0x6c')]=util['format'](_0xf638('0x6d'),_0x19d956[_0xf638('0x60')][_0xf638('0x37')]);_0x52b79c[_0xf638('0x26')][_0xf638('0x6e')]=_0x52b79c[_0xf638('0x6e')];_0x52b79c[_0xf638('0x26')][_0xf638('0x6f')]='accept';return respondWithRpcPromise(_0xf638('0x70'),'EventManager',{'event':_0xf638('0x71'),'message':_['merge'](_0x52b79c['message'],JSON[_0xf638('0x72')](_0x52b79c[_0xf638('0x67')][_0xf638('0x73')]))},client9002)[_0xf638('0x35')](function(){return _0x52b79c;});}return _0x52b79c;}return null;})[_0xf638('0x35')](respondWithResult(_0x5d282f,null))['catch'](handleError(_0x5d282f,null));};var interaction_log=require(_0xf638('0x15'))(_0xf638('0x74'));exports[_0xf638('0x32')]=function(_0xc413a3,_0x2d681a,_0x2bcd54){var _0x5c4402={'agent':{},'channel':_0xf638('0x75')};if(_0xc413a3[_0xf638('0x58')]['id']){delete _0xc413a3[_0xf638('0x58')]['id'];}_0xc413a3[_0xf638('0x58')][_0xf638('0x65')]=_0xc413a3[_0xf638('0x58')][_0xf638('0x65')]||_0xc413a3[_0xf638('0x60')]['id'];_0x5c4402[_0xf638('0x61')]['id']=_0xc413a3[_0xf638('0x58')][_0xf638('0x65')];return db[_0xf638('0x3a')]['find']({'where':{'id':_0xc413a3['params']['id'],'UserId':null}})[_0xf638('0x35')](handleEntityNotFound(_0x2d681a,null))[_0xf638('0x35')](function(_0x3d759a){if(_0x3d759a){_0x5c4402[_0xf638('0x26')]=_0x3d759a[_0xf638('0x63')]({'plain':!![]});return db[_0xf638('0x76')][_0xf638('0x56')]({'where':{'id':_0x3d759a['ChatInteractionId']}});}return null;})[_0xf638('0x35')](handleEntityNotFound(_0x2d681a,null))[_0xf638('0x35')](function(_0x11981a){if(_0x11981a){_0x5c4402[_0xf638('0x67')]=_0x11981a[_0xf638('0x63')]({'plain':!![]});interaction_log[_0xf638('0x27')]('[CHATMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0xc413a3['user']['id'],_0xc413a3[_0xf638('0x60')][_0xf638('0x37')],_0xc413a3['user']['role'],_0x5c4402[_0xf638('0x67')]['id'],_0xc413a3[_0xf638('0x58')]?JSON['stringify'](_0xc413a3['body']):_0xf638('0x69'));return respondWithRpcPromise('RejectMessage','rejectMessage',_0x5c4402);}return null;})[_0xf638('0x35')](function(_0x3ebe35){if(_0x3ebe35){_0x3ebe35[_0xf638('0x26')][_0xf638('0x6c')]=util[_0xf638('0x5e')]('SIP/%s',_0xc413a3[_0xf638('0x60')][_0xf638('0x37')]);_0x3ebe35[_0xf638('0x26')]['channel']=_0x5c4402[_0xf638('0x6e')];_0x3ebe35[_0xf638('0x26')]['event']=_0xf638('0x32');respondWithRpcPromise(_0xf638('0x70'),'EventManager',{'event':'rejectmessage','message':_0x3ebe35[_0xf638('0x26')]},client9002);return _0x5c4402;}return null;})['then'](respondWithResult(_0x2d681a,null))[_0xf638('0x29')](handleError(_0x2d681a,null));};
\ No newline at end of file
+var _0x960a=['interface','SIP/%s','channel','event','EventManager','parse','formData','util','lodash','ioredis','../../components/interaction/service','../../config/environment','../../mysqldb','redis','defaults','localhost','jayson/promise','client','http','../../config/logger','chat-interactions','then','info','ChatMessage,\x20%s,\x20%s','request\x20sent','ChatMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','json','undefined','limit','count','offset','status','set','destroy','end','sendStatus','name','send','index','map','ChatMessage','rawAttributes','type','key','model','query','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','includeAll','include','findAll','show','params','keys','find','create','body','update','describe','accept','chat','acceptMessage','reject','UserId','user','agent','ChatInteraction','ChatInteractionId','interaction','get','role','RejectMessage','rejectMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','ContactId','sequelize','QueryTypes','SELECT','contact','User','email'];(function(_0x5ebec4,_0x474731){var _0x3b9d3b=function(_0x3aa9da){while(--_0x3aa9da){_0x5ebec4['push'](_0x5ebec4['shift']());}};_0x3b9d3b(++_0x474731);}(_0x960a,0x18f));var _0xa960=function(_0x1b2aea,_0x1c51ff){_0x1b2aea=_0x1b2aea-0x0;var _0x2ff88c=_0x960a[_0x1b2aea];return _0x2ff88c;};'use strict';var util=require(_0xa960('0x0'));var _=require(_0xa960('0x1'));var Redis=require(_0xa960('0x2'));var interactionService=require(_0xa960('0x3'));var qs=require('../../components/parsers/qs');var logger=require('../../config/logger')('api');var config=require(_0xa960('0x4'));var db=require(_0xa960('0x5'))['db'];config[_0xa960('0x6')]=_[_0xa960('0x7')](config[_0xa960('0x6')],{'host':_0xa960('0x8'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require('./chatMessage.socket')['register'](socket);var jayson=require(_0xa960('0x9'));var client=jayson[_0xa960('0xa')][_0xa960('0xb')]({'port':0x232c});var client9002=jayson[_0xa960('0xa')][_0xa960('0xb')]({'port':0x232a});var interaction_log=require(_0xa960('0xc'))(_0xa960('0xd'));function respondWithRpcPromise(_0x5de2f6,_0x1b9980,_0x218d30,_0x18cb56){return new Promise(function(_0x3aeeae,_0xa6fc5f){var _0x36a988=_0x18cb56||client;return _0x36a988['request'](_0x5de2f6,_0x218d30)[_0xa960('0xe')](function(_0x4110dc){logger[_0xa960('0xf')](_0xa960('0x10'),_0x1b9980,_0xa960('0x11'));logger['debug'](_0xa960('0x12'),_0x1b9980,_0xa960('0x11'),JSON[_0xa960('0x13')](_0x4110dc));if(_0x4110dc[_0xa960('0x14')]){if(_0x4110dc[_0xa960('0x14')][_0xa960('0x15')]===0x1f4){logger[_0xa960('0x14')](_0xa960('0x10'),_0x1b9980,_0x4110dc[_0xa960('0x14')]['message']);return _0xa6fc5f(_0x4110dc[_0xa960('0x14')][_0xa960('0x16')]);}logger[_0xa960('0x14')]('ChatMessage,\x20%s,\x20%s',_0x1b9980,_0x4110dc['error'][_0xa960('0x16')]);return _0x3aeeae(_0x4110dc[_0xa960('0x14')][_0xa960('0x16')]);}else{logger[_0xa960('0xf')](_0xa960('0x10'),_0x1b9980,_0xa960('0x11'));_0x3aeeae(_0x4110dc['result'][_0xa960('0x16')]);}})[_0xa960('0x17')](function(_0x311c82){logger[_0xa960('0x14')](_0xa960('0x10'),_0x1b9980,_0x311c82);_0xa6fc5f(_0x311c82);});});}function respondWithResult(_0x307cf8,_0x5a408d){_0x5a408d=_0x5a408d||0xc8;return function(_0x1532a0){if(_0x1532a0){return _0x307cf8['status'](_0x5a408d)[_0xa960('0x18')](_0x1532a0);}};}function respondWithFilteredResult(_0x4ea051,_0x76ab41){return function(_0x57dfc4){if(_0x57dfc4){var _0x18d70a=typeof _0x76ab41['offset']===_0xa960('0x19')&&typeof _0x76ab41[_0xa960('0x1a')]===_0xa960('0x19');var _0x4b443a=_0x57dfc4[_0xa960('0x1b')];var _0xcdd616=_0x18d70a?0x0:_0x76ab41[_0xa960('0x1c')];var _0x458b27=_0x18d70a?_0x57dfc4[_0xa960('0x1b')]:_0x76ab41[_0xa960('0x1c')]+_0x76ab41[_0xa960('0x1a')];var _0x52e27d;if(_0x458b27>=_0x4b443a){_0x458b27=_0x4b443a;_0x52e27d=0xc8;}else{_0x52e27d=0xce;}_0x4ea051[_0xa960('0x1d')](_0x52e27d);return _0x4ea051[_0xa960('0x1e')]('Content-Range',_0xcdd616+'-'+_0x458b27+'/'+_0x4b443a)[_0xa960('0x18')](_0x57dfc4);}return null;};}function saveUpdates(_0x40b451){return function(_0x3e0647){if(_0x3e0647){return _0x3e0647['update'](_0x40b451)[_0xa960('0xe')](function(_0x2fb446){return _0x2fb446;});}return null;};}function removeEntity(_0x3ac980){return function(_0x2376d9){if(_0x2376d9){return _0x2376d9[_0xa960('0x1f')]()[_0xa960('0xe')](function(){_0x3ac980[_0xa960('0x1d')](0xcc)[_0xa960('0x20')]();});}};}function handleEntityNotFound(_0x14ce5d){return function(_0x4d6437){if(!_0x4d6437){_0x14ce5d[_0xa960('0x21')](0x194);}return _0x4d6437;};}function handleError(_0xd64cb9,_0x4aa39d){_0x4aa39d=_0x4aa39d||0x1f4;return function(_0x401af3){logger['error'](_0x401af3['stack']);if(_0x401af3[_0xa960('0x22')]){delete _0x401af3[_0xa960('0x22')];}_0xd64cb9['status'](_0x4aa39d)[_0xa960('0x23')](_0x401af3);};}exports[_0xa960('0x24')]=function(_0x36252c,_0x4e928d){var _0x47435f={},_0x5b066a={},_0x1c9e12={'count':0x0,'rows':[]};var _0x37467a=_[_0xa960('0x25')](db[_0xa960('0x26')][_0xa960('0x27')],function(_0x108be3){return{'name':_0x108be3['fieldName'],'type':_0x108be3[_0xa960('0x28')][_0xa960('0x29')]};});_0x5b066a[_0xa960('0x2a')]=_[_0xa960('0x25')](_0x37467a,_0xa960('0x22'));_0x5b066a[_0xa960('0x2b')]=_['keys'](_0x36252c[_0xa960('0x2b')]);_0x5b066a[_0xa960('0x2c')]=_[_0xa960('0x2d')](_0x5b066a['model'],_0x5b066a['query']);_0x47435f['attributes']=_[_0xa960('0x2d')](_0x5b066a[_0xa960('0x2a')],qs[_0xa960('0x2e')](_0x36252c[_0xa960('0x2b')][_0xa960('0x2e')]));_0x47435f[_0xa960('0x2f')]=_0x47435f[_0xa960('0x2f')][_0xa960('0x30')]?_0x47435f[_0xa960('0x2f')]:_0x5b066a[_0xa960('0x2a')];if(!_0x36252c['query'][_0xa960('0x31')](_0xa960('0x32'))){_0x47435f[_0xa960('0x1a')]=qs['limit'](_0x36252c['query']['limit']);_0x47435f[_0xa960('0x1c')]=qs['offset'](_0x36252c[_0xa960('0x2b')][_0xa960('0x1c')]);}_0x47435f[_0xa960('0x33')]=qs[_0xa960('0x34')](_0x36252c[_0xa960('0x2b')][_0xa960('0x34')]);_0x47435f[_0xa960('0x35')]=qs[_0xa960('0x2c')](_[_0xa960('0x36')](_0x36252c[_0xa960('0x2b')],_0x5b066a['filters']),_0x37467a);if(_0x36252c[_0xa960('0x2b')][_0xa960('0x37')]){_0x47435f['where']=_[_0xa960('0x38')](_0x47435f['where'],{'$or':_[_0xa960('0x25')](_0x37467a,function(_0x5b6c3f){if(_0x5b6c3f[_0xa960('0x28')]!==_0xa960('0x39')){var _0x21cddf={};_0x21cddf[_0x5b6c3f[_0xa960('0x22')]]={'$like':'%'+_0x36252c[_0xa960('0x2b')]['filter']+'%'};return _0x21cddf;}})});}_0x47435f=_['merge']({},_0x47435f,_0x36252c['options']);var _0x2473dc={'where':_0x47435f[_0xa960('0x35')]};return db['ChatMessage'][_0xa960('0x1b')](_0x2473dc)[_0xa960('0xe')](function(_0x540a9f){_0x1c9e12[_0xa960('0x1b')]=_0x540a9f;if(_0x36252c[_0xa960('0x2b')][_0xa960('0x3a')]){_0x47435f[_0xa960('0x3b')]=[{'all':!![]}];}return db['ChatMessage'][_0xa960('0x3c')](_0x47435f);})['then'](function(_0x26720e){_0x1c9e12['rows']=_0x26720e;return _0x1c9e12;})['then'](respondWithFilteredResult(_0x4e928d,_0x47435f))[_0xa960('0x17')](handleError(_0x4e928d,null));};exports[_0xa960('0x3d')]=function(_0x110c17,_0x2332fc){var _0x5f0d2d={'raw':!![],'where':{'id':_0x110c17[_0xa960('0x3e')]['id']}},_0x430c0b={};_0x430c0b['model']=_[_0xa960('0x3f')](db[_0xa960('0x26')]['rawAttributes']);_0x430c0b[_0xa960('0x2b')]=_['keys'](_0x110c17['query']);_0x430c0b[_0xa960('0x2c')]=_['intersection'](_0x430c0b[_0xa960('0x2a')],_0x430c0b[_0xa960('0x2b')]);_0x5f0d2d[_0xa960('0x2f')]=_[_0xa960('0x2d')](_0x430c0b[_0xa960('0x2a')],qs[_0xa960('0x2e')](_0x110c17['query'][_0xa960('0x2e')]));_0x5f0d2d[_0xa960('0x2f')]=_0x5f0d2d[_0xa960('0x2f')]['length']?_0x5f0d2d[_0xa960('0x2f')]:_0x430c0b[_0xa960('0x2a')];if(_0x110c17[_0xa960('0x2b')][_0xa960('0x3a')]){_0x5f0d2d[_0xa960('0x3b')]=[{'all':!![]}];}_0x5f0d2d=_[_0xa960('0x38')]({},_0x5f0d2d,_0x110c17['options']);return db[_0xa960('0x26')][_0xa960('0x40')](_0x5f0d2d)[_0xa960('0xe')](handleEntityNotFound(_0x2332fc,null))[_0xa960('0xe')](respondWithResult(_0x2332fc,null))[_0xa960('0x17')](handleError(_0x2332fc,null));};exports[_0xa960('0x41')]=function(_0x1dc2fa,_0x10f1c0){return db[_0xa960('0x26')][_0xa960('0x41')](_0x1dc2fa[_0xa960('0x42')],{})[_0xa960('0xe')](respondWithResult(_0x10f1c0,0xc9))[_0xa960('0x17')](handleError(_0x10f1c0,null));};exports[_0xa960('0x43')]=function(_0x5b6817,_0x280dcf){if(_0x5b6817[_0xa960('0x42')]['id']){delete _0x5b6817[_0xa960('0x42')]['id'];}return db[_0xa960('0x26')][_0xa960('0x40')]({'where':{'id':_0x5b6817[_0xa960('0x3e')]['id']}})[_0xa960('0xe')](handleEntityNotFound(_0x280dcf,null))[_0xa960('0xe')](saveUpdates(_0x5b6817[_0xa960('0x42')],null))['then'](respondWithResult(_0x280dcf,null))[_0xa960('0x17')](handleError(_0x280dcf,null));};exports[_0xa960('0x1f')]=function(_0x4a9d66,_0x12ad6f){return db[_0xa960('0x26')]['find']({'where':{'id':_0x4a9d66[_0xa960('0x3e')]['id']}})[_0xa960('0xe')](handleEntityNotFound(_0x12ad6f,null))[_0xa960('0xe')](removeEntity(_0x12ad6f,null))[_0xa960('0x17')](handleError(_0x12ad6f,null));};exports[_0xa960('0x44')]=function(_0x5f2ad1,_0x14f6e6){return db[_0xa960('0x26')]['describe']()['then'](respondWithResult(_0x14f6e6,null))[_0xa960('0x17')](handleError(_0x14f6e6,null));};exports[_0xa960('0x45')]=function(_0x4c1e6d,_0x30650f){var _0x5d87d8=_0xa960('0x46');return interactionService[_0xa960('0x47')](_0x4c1e6d,_0x5d87d8)[_0xa960('0xe')](respondWithResult(_0x30650f,null))[_0xa960('0x17')](handleError(_0x30650f,null));};exports[_0xa960('0x48')]=function(_0xdc17fa,_0x47f4e7){var _0x3fc48={'agent':{},'channel':_0xa960('0x46')};if(_0xdc17fa['body']['id']){delete _0xdc17fa[_0xa960('0x42')]['id'];}_0xdc17fa['body'][_0xa960('0x49')]=_0xdc17fa[_0xa960('0x42')][_0xa960('0x49')]||_0xdc17fa[_0xa960('0x4a')]['id'];_0x3fc48[_0xa960('0x4b')]['id']=_0xdc17fa[_0xa960('0x42')][_0xa960('0x49')];return db[_0xa960('0x26')][_0xa960('0x40')]({'where':{'id':_0xdc17fa[_0xa960('0x3e')]['id'],'UserId':null}})[_0xa960('0xe')](handleEntityNotFound(_0x47f4e7,null))[_0xa960('0xe')](function(_0x1224b4){if(_0x1224b4){_0x3fc48['message']=_0x1224b4['get']({'plain':!![]});return db[_0xa960('0x4c')][_0xa960('0x40')]({'where':{'id':_0x1224b4[_0xa960('0x4d')]}});}return null;})['then'](handleEntityNotFound(_0x47f4e7,null))[_0xa960('0xe')](function(_0x577b84){if(_0x577b84){_0x3fc48[_0xa960('0x4e')]=_0x577b84[_0xa960('0x4f')]({'plain':!![]});interaction_log[_0xa960('0xf')]('[CHATMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0xdc17fa['user']['id'],_0xdc17fa['user']['name'],_0xdc17fa[_0xa960('0x4a')][_0xa960('0x50')],_0x3fc48[_0xa960('0x4e')]['id'],_0xdc17fa[_0xa960('0x42')]?JSON[_0xa960('0x13')](_0xdc17fa[_0xa960('0x42')]):'null');return respondWithRpcPromise(_0xa960('0x51'),_0xa960('0x52'),_0x3fc48);}return null;})[_0xa960('0xe')](function(_0x2ac80d){var _0x3705e2=_0xa960('0x53')+_0x2ac80d[_0xa960('0x16')][_0xa960('0x54')];return db[_0xa960('0x55')][_0xa960('0x2b')](_0x3705e2,{'type':db['Sequelize'][_0xa960('0x56')][_0xa960('0x57')],'raw':!![]})[_0xa960('0xe')](function(_0x8ecc5){return _0x8ecc5;});})[_0xa960('0xe')](function(_0x495cb9){if(_0x495cb9){_0x3fc48[_0xa960('0x16')][_0xa960('0x58')]=_0x495cb9[0x0];if(!_0xdc17fa[_0xa960('0x42')][_0xa960('0x49')])return;return db[_0xa960('0x59')]['find']({'where':{'id':_0xdc17fa[_0xa960('0x42')][_0xa960('0x49')],'role':_0xa960('0x4b')},'attributes':['id',_0xa960('0x22'),'fullname',_0xa960('0x5a'),'internal'],'raw':!![]});}return null;})[_0xa960('0xe')](function(_0x9ede29){if(!_0x9ede29)return null;_0x3fc48[_0xa960('0x16')][_0xa960('0x4b')]=_0x9ede29;return _0x3fc48;})[_0xa960('0xe')](function(_0x514e4e){if(_0x514e4e){_0x514e4e['message'][_0xa960('0x5b')]=util['format'](_0xa960('0x5c'),_0xdc17fa[_0xa960('0x4a')][_0xa960('0x22')]);_0x514e4e[_0xa960('0x16')][_0xa960('0x5d')]=_0x3fc48['channel'];_0x514e4e['message']['motionChannel']=_0x3fc48['channel'];_0x514e4e[_0xa960('0x16')][_0xa960('0x5e')]='reject';respondWithRpcPromise(_0xa960('0x5f'),_0xa960('0x5f'),{'event':'rejectmessage','message':_[_0xa960('0x38')](_0x3fc48[_0xa960('0x16')],JSON[_0xa960('0x60')](_0x3fc48[_0xa960('0x4e')][_0xa960('0x61')]))},client9002);return _0x3fc48;}return null;})[_0xa960('0xe')](respondWithResult(_0x47f4e7,null))[_0xa960('0x17')](handleError(_0x47f4e7,null));};
\ No newline at end of file