Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / openchannelMessage / openchannelMessage.controller.js
index c35d30a..1bc47fd 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6697=['type','model','keys','query','filters','attributes','fields','length','hasOwnProperty','nolimit','sort','where','filter','merge','options','OpenchannelMessage','count','includeAll','include','rows','show','intersection','find','create','body','params','describe','openchannel-interactions','accept','openchannel','read','readAt','format','YYYY-MM-DD\x20HH:mm:ss','UserId','user','CmContact','Contact','get','OpenchannelInteraction','OpenchannelInteractionId','isNil','read1stAt','interaction','[OPENCHANNELMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','role','null','AcceptMessage','manual','SIP/%s','channel','event','EventManager','acceptmessage','[OPENCHANNELMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','RejectMessage','interface','rejectmessage','html-pdf','zip-dir','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','register','client','http','test','Sequelize','ValidationError','then','info','OpenchannelMessage,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','status','end','json','offset','limit','Content-Range','apply','reject','update','destroy','sendStatus','stack','name','send','index','map','rawAttributes','fieldName'];(function(_0x47fd36,_0x41535d){var _0x21a0fc=function(_0x44c07c){while(--_0x44c07c){_0x47fd36['push'](_0x47fd36['shift']());}};_0x21a0fc(++_0x41535d);}(_0x6697,0xb3));var _0x7669=function(_0x3b5587,_0x22a6f4){_0x3b5587=_0x3b5587-0x0;var _0x3fbb62=_0x6697[_0x3b5587];return _0x3fbb62;};'use strict';var pdf=require(_0x7669('0x0'));var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x7669('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x7669('0x2'));var moment=require(_0x7669('0x3'));var BPromise=require(_0x7669('0x4'));var Mustache=require(_0x7669('0x5'));var util=require(_0x7669('0x6'));var path=require(_0x7669('0x7'));var sox=require(_0x7669('0x8'));var csv=require(_0x7669('0x9'));var ejs=require(_0x7669('0xa'));var fs=require('fs');var _=require(_0x7669('0xb'));var squel=require(_0x7669('0xc'));var crypto=require(_0x7669('0xd'));var jsforce=require(_0x7669('0xe'));var deskjs=require(_0x7669('0xf'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x7669('0x10'));var Redis=require(_0x7669('0x11'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0x7669('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x7669('0x13'))(_0x7669('0x14'));var utils=require(_0x7669('0x15'));var config=require(_0x7669('0x16'));var db=require(_0x7669('0x17'))['db'];config[_0x7669('0x18')]=_[_0x7669('0x19')](config['redis'],{'host':_0x7669('0x1a'),'port':0x18eb});var socket=require(_0x7669('0x1b'))(new Redis(config[_0x7669('0x18')]));require('./openchannelMessage.socket')[_0x7669('0x1c')](socket);var jayson=require('jayson/promise');var client=jayson[_0x7669('0x1d')][_0x7669('0x1e')]({'port':0x232c});var client9002=jayson[_0x7669('0x1d')]['http']({'port':0x232a});function checkPasswordPattern(_0x3e72ea,_0xb38d7,_0x34743a){if(_0x34743a){var _0x1cda7c=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x1cda7c[_0x7669('0x1f')](_0xb38d7)){return _0x3e72ea;}else{throw new db[(_0x7669('0x20'))][(_0x7669('0x21'))]('The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.');}}else{return _0x3e72ea;}}function respondWithRpcPromise(_0x4b9489,_0x269249,_0x3f2cb7,_0x418cf3){return new BPromise(function(_0x4f917d,_0x5e4fb6){var _0x20a5ac=_0x418cf3||client;return _0x20a5ac['request'](_0x4b9489,_0x3f2cb7)[_0x7669('0x22')](function(_0x34fc60){logger[_0x7669('0x23')](_0x7669('0x24'),_0x269249,_0x7669('0x25'));logger[_0x7669('0x26')]('OpenchannelMessage,\x20%s,\x20%s,\x20%s',_0x269249,_0x7669('0x25'),JSON[_0x7669('0x27')](_0x34fc60));if(_0x34fc60['error']){if(_0x34fc60[_0x7669('0x28')][_0x7669('0x29')]===0x1f4){logger['error']('OpenchannelMessage,\x20%s,\x20%s',_0x269249,_0x34fc60['error'][_0x7669('0x2a')]);return _0x5e4fb6(_0x34fc60[_0x7669('0x28')][_0x7669('0x2a')]);}logger[_0x7669('0x28')](_0x7669('0x24'),_0x269249,_0x34fc60[_0x7669('0x28')][_0x7669('0x2a')]);return _0x4f917d(_0x34fc60['error']['message']);}else{logger[_0x7669('0x23')](_0x7669('0x24'),_0x269249,_0x7669('0x25'));_0x4f917d(_0x34fc60[_0x7669('0x2b')]['message']);}})[_0x7669('0x2c')](function(_0x1279b6){logger[_0x7669('0x28')](_0x7669('0x24'),_0x269249,_0x1279b6);_0x5e4fb6(_0x1279b6);});});}function respondWithStatusCode(_0x5ddbb3,_0x2d5e88){_0x2d5e88=_0x2d5e88||0xcc;return function(_0x1f4211){if(_0x1f4211){return _0x5ddbb3['sendStatus'](_0x2d5e88);}return _0x5ddbb3[_0x7669('0x2d')](_0x2d5e88)[_0x7669('0x2e')]();};}function respondWithResult(_0xbaa653,_0x1efefc){_0x1efefc=_0x1efefc||0xc8;return function(_0x58ee4e){if(_0x58ee4e){return _0xbaa653[_0x7669('0x2d')](_0x1efefc)[_0x7669('0x2f')](_0x58ee4e);}};}function respondWithFilteredResult(_0x2d63ea,_0xe998c3){return function(_0xa8eded){if(_0xa8eded){var _0x51859f=_0xa8eded['count'],_0xc03dde=_0xe998c3[_0x7669('0x30')],_0x5cff54=_0xe998c3[_0x7669('0x30')]+_0xe998c3[_0x7669('0x31')],_0x38b42c;if(_0x5cff54>=_0x51859f){_0x5cff54=_0x51859f;_0x38b42c=0xc8;}else{_0x38b42c=0xce;}_0x2d63ea[_0x7669('0x2d')](_0x38b42c);return _0x2d63ea['set'](_0x7669('0x32'),_0xc03dde+'-'+_0x5cff54+'/'+_0x51859f)[_0x7669('0x2f')](_0xa8eded);}return null;};}function patchUpdates(_0x336f76){return function(_0x5f1151){try{jsonpatch[_0x7669('0x33')](_0x5f1151,_0x336f76,!![]);}catch(_0x479203){return BPromise[_0x7669('0x34')](_0x479203);}return _0x5f1151['save']();};}function saveUpdates(_0x3ee608,_0x349b2b){return function(_0x2a2f6d){if(_0x2a2f6d){return _0x2a2f6d[_0x7669('0x35')](_0x3ee608)[_0x7669('0x22')](function(_0x397956){return _0x397956;});}return null;};}function removeEntity(_0x346e9e,_0x1d6d4f){return function(_0x9a6320){if(_0x9a6320){return _0x9a6320[_0x7669('0x36')]()[_0x7669('0x22')](function(){_0x346e9e['status'](0xcc)[_0x7669('0x2e')]();});}};}function handleEntityNotFound(_0x58f938,_0x43daaf){return function(_0x42b4d0){if(!_0x42b4d0){_0x58f938[_0x7669('0x37')](0x194);}return _0x42b4d0;};}function handleError(_0x4afc8f,_0x1c3964){_0x1c3964=_0x1c3964||0x1f4;return function(_0x3d7286){logger['error'](_0x3d7286[_0x7669('0x38')]);if(_0x3d7286[_0x7669('0x39')]){delete _0x3d7286['name'];}_0x4afc8f[_0x7669('0x2d')](_0x1c3964)[_0x7669('0x3a')](_0x3d7286);};}exports[_0x7669('0x3b')]=function(_0x3b2df6,_0x310cf5){var _0x434908={},_0x2d17f2={},_0x2e160d={'count':0x0,'rows':[]};var _0x57d058=_[_0x7669('0x3c')](db['OpenchannelMessage'][_0x7669('0x3d')],function(_0xcf0dba){return{'name':_0xcf0dba[_0x7669('0x3e')],'type':_0xcf0dba[_0x7669('0x3f')]['key']};});_0x2d17f2[_0x7669('0x40')]=_['map'](_0x57d058,_0x7669('0x39'));_0x2d17f2['query']=_[_0x7669('0x41')](_0x3b2df6[_0x7669('0x42')]);_0x2d17f2[_0x7669('0x43')]=_['intersection'](_0x2d17f2[_0x7669('0x40')],_0x2d17f2[_0x7669('0x42')]);_0x434908[_0x7669('0x44')]=_['intersection'](_0x2d17f2['model'],qs[_0x7669('0x45')](_0x3b2df6[_0x7669('0x42')][_0x7669('0x45')]));_0x434908[_0x7669('0x44')]=_0x434908[_0x7669('0x44')][_0x7669('0x46')]?_0x434908['attributes']:_0x2d17f2[_0x7669('0x40')];if(!_0x3b2df6['query'][_0x7669('0x47')](_0x7669('0x48'))){_0x434908[_0x7669('0x31')]=qs['limit'](_0x3b2df6[_0x7669('0x42')]['limit']);_0x434908[_0x7669('0x30')]=qs[_0x7669('0x30')](_0x3b2df6['query'][_0x7669('0x30')]);}_0x434908['order']=qs[_0x7669('0x49')](_0x3b2df6[_0x7669('0x42')][_0x7669('0x49')]);_0x434908[_0x7669('0x4a')]=qs[_0x7669('0x43')](_['pick'](_0x3b2df6[_0x7669('0x42')],_0x2d17f2[_0x7669('0x43')]));if(_0x3b2df6[_0x7669('0x42')][_0x7669('0x4b')]){_0x434908['where']=_[_0x7669('0x4c')](_0x434908[_0x7669('0x4a')],{'$or':_['map'](_0x57d058,function(_0x21a712){if(_0x21a712[_0x7669('0x3f')]!=='VIRTUAL'){var _0x4bea60={};_0x4bea60[_0x21a712['name']]={'$like':'%'+_0x3b2df6['query'][_0x7669('0x4b')]+'%'};return _0x4bea60;}})});}_0x434908=_[_0x7669('0x4c')]({},_0x434908,_0x3b2df6[_0x7669('0x4d')]);var _0x3d05a7={'where':_0x434908[_0x7669('0x4a')]};return db[_0x7669('0x4e')][_0x7669('0x4f')](_0x3d05a7)[_0x7669('0x22')](function(_0x3a9c15){_0x2e160d[_0x7669('0x4f')]=_0x3a9c15;if(_0x3b2df6[_0x7669('0x42')][_0x7669('0x50')]){_0x434908[_0x7669('0x51')]=[{'all':!![]}];}return db[_0x7669('0x4e')]['findAll'](_0x434908);})[_0x7669('0x22')](function(_0x225e53){_0x2e160d[_0x7669('0x52')]=_0x225e53;return _0x2e160d;})[_0x7669('0x22')](respondWithFilteredResult(_0x310cf5,_0x434908))[_0x7669('0x2c')](handleError(_0x310cf5,null));};exports[_0x7669('0x53')]=function(_0x42e7d0,_0x4b8642){var _0x4ac53f={'raw':!![],'where':{'id':_0x42e7d0['params']['id']}},_0x570bad={};_0x570bad[_0x7669('0x40')]=_['keys'](db[_0x7669('0x4e')]['rawAttributes']);_0x570bad[_0x7669('0x42')]=_[_0x7669('0x41')](_0x42e7d0['query']);_0x570bad[_0x7669('0x43')]=_[_0x7669('0x54')](_0x570bad[_0x7669('0x40')],_0x570bad[_0x7669('0x42')]);_0x4ac53f[_0x7669('0x44')]=_[_0x7669('0x54')](_0x570bad[_0x7669('0x40')],qs[_0x7669('0x45')](_0x42e7d0[_0x7669('0x42')][_0x7669('0x45')]));_0x4ac53f[_0x7669('0x44')]=_0x4ac53f[_0x7669('0x44')]['length']?_0x4ac53f[_0x7669('0x44')]:_0x570bad[_0x7669('0x40')];if(_0x42e7d0[_0x7669('0x42')][_0x7669('0x50')]){_0x4ac53f[_0x7669('0x51')]=[{'all':!![]}];}_0x4ac53f=_[_0x7669('0x4c')]({},_0x4ac53f,_0x42e7d0[_0x7669('0x4d')]);return db['OpenchannelMessage'][_0x7669('0x55')](_0x4ac53f)[_0x7669('0x22')](handleEntityNotFound(_0x4b8642,null))[_0x7669('0x22')](respondWithResult(_0x4b8642,null))['catch'](handleError(_0x4b8642,null));};exports[_0x7669('0x56')]=function(_0x4576b0,_0x3dc24f){return db[_0x7669('0x4e')][_0x7669('0x56')](_0x4576b0[_0x7669('0x57')],{})['then'](respondWithResult(_0x3dc24f,0xc9))[_0x7669('0x2c')](handleError(_0x3dc24f,null));};exports[_0x7669('0x35')]=function(_0x12dd8f,_0x5e7ba9){if(_0x12dd8f['body']['id']){delete _0x12dd8f['body']['id'];}return db['OpenchannelMessage']['find']({'where':{'id':_0x12dd8f[_0x7669('0x58')]['id']}})[_0x7669('0x22')](handleEntityNotFound(_0x5e7ba9,null))[_0x7669('0x22')](saveUpdates(_0x12dd8f[_0x7669('0x57')],null))[_0x7669('0x22')](respondWithResult(_0x5e7ba9,null))[_0x7669('0x2c')](handleError(_0x5e7ba9,null));};exports[_0x7669('0x36')]=function(_0x5f1926,_0x4cefa2){return db[_0x7669('0x4e')][_0x7669('0x55')]({'where':{'id':_0x5f1926[_0x7669('0x58')]['id']}})[_0x7669('0x22')](handleEntityNotFound(_0x4cefa2,null))[_0x7669('0x22')](removeEntity(_0x4cefa2,null))[_0x7669('0x2c')](handleError(_0x4cefa2,null));};exports[_0x7669('0x59')]=function(_0x5d5676,_0x1f28f9){return db['OpenchannelMessage']['describe']()[_0x7669('0x22')](respondWithResult(_0x1f28f9,null))[_0x7669('0x2c')](handleError(_0x1f28f9,null));};var interaction_log=require('../../config/logger')(_0x7669('0x5a'));exports[_0x7669('0x5b')]=function(_0x195fbb,_0xb2eba8,_0x51e566){var _0x3e7d09={'channel':_0x7669('0x5c')};if(_0x195fbb[_0x7669('0x57')]['id']){delete _0x195fbb['body']['id'];}_0x195fbb['body'][_0x7669('0x5d')]=!![];_0x195fbb[_0x7669('0x57')][_0x7669('0x5e')]=moment()[_0x7669('0x5f')](_0x7669('0x60'));_0x195fbb['body']['UserId']=_0x195fbb['body'][_0x7669('0x61')]||_0x195fbb[_0x7669('0x62')]['id'];return db[_0x7669('0x4e')][_0x7669('0x55')]({'where':{'id':_0x195fbb[_0x7669('0x58')]['id'],'UserId':null},'include':[{'model':db[_0x7669('0x63')],'as':_0x7669('0x64')}]})[_0x7669('0x22')](handleEntityNotFound(_0xb2eba8,null))[_0x7669('0x22')](saveUpdates(_0x195fbb[_0x7669('0x57')],null))['then'](function(_0x3a3459){if(_0x3a3459){_0x3e7d09[_0x7669('0x2a')]=_0x3a3459[_0x7669('0x65')]({'plain':!![]});return db[_0x7669('0x66')]['find']({'where':{'id':_0x3a3459[_0x7669('0x67')]}});}return null;})[_0x7669('0x22')](handleEntityNotFound(_0xb2eba8,null))[_0x7669('0x22')](function(_0x43d941){if(_0x43d941){return _0x43d941[_0x7669('0x35')]({'UserId':_0x195fbb[_0x7669('0x57')]['UserId'],'read1stAt':_[_0x7669('0x68')](_0x43d941[_0x7669('0x69')])?moment()[_0x7669('0x5f')](_0x7669('0x60')):undefined});}return null;})[_0x7669('0x22')](function(_0x48b6f3){if(_0x48b6f3){_0x3e7d09[_0x7669('0x6a')]=_0x48b6f3[_0x7669('0x65')]({'plain':!![]});interaction_log[_0x7669('0x23')](_0x7669('0x6b'),_0x195fbb[_0x7669('0x62')]['id'],_0x195fbb[_0x7669('0x62')][_0x7669('0x39')],_0x195fbb['user'][_0x7669('0x6c')],_0x3e7d09[_0x7669('0x6a')]['id'],_0x195fbb[_0x7669('0x57')]?JSON['stringify'](_0x195fbb[_0x7669('0x57')]):_0x7669('0x6d'));return respondWithRpcPromise(_0x7669('0x6e'),'acceptMessage',_0x3e7d09);}return null;})[_0x7669('0x22')](function(_0x4577c2){if(_0x4577c2){if(_0x195fbb['body'][_0x7669('0x6f')]){_0x3e7d09['message']['interface']=util[_0x7669('0x5f')](_0x7669('0x70'),_0x195fbb[_0x7669('0x62')]['name']);_0x3e7d09[_0x7669('0x2a')][_0x7669('0x71')]=_0x3e7d09[_0x7669('0x71')];_0x3e7d09[_0x7669('0x2a')][_0x7669('0x72')]=_0x7669('0x5b');return respondWithRpcPromise(_0x7669('0x73'),_0x7669('0x73'),{'event':_0x7669('0x74'),'message':_0x3e7d09[_0x7669('0x2a')]},client9002)[_0x7669('0x22')](function(){return _0x3e7d09;});}return _0x3e7d09;}return null;})[_0x7669('0x22')](respondWithResult(_0xb2eba8,null))[_0x7669('0x2c')](handleError(_0xb2eba8,null));};var interaction_log=require(_0x7669('0x13'))('openchannel-interactions');exports[_0x7669('0x34')]=function(_0x59b99d,_0x237a05,_0x3cfed2){var _0x55ddd5={'agent':{},'channel':'openchannel'};if(_0x59b99d[_0x7669('0x57')]['id']){delete _0x59b99d[_0x7669('0x57')]['id'];}_0x59b99d[_0x7669('0x57')][_0x7669('0x61')]=_0x59b99d['body'][_0x7669('0x61')]||_0x59b99d['user']['id'];_0x55ddd5['agent']['id']=_0x59b99d['body'][_0x7669('0x61')];return db['OpenchannelMessage'][_0x7669('0x55')]({'where':{'id':_0x59b99d[_0x7669('0x58')]['id'],'UserId':null}})[_0x7669('0x22')](handleEntityNotFound(_0x237a05,null))[_0x7669('0x22')](function(_0xd49045){if(_0xd49045){_0x55ddd5[_0x7669('0x2a')]=_0xd49045[_0x7669('0x65')]({'plain':!![]});return db[_0x7669('0x66')][_0x7669('0x55')]({'where':{'id':_0xd49045[_0x7669('0x67')]}});}return null;})[_0x7669('0x22')](handleEntityNotFound(_0x237a05,null))[_0x7669('0x22')](function(_0x2aac30){if(_0x2aac30){_0x55ddd5[_0x7669('0x6a')]=_0x2aac30[_0x7669('0x65')]({'plain':!![]});interaction_log[_0x7669('0x23')](_0x7669('0x75'),_0x59b99d['user']['id'],_0x59b99d[_0x7669('0x62')][_0x7669('0x39')],_0x59b99d[_0x7669('0x62')][_0x7669('0x6c')],_0x55ddd5[_0x7669('0x6a')]['id'],_0x59b99d[_0x7669('0x57')]?JSON[_0x7669('0x27')](_0x59b99d[_0x7669('0x57')]):_0x7669('0x6d'));return respondWithRpcPromise(_0x7669('0x76'),'rejectMessage',_0x55ddd5);}return null;})['then'](function(_0x3d7485){if(_0x3d7485){_0x3d7485['message'][_0x7669('0x77')]=util['format']('SIP/%s',_0x59b99d[_0x7669('0x62')][_0x7669('0x39')]);_0x3d7485[_0x7669('0x2a')][_0x7669('0x71')]=_0x55ddd5[_0x7669('0x71')];_0x3d7485[_0x7669('0x2a')][_0x7669('0x72')]=_0x7669('0x34');respondWithRpcPromise(_0x7669('0x73'),_0x7669('0x73'),{'event':_0x7669('0x78'),'message':_0x3d7485[_0x7669('0x2a')]},client9002);return _0x55ddd5;}return null;})[_0x7669('0x22')](respondWithResult(_0x237a05,null))[_0x7669('0x2c')](handleError(_0x237a05,null));};
\ No newline at end of file
+var _0xa8d4=['model','attributes','fields','length','hasOwnProperty','nolimit','sort','where','filters','filter','merge','VIRTUAL','includeAll','include','show','params','rawAttributes','options','find','catch','create','body','describe','openchannel','acceptMessage','reject','UserId','user','agent','get','OpenchannelInteraction','interaction','role','null','RejectMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','ContactId','sequelize','Sequelize','QueryTypes','SELECT','contact','User','fullname','email','interface','channel','EventManager','rejectmessage','util','lodash','ioredis','../../mysqldb','redis','localhost','socket.io-emitter','./openchannelMessage.socket','client','http','../../config/logger','request','then','info','OpenchannelMessage,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','status','json','offset','undefined','limit','count','set','Content-Range','update','destroy','stack','name','map','OpenchannelMessage','fieldName','type','key','query','keys','intersection'];(function(_0x4d778f,_0x1d4a49){var _0x100d48=function(_0x31e8bf){while(--_0x31e8bf){_0x4d778f['push'](_0x4d778f['shift']());}};_0x100d48(++_0x1d4a49);}(_0xa8d4,0xe7));var _0x4a8d=function(_0x1da04e,_0x31024b){_0x1da04e=_0x1da04e-0x0;var _0xdd8c41=_0xa8d4[_0x1da04e];return _0xdd8c41;};'use strict';var util=require(_0x4a8d('0x0'));var _=require(_0x4a8d('0x1'));var Redis=require(_0x4a8d('0x2'));var interactionService=require('../../components/interaction/service');var qs=require('../../components/parsers/qs');var logger=require('../../config/logger')('api');var config=require('../../config/environment');var db=require(_0x4a8d('0x3'))['db'];config[_0x4a8d('0x4')]=_['defaults'](config['redis'],{'host':_0x4a8d('0x5'),'port':0x18eb});var socket=require(_0x4a8d('0x6'))(new Redis(config[_0x4a8d('0x4')]));require(_0x4a8d('0x7'))['register'](socket);var jayson=require('jayson/promise');var client=jayson[_0x4a8d('0x8')][_0x4a8d('0x9')]({'port':0x232c});var client9002=jayson['client']['http']({'port':0x232a});var interaction_log=require(_0x4a8d('0xa'))('openchannel-interactions');function respondWithRpcPromise(_0x1994fe,_0x5a787a,_0xbcfcf0,_0x59d2d2){return new Promise(function(_0x309977,_0x1100aa){var _0xd4dc79=_0x59d2d2||client;return _0xd4dc79[_0x4a8d('0xb')](_0x1994fe,_0xbcfcf0)[_0x4a8d('0xc')](function(_0x16f974){logger[_0x4a8d('0xd')](_0x4a8d('0xe'),_0x5a787a,_0x4a8d('0xf'));logger[_0x4a8d('0x10')]('OpenchannelMessage,\x20%s,\x20%s,\x20%s',_0x5a787a,'request\x20sent',JSON[_0x4a8d('0x11')](_0x16f974));if(_0x16f974[_0x4a8d('0x12')]){if(_0x16f974[_0x4a8d('0x12')][_0x4a8d('0x13')]===0x1f4){logger[_0x4a8d('0x12')](_0x4a8d('0xe'),_0x5a787a,_0x16f974[_0x4a8d('0x12')][_0x4a8d('0x14')]);return _0x1100aa(_0x16f974['error'][_0x4a8d('0x14')]);}logger['error'](_0x4a8d('0xe'),_0x5a787a,_0x16f974['error'][_0x4a8d('0x14')]);return _0x309977(_0x16f974[_0x4a8d('0x12')][_0x4a8d('0x14')]);}else{logger['info'](_0x4a8d('0xe'),_0x5a787a,_0x4a8d('0xf'));_0x309977(_0x16f974[_0x4a8d('0x15')][_0x4a8d('0x14')]);}})['catch'](function(_0x1f700b){logger[_0x4a8d('0x12')](_0x4a8d('0xe'),_0x5a787a,_0x1f700b);_0x1100aa(_0x1f700b);});});}function respondWithResult(_0x32996e,_0x535614){_0x535614=_0x535614||0xc8;return function(_0xce902e){if(_0xce902e){return _0x32996e[_0x4a8d('0x16')](_0x535614)[_0x4a8d('0x17')](_0xce902e);}};}function respondWithFilteredResult(_0x2755c0,_0x29ed67){return function(_0x37ac4e){if(_0x37ac4e){var _0x233030=typeof _0x29ed67[_0x4a8d('0x18')]===_0x4a8d('0x19')&&typeof _0x29ed67[_0x4a8d('0x1a')]===_0x4a8d('0x19');var _0xe7a2fe=_0x37ac4e[_0x4a8d('0x1b')];var _0xb4d0a5=_0x233030?0x0:_0x29ed67[_0x4a8d('0x18')];var _0xc2bac0=_0x233030?_0x37ac4e[_0x4a8d('0x1b')]:_0x29ed67[_0x4a8d('0x18')]+_0x29ed67[_0x4a8d('0x1a')];var _0x5c69b8;if(_0xc2bac0>=_0xe7a2fe){_0xc2bac0=_0xe7a2fe;_0x5c69b8=0xc8;}else{_0x5c69b8=0xce;}_0x2755c0[_0x4a8d('0x16')](_0x5c69b8);return _0x2755c0[_0x4a8d('0x1c')](_0x4a8d('0x1d'),_0xb4d0a5+'-'+_0xc2bac0+'/'+_0xe7a2fe)['json'](_0x37ac4e);}return null;};}function saveUpdates(_0x1d9098){return function(_0x598668){if(_0x598668){return _0x598668[_0x4a8d('0x1e')](_0x1d9098)[_0x4a8d('0xc')](function(_0x5d24c5){return _0x5d24c5;});}return null;};}function removeEntity(_0x2b93da){return function(_0x4d413f){if(_0x4d413f){return _0x4d413f[_0x4a8d('0x1f')]()[_0x4a8d('0xc')](function(){_0x2b93da[_0x4a8d('0x16')](0xcc)['end']();});}};}function handleEntityNotFound(_0x497e51){return function(_0x23aa61){if(!_0x23aa61){_0x497e51['sendStatus'](0x194);}return _0x23aa61;};}function handleError(_0x44ed58,_0x22cd0d){_0x22cd0d=_0x22cd0d||0x1f4;return function(_0x597473){logger[_0x4a8d('0x12')](_0x597473[_0x4a8d('0x20')]);if(_0x597473[_0x4a8d('0x21')]){delete _0x597473[_0x4a8d('0x21')];}_0x44ed58[_0x4a8d('0x16')](_0x22cd0d)['send'](_0x597473);};}exports['index']=function(_0x1c1d55,_0x1aa415){var _0x228672={},_0x2a9390={},_0x320c4e={'count':0x0,'rows':[]};var _0x4ed5f9=_[_0x4a8d('0x22')](db[_0x4a8d('0x23')]['rawAttributes'],function(_0x2a7422){return{'name':_0x2a7422[_0x4a8d('0x24')],'type':_0x2a7422[_0x4a8d('0x25')][_0x4a8d('0x26')]};});_0x2a9390['model']=_[_0x4a8d('0x22')](_0x4ed5f9,'name');_0x2a9390[_0x4a8d('0x27')]=_[_0x4a8d('0x28')](_0x1c1d55[_0x4a8d('0x27')]);_0x2a9390['filters']=_[_0x4a8d('0x29')](_0x2a9390[_0x4a8d('0x2a')],_0x2a9390[_0x4a8d('0x27')]);_0x228672[_0x4a8d('0x2b')]=_[_0x4a8d('0x29')](_0x2a9390[_0x4a8d('0x2a')],qs[_0x4a8d('0x2c')](_0x1c1d55[_0x4a8d('0x27')][_0x4a8d('0x2c')]));_0x228672[_0x4a8d('0x2b')]=_0x228672[_0x4a8d('0x2b')][_0x4a8d('0x2d')]?_0x228672['attributes']:_0x2a9390[_0x4a8d('0x2a')];if(!_0x1c1d55[_0x4a8d('0x27')][_0x4a8d('0x2e')](_0x4a8d('0x2f'))){_0x228672[_0x4a8d('0x1a')]=qs[_0x4a8d('0x1a')](_0x1c1d55[_0x4a8d('0x27')]['limit']);_0x228672['offset']=qs['offset'](_0x1c1d55[_0x4a8d('0x27')][_0x4a8d('0x18')]);}_0x228672['order']=qs[_0x4a8d('0x30')](_0x1c1d55['query'][_0x4a8d('0x30')]);_0x228672[_0x4a8d('0x31')]=qs[_0x4a8d('0x32')](_['pick'](_0x1c1d55['query'],_0x2a9390[_0x4a8d('0x32')]),_0x4ed5f9);if(_0x1c1d55['query'][_0x4a8d('0x33')]){_0x228672[_0x4a8d('0x31')]=_[_0x4a8d('0x34')](_0x228672[_0x4a8d('0x31')],{'$or':_[_0x4a8d('0x22')](_0x4ed5f9,function(_0x8c9b3b){if(_0x8c9b3b[_0x4a8d('0x25')]!==_0x4a8d('0x35')){var _0xe47932={};_0xe47932[_0x8c9b3b[_0x4a8d('0x21')]]={'$like':'%'+_0x1c1d55[_0x4a8d('0x27')][_0x4a8d('0x33')]+'%'};return _0xe47932;}})});}_0x228672=_[_0x4a8d('0x34')]({},_0x228672,_0x1c1d55['options']);var _0x50e9e0={'where':_0x228672['where']};return db['OpenchannelMessage'][_0x4a8d('0x1b')](_0x50e9e0)[_0x4a8d('0xc')](function(_0x44f7fc){_0x320c4e['count']=_0x44f7fc;if(_0x1c1d55[_0x4a8d('0x27')][_0x4a8d('0x36')]){_0x228672[_0x4a8d('0x37')]=[{'all':!![]}];}return db[_0x4a8d('0x23')]['findAll'](_0x228672);})[_0x4a8d('0xc')](function(_0x5413b7){_0x320c4e['rows']=_0x5413b7;return _0x320c4e;})[_0x4a8d('0xc')](respondWithFilteredResult(_0x1aa415,_0x228672))['catch'](handleError(_0x1aa415,null));};exports[_0x4a8d('0x38')]=function(_0x9deb,_0x80156b){var _0x8b24e2={'raw':!![],'where':{'id':_0x9deb[_0x4a8d('0x39')]['id']}},_0x34e13e={};_0x34e13e[_0x4a8d('0x2a')]=_[_0x4a8d('0x28')](db['OpenchannelMessage'][_0x4a8d('0x3a')]);_0x34e13e['query']=_['keys'](_0x9deb['query']);_0x34e13e['filters']=_[_0x4a8d('0x29')](_0x34e13e['model'],_0x34e13e['query']);_0x8b24e2[_0x4a8d('0x2b')]=_[_0x4a8d('0x29')](_0x34e13e[_0x4a8d('0x2a')],qs[_0x4a8d('0x2c')](_0x9deb[_0x4a8d('0x27')]['fields']));_0x8b24e2[_0x4a8d('0x2b')]=_0x8b24e2['attributes'][_0x4a8d('0x2d')]?_0x8b24e2[_0x4a8d('0x2b')]:_0x34e13e['model'];if(_0x9deb[_0x4a8d('0x27')]['includeAll']){_0x8b24e2[_0x4a8d('0x37')]=[{'all':!![]}];}_0x8b24e2=_[_0x4a8d('0x34')]({},_0x8b24e2,_0x9deb[_0x4a8d('0x3b')]);return db[_0x4a8d('0x23')][_0x4a8d('0x3c')](_0x8b24e2)['then'](handleEntityNotFound(_0x80156b,null))[_0x4a8d('0xc')](respondWithResult(_0x80156b,null))[_0x4a8d('0x3d')](handleError(_0x80156b,null));};exports[_0x4a8d('0x3e')]=function(_0x9645,_0x36ddf2){return db[_0x4a8d('0x23')][_0x4a8d('0x3e')](_0x9645['body'],{})['then'](respondWithResult(_0x36ddf2,0xc9))[_0x4a8d('0x3d')](handleError(_0x36ddf2,null));};exports[_0x4a8d('0x1e')]=function(_0x2dcae7,_0x1387a9){if(_0x2dcae7['body']['id']){delete _0x2dcae7[_0x4a8d('0x3f')]['id'];}return db[_0x4a8d('0x23')][_0x4a8d('0x3c')]({'where':{'id':_0x2dcae7[_0x4a8d('0x39')]['id']}})[_0x4a8d('0xc')](handleEntityNotFound(_0x1387a9,null))['then'](saveUpdates(_0x2dcae7['body'],null))[_0x4a8d('0xc')](respondWithResult(_0x1387a9,null))[_0x4a8d('0x3d')](handleError(_0x1387a9,null));};exports[_0x4a8d('0x1f')]=function(_0x9473c9,_0x28a77c){return db[_0x4a8d('0x23')][_0x4a8d('0x3c')]({'where':{'id':_0x9473c9['params']['id']}})[_0x4a8d('0xc')](handleEntityNotFound(_0x28a77c,null))['then'](removeEntity(_0x28a77c,null))['catch'](handleError(_0x28a77c,null));};exports[_0x4a8d('0x40')]=function(_0x130ae7,_0x58ec51){return db[_0x4a8d('0x23')][_0x4a8d('0x40')]()['then'](respondWithResult(_0x58ec51,null))['catch'](handleError(_0x58ec51,null));};exports['accept']=function(_0xbec1ab,_0x160915){var _0x3ec42c=_0x4a8d('0x41');return interactionService[_0x4a8d('0x42')](_0xbec1ab,_0x3ec42c)['then'](respondWithResult(_0x160915,null))[_0x4a8d('0x3d')](handleError(_0x160915,null));};exports[_0x4a8d('0x43')]=function(_0x6230e4,_0x4ce674){var _0x57c5d9={'agent':{},'channel':_0x4a8d('0x41')};if(_0x6230e4[_0x4a8d('0x3f')]['id']){delete _0x6230e4['body']['id'];}_0x6230e4[_0x4a8d('0x3f')]['UserId']=_0x6230e4[_0x4a8d('0x3f')][_0x4a8d('0x44')]||_0x6230e4[_0x4a8d('0x45')]['id'];_0x57c5d9[_0x4a8d('0x46')]['id']=_0x6230e4['body']['UserId'];return db[_0x4a8d('0x23')][_0x4a8d('0x3c')]({'where':{'id':_0x6230e4['params']['id'],'UserId':null}})['then'](handleEntityNotFound(_0x4ce674,null))[_0x4a8d('0xc')](function(_0x255d7c){if(_0x255d7c){_0x57c5d9[_0x4a8d('0x14')]=_0x255d7c[_0x4a8d('0x47')]({'plain':!![]});return db[_0x4a8d('0x48')]['find']({'where':{'id':_0x255d7c['OpenchannelInteractionId']}});}return null;})[_0x4a8d('0xc')](handleEntityNotFound(_0x4ce674,null))[_0x4a8d('0xc')](function(_0x23b2a3){if(_0x23b2a3){_0x57c5d9[_0x4a8d('0x49')]=_0x23b2a3[_0x4a8d('0x47')]({'plain':!![]});interaction_log['info']('[OPENCHANNELMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0x6230e4['user']['id'],_0x6230e4[_0x4a8d('0x45')][_0x4a8d('0x21')],_0x6230e4['user'][_0x4a8d('0x4a')],_0x57c5d9['interaction']['id'],_0x6230e4['body']?JSON[_0x4a8d('0x11')](_0x6230e4[_0x4a8d('0x3f')]):_0x4a8d('0x4b'));return respondWithRpcPromise(_0x4a8d('0x4c'),'rejectMessage',_0x57c5d9);}return null;})['then'](function(_0x47318c){var _0x238e81=_0x4a8d('0x4d')+_0x47318c['message'][_0x4a8d('0x4e')];return db[_0x4a8d('0x4f')][_0x4a8d('0x27')](_0x238e81,{'type':db[_0x4a8d('0x50')][_0x4a8d('0x51')][_0x4a8d('0x52')],'raw':!![]})[_0x4a8d('0xc')](function(_0x91be7){return _0x91be7;});})[_0x4a8d('0xc')](function(_0x3cfc64){if(_0x3cfc64){_0x57c5d9['message'][_0x4a8d('0x53')]=_0x3cfc64[0x0];if(!_0x6230e4[_0x4a8d('0x3f')][_0x4a8d('0x44')])return;return db[_0x4a8d('0x54')][_0x4a8d('0x3c')]({'where':{'id':_0x6230e4[_0x4a8d('0x3f')][_0x4a8d('0x44')],'role':'agent'},'attributes':['id',_0x4a8d('0x21'),_0x4a8d('0x55'),_0x4a8d('0x56'),'internal'],'raw':!![]});}return null;})['then'](function(_0x1f6339){if(!_0x1f6339)return null;_0x57c5d9['message']['agent']=_0x1f6339;return _0x57c5d9;})[_0x4a8d('0xc')](function(_0x213adc){if(_0x213adc){_0x213adc[_0x4a8d('0x14')][_0x4a8d('0x57')]=util['format']('SIP/%s',_0x6230e4[_0x4a8d('0x45')][_0x4a8d('0x21')]);_0x213adc[_0x4a8d('0x14')][_0x4a8d('0x58')]=_0x57c5d9[_0x4a8d('0x58')];_0x213adc[_0x4a8d('0x14')]['motionChannel']=_0x57c5d9['channel'];_0x213adc[_0x4a8d('0x14')]['event']=_0x4a8d('0x43');respondWithRpcPromise(_0x4a8d('0x59'),_0x4a8d('0x59'),{'event':_0x4a8d('0x5a'),'message':_0x213adc[_0x4a8d('0x14')]},client9002);return _0x57c5d9;}return null;})['then'](respondWithResult(_0x4ce674,null))[_0x4a8d('0x3d')](handleError(_0x4ce674,null));};
\ No newline at end of file