Built motion from commit (unavailable).|2.5.4
[motion2.git] / server / api / openchannelMessage / openchannelMessage.controller.js
index 3e7f273..8f1e6eb 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf40b=['jayson/promise','client','http','ValidationError','The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.','request','then','OpenchannelMessage,\x20%s,\x20%s','debug','OpenchannelMessage,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','message','info','status','end','json','count','offset','limit','Content-Range','apply','save','update','destroy','sendStatus','stack','name','send','index','map','OpenchannelMessage','rawAttributes','fieldName','type','key','keys','query','filters','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','findAll','rows','catch','show','params','includeAll','include','find','create','body','describe','../../config/logger','openchannel-interactions','openchannel','read','readAt','format','UserId','user','CmContact','Contact','get','OpenchannelInteraction','isNil','read1stAt','interaction','[OPENCHANNELMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','role','null','acceptMessage','interface','channel','event','accept','EventManager','RejectMessage','rejectMessage','SIP/%s','rejectmessage','html-pdf','eml-format','rimraf','zip-dir','moment','mustache','util','path','ejs','crypto','jsforce','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','api','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','register'];(function(_0x380af2,_0x36cf66){var _0x1789dc=function(_0x37b604){while(--_0x37b604){_0x380af2['push'](_0x380af2['shift']());}};_0x1789dc(++_0x36cf66);}(_0xf40b,0x14e));var _0xbf40=function(_0xbe0d54,_0x5c3362){_0xbe0d54=_0xbe0d54-0x0;var _0x13e619=_0xf40b[_0xbe0d54];return _0x13e619;};'use strict';var pdf=require(_0xbf40('0x0'));var emlformat=require(_0xbf40('0x1'));var rimraf=require(_0xbf40('0x2'));var zipdir=require(_0xbf40('0x3'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0xbf40('0x4'));var BPromise=require('bluebird');var Mustache=require(_0xbf40('0x5'));var util=require(_0xbf40('0x6'));var path=require(_0xbf40('0x7'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0xbf40('0x8'));var fs=require('fs');var _=require('lodash');var squel=require('squel');var crypto=require(_0xbf40('0x9'));var jsforce=require(_0xbf40('0xa'));var deskjs=require('desk.js');var toCsv=require(_0xbf40('0xb'));var querystring=require(_0xbf40('0xc'));var Papa=require(_0xbf40('0xd'));var Redis=require(_0xbf40('0xe'));var authService=require(_0xbf40('0xf'));var qs=require(_0xbf40('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0xbf40('0x11'));var utils=require(_0xbf40('0x12'));var config=require(_0xbf40('0x13'));var db=require(_0xbf40('0x14'))['db'];config[_0xbf40('0x15')]=_[_0xbf40('0x16')](config['redis'],{'host':_0xbf40('0x17'),'port':0x18eb});var socket=require(_0xbf40('0x18'))(new Redis(config[_0xbf40('0x15')]));require('./openchannelMessage.socket')[_0xbf40('0x19')](socket);var jayson=require(_0xbf40('0x1a'));var client=jayson['client']['http']({'port':0x232c});var client9002=jayson[_0xbf40('0x1b')][_0xbf40('0x1c')]({'port':0x232a});function checkPasswordPattern(_0x581928,_0xda65f,_0x9528ad){if(_0x9528ad){var _0x57bfb8=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x57bfb8['test'](_0xda65f)){return _0x581928;}else{throw new db['Sequelize'][(_0xbf40('0x1d'))](_0xbf40('0x1e'));}}else{return _0x581928;}}function respondWithRpcPromise(_0x3a047a,_0x329d31,_0x58388c,_0xd5d3a1){return new BPromise(function(_0x48cbe8,_0x269b7e){var _0x3ac4e7=_0xd5d3a1||client;return _0x3ac4e7[_0xbf40('0x1f')](_0x3a047a,_0x58388c)[_0xbf40('0x20')](function(_0x5f2aa0){logger['info'](_0xbf40('0x21'),_0x329d31,'request\x20sent');logger[_0xbf40('0x22')](_0xbf40('0x23'),_0x329d31,_0xbf40('0x24'),JSON[_0xbf40('0x25')](_0x5f2aa0));if(_0x5f2aa0[_0xbf40('0x26')]){if(_0x5f2aa0[_0xbf40('0x26')]['code']===0x1f4){logger[_0xbf40('0x26')](_0xbf40('0x21'),_0x329d31,_0x5f2aa0[_0xbf40('0x26')][_0xbf40('0x27')]);return _0x269b7e(_0x5f2aa0['error']['message']);}logger[_0xbf40('0x26')](_0xbf40('0x21'),_0x329d31,_0x5f2aa0[_0xbf40('0x26')][_0xbf40('0x27')]);return _0x48cbe8(_0x5f2aa0['error'][_0xbf40('0x27')]);}else{logger[_0xbf40('0x28')]('OpenchannelMessage,\x20%s,\x20%s',_0x329d31,_0xbf40('0x24'));_0x48cbe8(_0x5f2aa0['result'][_0xbf40('0x27')]);}})['catch'](function(_0x562c7c){logger[_0xbf40('0x26')](_0xbf40('0x21'),_0x329d31,_0x562c7c);_0x269b7e(_0x562c7c);});});}function respondWithStatusCode(_0x154f13,_0x33f4c4){_0x33f4c4=_0x33f4c4||0xcc;return function(_0x4e589a){if(_0x4e589a){return _0x154f13['sendStatus'](_0x33f4c4);}return _0x154f13[_0xbf40('0x29')](_0x33f4c4)[_0xbf40('0x2a')]();};}function respondWithResult(_0x19f6ba,_0x2085e1){_0x2085e1=_0x2085e1||0xc8;return function(_0x52c8df){if(_0x52c8df){return _0x19f6ba[_0xbf40('0x29')](_0x2085e1)[_0xbf40('0x2b')](_0x52c8df);}};}function respondWithFilteredResult(_0x26ea4a,_0x320335){return function(_0x49cf65){if(_0x49cf65){var _0x2772ea=_0x49cf65[_0xbf40('0x2c')],_0x2d0124=_0x320335[_0xbf40('0x2d')],_0x4b6551=_0x320335[_0xbf40('0x2d')]+_0x320335[_0xbf40('0x2e')],_0x1d3be2;if(_0x4b6551>=_0x2772ea){_0x4b6551=_0x2772ea;_0x1d3be2=0xc8;}else{_0x1d3be2=0xce;}_0x26ea4a[_0xbf40('0x29')](_0x1d3be2);return _0x26ea4a['set'](_0xbf40('0x2f'),_0x2d0124+'-'+_0x4b6551+'/'+_0x2772ea)[_0xbf40('0x2b')](_0x49cf65);}return null;};}function patchUpdates(_0x3d9ec0){return function(_0x29d28c){try{jsonpatch[_0xbf40('0x30')](_0x29d28c,_0x3d9ec0,!![]);}catch(_0x41d44c){return BPromise['reject'](_0x41d44c);}return _0x29d28c[_0xbf40('0x31')]();};}function saveUpdates(_0xb4bdba,_0x46fe06){return function(_0x196275){if(_0x196275){return _0x196275[_0xbf40('0x32')](_0xb4bdba)['then'](function(_0xbc96a4){return _0xbc96a4;});}return null;};}function removeEntity(_0x293af8,_0x5a4168){return function(_0x5c3e7c){if(_0x5c3e7c){return _0x5c3e7c[_0xbf40('0x33')]()[_0xbf40('0x20')](function(){_0x293af8[_0xbf40('0x29')](0xcc)[_0xbf40('0x2a')]();});}};}function handleEntityNotFound(_0xa1d782,_0x157e2c){return function(_0x1b110c){if(!_0x1b110c){_0xa1d782[_0xbf40('0x34')](0x194);}return _0x1b110c;};}function handleError(_0x34eda5,_0x1e5076){_0x1e5076=_0x1e5076||0x1f4;return function(_0x4855f3){logger[_0xbf40('0x26')](_0x4855f3[_0xbf40('0x35')]);if(_0x4855f3[_0xbf40('0x36')]){delete _0x4855f3['name'];}_0x34eda5[_0xbf40('0x29')](_0x1e5076)[_0xbf40('0x37')](_0x4855f3);};}exports[_0xbf40('0x38')]=function(_0x3907eb,_0x1b6e6d){var _0x5f496e={},_0x4aae71={},_0x3cc2ee={'count':0x0,'rows':[]};var _0x117b61=_[_0xbf40('0x39')](db[_0xbf40('0x3a')][_0xbf40('0x3b')],function(_0x2519c3){return{'name':_0x2519c3[_0xbf40('0x3c')],'type':_0x2519c3[_0xbf40('0x3d')][_0xbf40('0x3e')]};});_0x4aae71['model']=_[_0xbf40('0x39')](_0x117b61,'name');_0x4aae71['query']=_[_0xbf40('0x3f')](_0x3907eb[_0xbf40('0x40')]);_0x4aae71[_0xbf40('0x41')]=_[_0xbf40('0x42')](_0x4aae71[_0xbf40('0x43')],_0x4aae71[_0xbf40('0x40')]);_0x5f496e[_0xbf40('0x44')]=_[_0xbf40('0x42')](_0x4aae71[_0xbf40('0x43')],qs[_0xbf40('0x45')](_0x3907eb[_0xbf40('0x40')][_0xbf40('0x45')]));_0x5f496e[_0xbf40('0x44')]=_0x5f496e[_0xbf40('0x44')][_0xbf40('0x46')]?_0x5f496e[_0xbf40('0x44')]:_0x4aae71[_0xbf40('0x43')];if(!_0x3907eb[_0xbf40('0x40')][_0xbf40('0x47')](_0xbf40('0x48'))){_0x5f496e[_0xbf40('0x2e')]=qs[_0xbf40('0x2e')](_0x3907eb['query'][_0xbf40('0x2e')]);_0x5f496e[_0xbf40('0x2d')]=qs[_0xbf40('0x2d')](_0x3907eb[_0xbf40('0x40')][_0xbf40('0x2d')]);}_0x5f496e[_0xbf40('0x49')]=qs[_0xbf40('0x4a')](_0x3907eb[_0xbf40('0x40')][_0xbf40('0x4a')]);_0x5f496e[_0xbf40('0x4b')]=qs[_0xbf40('0x41')](_[_0xbf40('0x4c')](_0x3907eb[_0xbf40('0x40')],_0x4aae71['filters']),_0x117b61);if(_0x3907eb['query'][_0xbf40('0x4d')]){_0x5f496e[_0xbf40('0x4b')]=_[_0xbf40('0x4e')](_0x5f496e[_0xbf40('0x4b')],{'$or':_[_0xbf40('0x39')](_0x117b61,function(_0x32ea7e){if(_0x32ea7e['type']!==_0xbf40('0x4f')){var _0x48661b={};_0x48661b[_0x32ea7e[_0xbf40('0x36')]]={'$like':'%'+_0x3907eb[_0xbf40('0x40')][_0xbf40('0x4d')]+'%'};return _0x48661b;}})});}_0x5f496e=_[_0xbf40('0x4e')]({},_0x5f496e,_0x3907eb[_0xbf40('0x50')]);var _0x36751a={'where':_0x5f496e['where']};return db['OpenchannelMessage'][_0xbf40('0x2c')](_0x36751a)[_0xbf40('0x20')](function(_0x5dc2f7){_0x3cc2ee[_0xbf40('0x2c')]=_0x5dc2f7;if(_0x3907eb[_0xbf40('0x40')]['includeAll']){_0x5f496e['include']=[{'all':!![]}];}return db[_0xbf40('0x3a')][_0xbf40('0x51')](_0x5f496e);})[_0xbf40('0x20')](function(_0x2bdb57){_0x3cc2ee[_0xbf40('0x52')]=_0x2bdb57;return _0x3cc2ee;})[_0xbf40('0x20')](respondWithFilteredResult(_0x1b6e6d,_0x5f496e))[_0xbf40('0x53')](handleError(_0x1b6e6d,null));};exports[_0xbf40('0x54')]=function(_0xe75ddb,_0x57aa06){var _0x23bda2={'raw':!![],'where':{'id':_0xe75ddb[_0xbf40('0x55')]['id']}},_0x358f24={};_0x358f24['model']=_['keys'](db[_0xbf40('0x3a')][_0xbf40('0x3b')]);_0x358f24[_0xbf40('0x40')]=_[_0xbf40('0x3f')](_0xe75ddb[_0xbf40('0x40')]);_0x358f24[_0xbf40('0x41')]=_['intersection'](_0x358f24[_0xbf40('0x43')],_0x358f24[_0xbf40('0x40')]);_0x23bda2[_0xbf40('0x44')]=_[_0xbf40('0x42')](_0x358f24[_0xbf40('0x43')],qs['fields'](_0xe75ddb[_0xbf40('0x40')][_0xbf40('0x45')]));_0x23bda2['attributes']=_0x23bda2[_0xbf40('0x44')][_0xbf40('0x46')]?_0x23bda2[_0xbf40('0x44')]:_0x358f24[_0xbf40('0x43')];if(_0xe75ddb[_0xbf40('0x40')][_0xbf40('0x56')]){_0x23bda2[_0xbf40('0x57')]=[{'all':!![]}];}_0x23bda2=_[_0xbf40('0x4e')]({},_0x23bda2,_0xe75ddb[_0xbf40('0x50')]);return db[_0xbf40('0x3a')][_0xbf40('0x58')](_0x23bda2)['then'](handleEntityNotFound(_0x57aa06,null))[_0xbf40('0x20')](respondWithResult(_0x57aa06,null))[_0xbf40('0x53')](handleError(_0x57aa06,null));};exports[_0xbf40('0x59')]=function(_0x39bd93,_0x2d519b){return db[_0xbf40('0x3a')]['create'](_0x39bd93[_0xbf40('0x5a')],{})[_0xbf40('0x20')](respondWithResult(_0x2d519b,0xc9))[_0xbf40('0x53')](handleError(_0x2d519b,null));};exports[_0xbf40('0x32')]=function(_0x52248,_0x45b04f){if(_0x52248[_0xbf40('0x5a')]['id']){delete _0x52248[_0xbf40('0x5a')]['id'];}return db[_0xbf40('0x3a')][_0xbf40('0x58')]({'where':{'id':_0x52248[_0xbf40('0x55')]['id']}})['then'](handleEntityNotFound(_0x45b04f,null))[_0xbf40('0x20')](saveUpdates(_0x52248[_0xbf40('0x5a')],null))[_0xbf40('0x20')](respondWithResult(_0x45b04f,null))[_0xbf40('0x53')](handleError(_0x45b04f,null));};exports['destroy']=function(_0x25bc4e,_0x3c603c){return db[_0xbf40('0x3a')]['find']({'where':{'id':_0x25bc4e['params']['id']}})[_0xbf40('0x20')](handleEntityNotFound(_0x3c603c,null))[_0xbf40('0x20')](removeEntity(_0x3c603c,null))[_0xbf40('0x53')](handleError(_0x3c603c,null));};exports['describe']=function(_0x3162ba,_0x189a4b){return db[_0xbf40('0x3a')][_0xbf40('0x5b')]()['then'](respondWithResult(_0x189a4b,null))[_0xbf40('0x53')](handleError(_0x189a4b,null));};var interaction_log=require(_0xbf40('0x5c'))(_0xbf40('0x5d'));exports['accept']=function(_0x548724,_0x357b6e,_0x9714c6){var _0xb1d76f={'channel':_0xbf40('0x5e')};if(_0x548724[_0xbf40('0x5a')]['id']){delete _0x548724[_0xbf40('0x5a')]['id'];}_0x548724[_0xbf40('0x5a')][_0xbf40('0x5f')]=!![];_0x548724[_0xbf40('0x5a')][_0xbf40('0x60')]=moment()[_0xbf40('0x61')]('YYYY-MM-DD\x20HH:mm:ss');_0x548724['body'][_0xbf40('0x62')]=_0x548724['body'][_0xbf40('0x62')]||_0x548724[_0xbf40('0x63')]['id'];return db[_0xbf40('0x3a')]['find']({'where':{'id':_0x548724[_0xbf40('0x55')]['id'],'UserId':null},'include':[{'model':db[_0xbf40('0x64')],'as':_0xbf40('0x65')}]})[_0xbf40('0x20')](handleEntityNotFound(_0x357b6e,null))['then'](saveUpdates(_0x548724[_0xbf40('0x5a')],null))[_0xbf40('0x20')](function(_0x38e8d1){if(_0x38e8d1){_0xb1d76f[_0xbf40('0x27')]=_0x38e8d1[_0xbf40('0x66')]({'plain':!![]});return db[_0xbf40('0x67')][_0xbf40('0x58')]({'where':{'id':_0x38e8d1['OpenchannelInteractionId']}});}return null;})[_0xbf40('0x20')](handleEntityNotFound(_0x357b6e,null))[_0xbf40('0x20')](function(_0x530823){if(_0x530823){return _0x530823['update']({'UserId':_0x548724['body'][_0xbf40('0x62')],'read1stAt':_[_0xbf40('0x68')](_0x530823[_0xbf40('0x69')])?moment()['format']('YYYY-MM-DD\x20HH:mm:ss'):undefined});}return null;})[_0xbf40('0x20')](function(_0x195d0d){if(_0x195d0d){_0xb1d76f[_0xbf40('0x6a')]=_0x195d0d[_0xbf40('0x66')]({'plain':!![]});interaction_log[_0xbf40('0x28')](_0xbf40('0x6b'),_0x548724[_0xbf40('0x63')]['id'],_0x548724['user']['name'],_0x548724[_0xbf40('0x63')][_0xbf40('0x6c')],_0xb1d76f[_0xbf40('0x6a')]['id'],_0x548724[_0xbf40('0x5a')]?JSON[_0xbf40('0x25')](_0x548724[_0xbf40('0x5a')]):_0xbf40('0x6d'));return respondWithRpcPromise('AcceptMessage',_0xbf40('0x6e'),_0xb1d76f);}return null;})[_0xbf40('0x20')](function(_0x2eb7e0){if(_0x2eb7e0){if(_0x548724[_0xbf40('0x5a')]['manual']){_0xb1d76f[_0xbf40('0x27')][_0xbf40('0x6f')]=util[_0xbf40('0x61')]('SIP/%s',_0x548724[_0xbf40('0x63')][_0xbf40('0x36')]);_0xb1d76f[_0xbf40('0x27')][_0xbf40('0x70')]=_0xb1d76f['channel'];_0xb1d76f['message'][_0xbf40('0x71')]=_0xbf40('0x72');return respondWithRpcPromise('EventManager',_0xbf40('0x73'),{'event':'acceptmessage','message':_0xb1d76f[_0xbf40('0x27')]},client9002)[_0xbf40('0x20')](function(){return _0xb1d76f;});}return _0xb1d76f;}return null;})[_0xbf40('0x20')](respondWithResult(_0x357b6e,null))[_0xbf40('0x53')](handleError(_0x357b6e,null));};var interaction_log=require('../../config/logger')(_0xbf40('0x5d'));exports['reject']=function(_0x77d42a,_0x17df33,_0xe998b9){var _0x282c04={'agent':{},'channel':_0xbf40('0x5e')};if(_0x77d42a['body']['id']){delete _0x77d42a[_0xbf40('0x5a')]['id'];}_0x77d42a[_0xbf40('0x5a')][_0xbf40('0x62')]=_0x77d42a[_0xbf40('0x5a')][_0xbf40('0x62')]||_0x77d42a[_0xbf40('0x63')]['id'];_0x282c04['agent']['id']=_0x77d42a[_0xbf40('0x5a')][_0xbf40('0x62')];return db['OpenchannelMessage']['find']({'where':{'id':_0x77d42a[_0xbf40('0x55')]['id'],'UserId':null}})[_0xbf40('0x20')](handleEntityNotFound(_0x17df33,null))['then'](function(_0x42abed){if(_0x42abed){_0x282c04[_0xbf40('0x27')]=_0x42abed[_0xbf40('0x66')]({'plain':!![]});return db['OpenchannelInteraction'][_0xbf40('0x58')]({'where':{'id':_0x42abed['OpenchannelInteractionId']}});}return null;})[_0xbf40('0x20')](handleEntityNotFound(_0x17df33,null))['then'](function(_0x63c96b){if(_0x63c96b){_0x282c04[_0xbf40('0x6a')]=_0x63c96b[_0xbf40('0x66')]({'plain':!![]});interaction_log[_0xbf40('0x28')]('[OPENCHANNELMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0x77d42a[_0xbf40('0x63')]['id'],_0x77d42a[_0xbf40('0x63')][_0xbf40('0x36')],_0x77d42a[_0xbf40('0x63')][_0xbf40('0x6c')],_0x282c04[_0xbf40('0x6a')]['id'],_0x77d42a[_0xbf40('0x5a')]?JSON[_0xbf40('0x25')](_0x77d42a[_0xbf40('0x5a')]):_0xbf40('0x6d'));return respondWithRpcPromise(_0xbf40('0x74'),_0xbf40('0x75'),_0x282c04);}return null;})[_0xbf40('0x20')](function(_0x45d51e){if(_0x45d51e){_0x45d51e[_0xbf40('0x27')][_0xbf40('0x6f')]=util[_0xbf40('0x61')](_0xbf40('0x76'),_0x77d42a[_0xbf40('0x63')][_0xbf40('0x36')]);_0x45d51e[_0xbf40('0x27')]['channel']=_0x282c04[_0xbf40('0x70')];_0x45d51e['message'][_0xbf40('0x71')]='reject';respondWithRpcPromise(_0xbf40('0x73'),'EventManager',{'event':_0xbf40('0x77'),'message':_0x45d51e[_0xbf40('0x27')]},client9002);return _0x282c04;}return null;})['then'](respondWithResult(_0x17df33,null))[_0xbf40('0x53')](handleError(_0x17df33,null));};
\ No newline at end of file
+var _0x21f6=['create','body','describe','accept','openchannel','read','readAt','YYYY-MM-DD\x20HH:mm:ss','UserId','user','CmContact','Contact','get','OpenchannelInteraction','OpenchannelInteractionId','[OPENCHANNELMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','interaction','null','acceptMessage','manual','interface','format','SIP/%s','channel','event','EventManager','acceptmessage','openchannel-interactions','reject','agent','[OPENCHANNELMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','role','RejectMessage','rejectMessage','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','mustache','util','sox','to-csv','ejs','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./openchannelMessage.socket','jayson/promise','client','http','test','ValidationError','The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.','request','then','info','OpenchannelMessage,\x20%s,\x20%s','request\x20sent','debug','OpenchannelMessage,\x20%s,\x20%s,\x20%s','stringify','error','message','result','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','save','update','destroy','name','send','map','OpenchannelMessage','rawAttributes','fieldName','type','query','keys','filters','intersection','attributes','model','length','hasOwnProperty','nolimit','order','sort','merge','where','VIRTUAL','filter','options','includeAll','include','findAll','catch','show','params','fields','find'];(function(_0x277340,_0x2efc91){var _0x314cd1=function(_0x45c371){while(--_0x45c371){_0x277340['push'](_0x277340['shift']());}};_0x314cd1(++_0x2efc91);}(_0x21f6,0x11c));var _0x621f=function(_0x1f5b57,_0x5c21ac){_0x1f5b57=_0x1f5b57-0x0;var _0xef15b1=_0x21f6[_0x1f5b57];return _0xef15b1;};'use strict';var pdf=require(_0x621f('0x0'));var emlformat=require(_0x621f('0x1'));var rimraf=require(_0x621f('0x2'));var zipdir=require(_0x621f('0x3'));var jsonpatch=require(_0x621f('0x4'));var rp=require(_0x621f('0x5'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x621f('0x6'));var util=require(_0x621f('0x7'));var path=require('path');var sox=require(_0x621f('0x8'));var csv=require(_0x621f('0x9'));var ejs=require(_0x621f('0xa'));var fs=require('fs');var _=require('lodash');var squel=require('squel');var crypto=require(_0x621f('0xb'));var jsforce=require(_0x621f('0xc'));var deskjs=require(_0x621f('0xd'));var toCsv=require('to-csv');var querystring=require(_0x621f('0xe'));var Papa=require(_0x621f('0xf'));var Redis=require(_0x621f('0x10'));var authService=require(_0x621f('0x11'));var qs=require(_0x621f('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x621f('0x13'));var logger=require(_0x621f('0x14'))(_0x621f('0x15'));var utils=require(_0x621f('0x16'));var config=require(_0x621f('0x17'));var db=require(_0x621f('0x18'))['db'];config[_0x621f('0x19')]=_[_0x621f('0x1a')](config[_0x621f('0x19')],{'host':_0x621f('0x1b'),'port':0x18eb});var socket=require(_0x621f('0x1c'))(new Redis(config[_0x621f('0x19')]));require(_0x621f('0x1d'))['register'](socket);var jayson=require(_0x621f('0x1e'));var client=jayson[_0x621f('0x1f')][_0x621f('0x20')]({'port':0x232c});var client9002=jayson['client'][_0x621f('0x20')]({'port':0x232a});function checkPasswordPattern(_0x47feb7,_0x506486,_0x3eb02f){if(_0x3eb02f){var _0x3ee6d1=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x3ee6d1[_0x621f('0x21')](_0x506486)){return _0x47feb7;}else{throw new db['Sequelize'][(_0x621f('0x22'))](_0x621f('0x23'));}}else{return _0x47feb7;}}function respondWithRpcPromise(_0x472893,_0x3c1d4d,_0x4aa4fc,_0x4597f4){return new BPromise(function(_0xf36d28,_0x25f49c){var _0x354927=_0x4597f4||client;return _0x354927[_0x621f('0x24')](_0x472893,_0x4aa4fc)[_0x621f('0x25')](function(_0x4d5828){logger[_0x621f('0x26')](_0x621f('0x27'),_0x3c1d4d,_0x621f('0x28'));logger[_0x621f('0x29')](_0x621f('0x2a'),_0x3c1d4d,_0x621f('0x28'),JSON[_0x621f('0x2b')](_0x4d5828));if(_0x4d5828[_0x621f('0x2c')]){if(_0x4d5828[_0x621f('0x2c')]['code']===0x1f4){logger[_0x621f('0x2c')](_0x621f('0x27'),_0x3c1d4d,_0x4d5828[_0x621f('0x2c')][_0x621f('0x2d')]);return _0x25f49c(_0x4d5828[_0x621f('0x2c')]['message']);}logger[_0x621f('0x2c')](_0x621f('0x27'),_0x3c1d4d,_0x4d5828[_0x621f('0x2c')][_0x621f('0x2d')]);return _0xf36d28(_0x4d5828[_0x621f('0x2c')]['message']);}else{logger[_0x621f('0x26')]('OpenchannelMessage,\x20%s,\x20%s',_0x3c1d4d,'request\x20sent');_0xf36d28(_0x4d5828[_0x621f('0x2e')][_0x621f('0x2d')]);}})['catch'](function(_0x42b649){logger['error']('OpenchannelMessage,\x20%s,\x20%s',_0x3c1d4d,_0x42b649);_0x25f49c(_0x42b649);});});}function respondWithStatusCode(_0x24e8ec,_0x459550){_0x459550=_0x459550||0xcc;return function(_0x47f19e){if(_0x47f19e){return _0x24e8ec[_0x621f('0x2f')](_0x459550);}return _0x24e8ec[_0x621f('0x30')](_0x459550)[_0x621f('0x31')]();};}function respondWithResult(_0x365277,_0x2fa5e9){_0x2fa5e9=_0x2fa5e9||0xc8;return function(_0x2c6dec){if(_0x2c6dec){return _0x365277[_0x621f('0x30')](_0x2fa5e9)[_0x621f('0x32')](_0x2c6dec);}};}function respondWithFilteredResult(_0x68a1f,_0x252bed){return function(_0x2f5e79){if(_0x2f5e79){var _0x90bc99=_0x2f5e79[_0x621f('0x33')],_0x25b0f5=_0x252bed[_0x621f('0x34')],_0x5e3e38=_0x252bed[_0x621f('0x34')]+_0x252bed[_0x621f('0x35')],_0x57b2a0;if(_0x5e3e38>=_0x90bc99){_0x5e3e38=_0x90bc99;_0x57b2a0=0xc8;}else{_0x57b2a0=0xce;}_0x68a1f[_0x621f('0x30')](_0x57b2a0);return _0x68a1f[_0x621f('0x36')](_0x621f('0x37'),_0x25b0f5+'-'+_0x5e3e38+'/'+_0x90bc99)['json'](_0x2f5e79);}return null;};}function patchUpdates(_0x514eaa){return function(_0x2355aa){try{jsonpatch[_0x621f('0x38')](_0x2355aa,_0x514eaa,!![]);}catch(_0x3c89a3){return BPromise['reject'](_0x3c89a3);}return _0x2355aa[_0x621f('0x39')]();};}function saveUpdates(_0x5ca574,_0x1bcecf){return function(_0x31344b){if(_0x31344b){return _0x31344b[_0x621f('0x3a')](_0x5ca574)['then'](function(_0x108c1a){return _0x108c1a;});}return null;};}function removeEntity(_0x50617b,_0x26b773){return function(_0x3ea23b){if(_0x3ea23b){return _0x3ea23b[_0x621f('0x3b')]()[_0x621f('0x25')](function(){_0x50617b[_0x621f('0x30')](0xcc)[_0x621f('0x31')]();});}};}function handleEntityNotFound(_0x5c3d63,_0x4cc6ba){return function(_0x1f9956){if(!_0x1f9956){_0x5c3d63[_0x621f('0x2f')](0x194);}return _0x1f9956;};}function handleError(_0x55abb3,_0x2fc99d){_0x2fc99d=_0x2fc99d||0x1f4;return function(_0x3c8782){logger[_0x621f('0x2c')](_0x3c8782['stack']);if(_0x3c8782[_0x621f('0x3c')]){delete _0x3c8782[_0x621f('0x3c')];}_0x55abb3[_0x621f('0x30')](_0x2fc99d)[_0x621f('0x3d')](_0x3c8782);};}exports['index']=function(_0x561e8e,_0x257c70){var _0x3ad777={},_0x3c810d={},_0x20037f={'count':0x0,'rows':[]};var _0xb204b6=_[_0x621f('0x3e')](db[_0x621f('0x3f')][_0x621f('0x40')],function(_0x3449d5){return{'name':_0x3449d5[_0x621f('0x41')],'type':_0x3449d5[_0x621f('0x42')]['key']};});_0x3c810d['model']=_['map'](_0xb204b6,_0x621f('0x3c'));_0x3c810d[_0x621f('0x43')]=_[_0x621f('0x44')](_0x561e8e[_0x621f('0x43')]);_0x3c810d[_0x621f('0x45')]=_[_0x621f('0x46')](_0x3c810d['model'],_0x3c810d['query']);_0x3ad777[_0x621f('0x47')]=_[_0x621f('0x46')](_0x3c810d[_0x621f('0x48')],qs['fields'](_0x561e8e['query']['fields']));_0x3ad777[_0x621f('0x47')]=_0x3ad777[_0x621f('0x47')][_0x621f('0x49')]?_0x3ad777[_0x621f('0x47')]:_0x3c810d[_0x621f('0x48')];if(!_0x561e8e[_0x621f('0x43')][_0x621f('0x4a')](_0x621f('0x4b'))){_0x3ad777[_0x621f('0x35')]=qs[_0x621f('0x35')](_0x561e8e[_0x621f('0x43')][_0x621f('0x35')]);_0x3ad777[_0x621f('0x34')]=qs[_0x621f('0x34')](_0x561e8e[_0x621f('0x43')]['offset']);}_0x3ad777[_0x621f('0x4c')]=qs[_0x621f('0x4d')](_0x561e8e[_0x621f('0x43')][_0x621f('0x4d')]);_0x3ad777['where']=qs[_0x621f('0x45')](_['pick'](_0x561e8e[_0x621f('0x43')],_0x3c810d[_0x621f('0x45')]),_0xb204b6);if(_0x561e8e['query']['filter']){_0x3ad777['where']=_[_0x621f('0x4e')](_0x3ad777[_0x621f('0x4f')],{'$or':_[_0x621f('0x3e')](_0xb204b6,function(_0x5a4521){if(_0x5a4521[_0x621f('0x42')]!==_0x621f('0x50')){var _0x20d625={};_0x20d625[_0x5a4521['name']]={'$like':'%'+_0x561e8e[_0x621f('0x43')][_0x621f('0x51')]+'%'};return _0x20d625;}})});}_0x3ad777=_[_0x621f('0x4e')]({},_0x3ad777,_0x561e8e[_0x621f('0x52')]);var _0x1f7751={'where':_0x3ad777['where']};return db[_0x621f('0x3f')][_0x621f('0x33')](_0x1f7751)[_0x621f('0x25')](function(_0xe5f5bc){_0x20037f[_0x621f('0x33')]=_0xe5f5bc;if(_0x561e8e[_0x621f('0x43')][_0x621f('0x53')]){_0x3ad777[_0x621f('0x54')]=[{'all':!![]}];}return db[_0x621f('0x3f')][_0x621f('0x55')](_0x3ad777);})[_0x621f('0x25')](function(_0x4d6bdc){_0x20037f['rows']=_0x4d6bdc;return _0x20037f;})[_0x621f('0x25')](respondWithFilteredResult(_0x257c70,_0x3ad777))[_0x621f('0x56')](handleError(_0x257c70,null));};exports[_0x621f('0x57')]=function(_0x5607c8,_0x1a1fc6){var _0x39f807={'raw':!![],'where':{'id':_0x5607c8[_0x621f('0x58')]['id']}},_0x186e61={};_0x186e61['model']=_[_0x621f('0x44')](db[_0x621f('0x3f')]['rawAttributes']);_0x186e61[_0x621f('0x43')]=_[_0x621f('0x44')](_0x5607c8[_0x621f('0x43')]);_0x186e61[_0x621f('0x45')]=_[_0x621f('0x46')](_0x186e61[_0x621f('0x48')],_0x186e61['query']);_0x39f807[_0x621f('0x47')]=_[_0x621f('0x46')](_0x186e61['model'],qs[_0x621f('0x59')](_0x5607c8['query'][_0x621f('0x59')]));_0x39f807[_0x621f('0x47')]=_0x39f807[_0x621f('0x47')][_0x621f('0x49')]?_0x39f807['attributes']:_0x186e61[_0x621f('0x48')];if(_0x5607c8[_0x621f('0x43')][_0x621f('0x53')]){_0x39f807[_0x621f('0x54')]=[{'all':!![]}];}_0x39f807=_[_0x621f('0x4e')]({},_0x39f807,_0x5607c8[_0x621f('0x52')]);return db[_0x621f('0x3f')][_0x621f('0x5a')](_0x39f807)['then'](handleEntityNotFound(_0x1a1fc6,null))['then'](respondWithResult(_0x1a1fc6,null))[_0x621f('0x56')](handleError(_0x1a1fc6,null));};exports[_0x621f('0x5b')]=function(_0x355f98,_0x5ba926){return db['OpenchannelMessage']['create'](_0x355f98[_0x621f('0x5c')],{})[_0x621f('0x25')](respondWithResult(_0x5ba926,0xc9))[_0x621f('0x56')](handleError(_0x5ba926,null));};exports[_0x621f('0x3a')]=function(_0x3613cb,_0x859b1d){if(_0x3613cb[_0x621f('0x5c')]['id']){delete _0x3613cb['body']['id'];}return db[_0x621f('0x3f')][_0x621f('0x5a')]({'where':{'id':_0x3613cb[_0x621f('0x58')]['id']}})['then'](handleEntityNotFound(_0x859b1d,null))['then'](saveUpdates(_0x3613cb[_0x621f('0x5c')],null))[_0x621f('0x25')](respondWithResult(_0x859b1d,null))[_0x621f('0x56')](handleError(_0x859b1d,null));};exports[_0x621f('0x3b')]=function(_0x78c151,_0x17d1dd){return db[_0x621f('0x3f')][_0x621f('0x5a')]({'where':{'id':_0x78c151[_0x621f('0x58')]['id']}})[_0x621f('0x25')](handleEntityNotFound(_0x17d1dd,null))[_0x621f('0x25')](removeEntity(_0x17d1dd,null))[_0x621f('0x56')](handleError(_0x17d1dd,null));};exports['describe']=function(_0x2862a7,_0x941f83){return db['OpenchannelMessage'][_0x621f('0x5d')]()[_0x621f('0x25')](respondWithResult(_0x941f83,null))['catch'](handleError(_0x941f83,null));};var interaction_log=require('../../config/logger')('openchannel-interactions');exports[_0x621f('0x5e')]=function(_0x5d0f6f,_0x3b80ed,_0x4a2e2b){var _0x1fb229={'channel':_0x621f('0x5f')};if(_0x5d0f6f[_0x621f('0x5c')]['id']){delete _0x5d0f6f[_0x621f('0x5c')]['id'];}_0x5d0f6f[_0x621f('0x5c')][_0x621f('0x60')]=!![];_0x5d0f6f[_0x621f('0x5c')][_0x621f('0x61')]=moment()['format'](_0x621f('0x62'));_0x5d0f6f['body'][_0x621f('0x63')]=_0x5d0f6f[_0x621f('0x5c')][_0x621f('0x63')]||_0x5d0f6f[_0x621f('0x64')]['id'];return db['OpenchannelMessage'][_0x621f('0x5a')]({'where':{'id':_0x5d0f6f[_0x621f('0x58')]['id'],'UserId':null},'include':[{'model':db[_0x621f('0x65')],'as':_0x621f('0x66')}]})[_0x621f('0x25')](handleEntityNotFound(_0x3b80ed,null))['then'](saveUpdates(_0x5d0f6f[_0x621f('0x5c')],null))[_0x621f('0x25')](function(_0x23d354){if(_0x23d354){_0x1fb229[_0x621f('0x2d')]=_0x23d354[_0x621f('0x67')]({'plain':!![]});return db[_0x621f('0x68')]['find']({'where':{'id':_0x23d354[_0x621f('0x69')]}});}return null;})['then'](handleEntityNotFound(_0x3b80ed,null))[_0x621f('0x25')](function(_0x12502d){if(_0x12502d){return _0x12502d['update']({'UserId':_0x5d0f6f[_0x621f('0x5c')][_0x621f('0x63')],'read1stAt':_['isNil'](_0x12502d['read1stAt'])?moment()['format'](_0x621f('0x62')):undefined});}return null;})[_0x621f('0x25')](function(_0xf7ce18){if(_0xf7ce18){_0x1fb229['interaction']=_0xf7ce18[_0x621f('0x67')]({'plain':!![]});interaction_log[_0x621f('0x26')](_0x621f('0x6a'),_0x5d0f6f['user']['id'],_0x5d0f6f['user'][_0x621f('0x3c')],_0x5d0f6f[_0x621f('0x64')]['role'],_0x1fb229[_0x621f('0x6b')]['id'],_0x5d0f6f[_0x621f('0x5c')]?JSON['stringify'](_0x5d0f6f[_0x621f('0x5c')]):_0x621f('0x6c'));return respondWithRpcPromise('AcceptMessage',_0x621f('0x6d'),_0x1fb229);}return null;})[_0x621f('0x25')](function(_0x56543e){if(_0x56543e){if(_0x5d0f6f[_0x621f('0x5c')][_0x621f('0x6e')]){_0x1fb229[_0x621f('0x2d')][_0x621f('0x6f')]=util[_0x621f('0x70')](_0x621f('0x71'),_0x5d0f6f['user']['name']);_0x1fb229[_0x621f('0x2d')][_0x621f('0x72')]=_0x1fb229[_0x621f('0x72')];_0x1fb229['message'][_0x621f('0x73')]=_0x621f('0x5e');return respondWithRpcPromise(_0x621f('0x74'),_0x621f('0x74'),{'event':_0x621f('0x75'),'message':_0x1fb229['message']},client9002)[_0x621f('0x25')](function(){return _0x1fb229;});}return _0x1fb229;}return null;})[_0x621f('0x25')](respondWithResult(_0x3b80ed,null))['catch'](handleError(_0x3b80ed,null));};var interaction_log=require('../../config/logger')(_0x621f('0x76'));exports[_0x621f('0x77')]=function(_0xa0eea8,_0x5ed3dd,_0x544a16){var _0x4d6d53={'agent':{},'channel':_0x621f('0x5f')};if(_0xa0eea8[_0x621f('0x5c')]['id']){delete _0xa0eea8[_0x621f('0x5c')]['id'];}_0xa0eea8[_0x621f('0x5c')][_0x621f('0x63')]=_0xa0eea8[_0x621f('0x5c')][_0x621f('0x63')]||_0xa0eea8[_0x621f('0x64')]['id'];_0x4d6d53[_0x621f('0x78')]['id']=_0xa0eea8[_0x621f('0x5c')][_0x621f('0x63')];return db['OpenchannelMessage']['find']({'where':{'id':_0xa0eea8['params']['id'],'UserId':null}})[_0x621f('0x25')](handleEntityNotFound(_0x5ed3dd,null))[_0x621f('0x25')](function(_0x15a48){if(_0x15a48){_0x4d6d53[_0x621f('0x2d')]=_0x15a48[_0x621f('0x67')]({'plain':!![]});return db[_0x621f('0x68')][_0x621f('0x5a')]({'where':{'id':_0x15a48[_0x621f('0x69')]}});}return null;})[_0x621f('0x25')](handleEntityNotFound(_0x5ed3dd,null))[_0x621f('0x25')](function(_0x15f298){if(_0x15f298){_0x4d6d53[_0x621f('0x6b')]=_0x15f298[_0x621f('0x67')]({'plain':!![]});interaction_log[_0x621f('0x26')](_0x621f('0x79'),_0xa0eea8[_0x621f('0x64')]['id'],_0xa0eea8['user'][_0x621f('0x3c')],_0xa0eea8[_0x621f('0x64')][_0x621f('0x7a')],_0x4d6d53[_0x621f('0x6b')]['id'],_0xa0eea8[_0x621f('0x5c')]?JSON['stringify'](_0xa0eea8[_0x621f('0x5c')]):_0x621f('0x6c'));return respondWithRpcPromise(_0x621f('0x7b'),_0x621f('0x7c'),_0x4d6d53);}return null;})[_0x621f('0x25')](function(_0x2a3648){if(_0x2a3648){_0x2a3648[_0x621f('0x2d')]['interface']=util['format']('SIP/%s',_0xa0eea8[_0x621f('0x64')][_0x621f('0x3c')]);_0x2a3648['message'][_0x621f('0x72')]=_0x4d6d53[_0x621f('0x72')];_0x2a3648[_0x621f('0x2d')]['event']=_0x621f('0x77');respondWithRpcPromise(_0x621f('0x74'),_0x621f('0x74'),{'event':'rejectmessage','message':_0x2a3648[_0x621f('0x2d')]},client9002);return _0x4d6d53;}return null;})[_0x621f('0x25')](respondWithResult(_0x5ed3dd,null))[_0x621f('0x56')](handleError(_0x5ed3dd,null));};
\ No newline at end of file