Built motion from commit 449495f6.|2.6.27
[motion2.git] / server / api / cannedAnswer / cannedAnswer.controller.js
index 672ca87..6bbf01a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xfbf4=['hasOwnProperty','nolimit','order','where','pick','filter','merge','map','VIRTUAL','options','count','include','findAll','rows','catch','show','params','find','body','create','MailAccountId','SmsAccountId','OpenchannelAccountId','ChatWebsiteId','Sequelize','ValidationError','The\x20inserted\x20key\x20already\x20exists.','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','util','path','ejs','lodash','squel','crypto','desk.js','to-csv','querystring','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../mysqldb','sendStatus','status','end','json','offset','limit','set','Content-Range','apply','reject','update','then','destroy','CannedAnswers','error','stack','name','send','index','CannedAnswer','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xfbf4,0x186));var _0x4fbf=function(_0x57c3a1,_0x3e9b2a){_0x57c3a1=_0x57c3a1-0x0;var _0x1e0084=_0xfbf4[_0x57c3a1];return _0x1e0084;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x4fbf('0x0'));var rimraf=require(_0x4fbf('0x1'));var zipdir=require(_0x4fbf('0x2'));var jsonpatch=require(_0x4fbf('0x3'));var rp=require('request-promise');var moment=require(_0x4fbf('0x4'));var BPromise=require(_0x4fbf('0x5'));var Mustache=require('mustache');var util=require(_0x4fbf('0x6'));var path=require(_0x4fbf('0x7'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0x4fbf('0x8'));var fs=require('fs');var _=require(_0x4fbf('0x9'));var squel=require(_0x4fbf('0xa'));var crypto=require(_0x4fbf('0xb'));var jsforce=require('jsforce');var deskjs=require(_0x4fbf('0xc'));var toCsv=require(_0x4fbf('0xd'));var querystring=require(_0x4fbf('0xe'));var Papa=require(_0x4fbf('0xf'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x4fbf('0x10'));var as=require(_0x4fbf('0x11'));var hardwareService=require(_0x4fbf('0x12'));var logger=require(_0x4fbf('0x13'))(_0x4fbf('0x14'));var utils=require(_0x4fbf('0x15'));var config=require('../../config/environment');var db=require(_0x4fbf('0x16'))['db'];function respondWithStatusCode(_0x51093b,_0x5ddfa2){_0x5ddfa2=_0x5ddfa2||0xcc;return function(_0x588178){if(_0x588178){return _0x51093b[_0x4fbf('0x17')](_0x5ddfa2);}return _0x51093b[_0x4fbf('0x18')](_0x5ddfa2)[_0x4fbf('0x19')]();};}function respondWithResult(_0x78b43e,_0x1ee996){_0x1ee996=_0x1ee996||0xc8;return function(_0x4216ac){if(_0x4216ac){return _0x78b43e[_0x4fbf('0x18')](_0x1ee996)[_0x4fbf('0x1a')](_0x4216ac);}};}function respondWithFilteredResult(_0x485cb6,_0x402744){return function(_0x483be2){if(_0x483be2){var _0x584e22=_0x483be2['count'],_0x132deb=_0x402744['offset'],_0x44480d=_0x402744[_0x4fbf('0x1b')]+_0x402744[_0x4fbf('0x1c')],_0x5c1bfb;if(_0x44480d>=_0x584e22){_0x44480d=_0x584e22;_0x5c1bfb=0xc8;}else{_0x5c1bfb=0xce;}_0x485cb6['status'](_0x5c1bfb);return _0x485cb6[_0x4fbf('0x1d')](_0x4fbf('0x1e'),_0x132deb+'-'+_0x44480d+'/'+_0x584e22)[_0x4fbf('0x1a')](_0x483be2);}return null;};}function patchUpdates(_0x472f55){return function(_0x1e2c62){try{jsonpatch[_0x4fbf('0x1f')](_0x1e2c62,_0x472f55,!![]);}catch(_0x19234d){return BPromise[_0x4fbf('0x20')](_0x19234d);}return _0x1e2c62['save']();};}function saveUpdates(_0x1bdfd0,_0x33136b){return function(_0xc2b74a){if(_0xc2b74a){return _0xc2b74a[_0x4fbf('0x21')](_0x1bdfd0)[_0x4fbf('0x22')](function(_0x5ddbbf){return _0x5ddbbf;});}return null;};}function removeEntity(_0x391689,_0x3a6a5b){return function(_0x2d967c){if(_0x2d967c){return _0x2d967c[_0x4fbf('0x23')]()[_0x4fbf('0x22')](function(){var _0x360f03=_0x2d967c['get']({'plain':!![]});var _0x20c6de=_0x4fbf('0x24');return db['UserProfileResource'][_0x4fbf('0x23')]({'where':{'type':_0x20c6de,'resourceId':_0x360f03['id']}})[_0x4fbf('0x22')](function(){return _0x2d967c;});})[_0x4fbf('0x22')](function(){_0x391689['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x59e15a,_0x49ce1c){return function(_0x3066c9){if(!_0x3066c9){_0x59e15a[_0x4fbf('0x17')](0x194);}return _0x3066c9;};}function handleError(_0x15be35,_0x5538b8){_0x5538b8=_0x5538b8||0x1f4;return function(_0x308674){logger[_0x4fbf('0x25')](_0x308674[_0x4fbf('0x26')]);if(_0x308674['name']){delete _0x308674[_0x4fbf('0x27')];}_0x15be35['status'](_0x5538b8)[_0x4fbf('0x28')](_0x308674);};}exports[_0x4fbf('0x29')]=function(_0x342437,_0x319f4f){var _0x4ab43f={},_0xee333a={},_0x436682={'count':0x0,'rows':[]};var _0x2e6e3a=_['map'](db[_0x4fbf('0x2a')][_0x4fbf('0x2b')],function(_0x2d7217){return{'name':_0x2d7217[_0x4fbf('0x2c')],'type':_0x2d7217[_0x4fbf('0x2d')][_0x4fbf('0x2e')]};});_0xee333a[_0x4fbf('0x2f')]=_['map'](_0x2e6e3a,_0x4fbf('0x27'));_0xee333a[_0x4fbf('0x30')]=_[_0x4fbf('0x31')](_0x342437[_0x4fbf('0x30')]);_0xee333a[_0x4fbf('0x32')]=_[_0x4fbf('0x33')](_0xee333a['model'],_0xee333a[_0x4fbf('0x30')]);_0x4ab43f[_0x4fbf('0x34')]=_[_0x4fbf('0x33')](_0xee333a['model'],qs[_0x4fbf('0x35')](_0x342437[_0x4fbf('0x30')][_0x4fbf('0x35')]));_0x4ab43f[_0x4fbf('0x34')]=_0x4ab43f[_0x4fbf('0x34')][_0x4fbf('0x36')]?_0x4ab43f['attributes']:_0xee333a['model'];if(!_0x342437['query'][_0x4fbf('0x37')](_0x4fbf('0x38'))){_0x4ab43f[_0x4fbf('0x1c')]=qs[_0x4fbf('0x1c')](_0x342437['query'][_0x4fbf('0x1c')]);_0x4ab43f['offset']=qs[_0x4fbf('0x1b')](_0x342437['query']['offset']);}_0x4ab43f[_0x4fbf('0x39')]=qs['sort'](_0x342437[_0x4fbf('0x30')]['sort']);_0x4ab43f[_0x4fbf('0x3a')]=qs[_0x4fbf('0x32')](_[_0x4fbf('0x3b')](_0x342437[_0x4fbf('0x30')],_0xee333a[_0x4fbf('0x32')]),_0x2e6e3a);if(_0x342437[_0x4fbf('0x30')][_0x4fbf('0x3c')]){_0x4ab43f['where']=_[_0x4fbf('0x3d')](_0x4ab43f['where'],{'$or':_[_0x4fbf('0x3e')](_0x2e6e3a,function(_0xa9e1d7){if(_0xa9e1d7[_0x4fbf('0x2d')]!==_0x4fbf('0x3f')){var _0x47bdba={};_0x47bdba[_0xa9e1d7[_0x4fbf('0x27')]]={'$like':'%'+_0x342437[_0x4fbf('0x30')]['filter']+'%'};return _0x47bdba;}})});}_0x4ab43f=_['merge']({},_0x4ab43f,_0x342437[_0x4fbf('0x40')]);var _0x33762d={'where':_0x4ab43f['where']};return db[_0x4fbf('0x2a')][_0x4fbf('0x41')](_0x33762d)['then'](function(_0x291fa4){_0x436682[_0x4fbf('0x41')]=_0x291fa4;if(_0x342437[_0x4fbf('0x30')]['includeAll']){_0x4ab43f[_0x4fbf('0x42')]=[{'all':!![]}];}return db[_0x4fbf('0x2a')][_0x4fbf('0x43')](_0x4ab43f);})[_0x4fbf('0x22')](function(_0x69ea7){_0x436682[_0x4fbf('0x44')]=_0x69ea7;return _0x436682;})[_0x4fbf('0x22')](respondWithFilteredResult(_0x319f4f,_0x4ab43f))[_0x4fbf('0x45')](handleError(_0x319f4f,null));};exports[_0x4fbf('0x46')]=function(_0x58ef81,_0x50559f){var _0x883075={'raw':!![],'where':{'id':_0x58ef81[_0x4fbf('0x47')]['id']}},_0x58f333={};_0x58f333[_0x4fbf('0x2f')]=_[_0x4fbf('0x31')](db[_0x4fbf('0x2a')][_0x4fbf('0x2b')]);_0x58f333['query']=_[_0x4fbf('0x31')](_0x58ef81['query']);_0x58f333[_0x4fbf('0x32')]=_['intersection'](_0x58f333[_0x4fbf('0x2f')],_0x58f333[_0x4fbf('0x30')]);_0x883075[_0x4fbf('0x34')]=_[_0x4fbf('0x33')](_0x58f333[_0x4fbf('0x2f')],qs['fields'](_0x58ef81[_0x4fbf('0x30')][_0x4fbf('0x35')]));_0x883075[_0x4fbf('0x34')]=_0x883075['attributes'][_0x4fbf('0x36')]?_0x883075[_0x4fbf('0x34')]:_0x58f333[_0x4fbf('0x2f')];if(_0x58ef81[_0x4fbf('0x30')]['includeAll']){_0x883075['include']=[{'all':!![]}];}_0x883075=_[_0x4fbf('0x3d')]({},_0x883075,_0x58ef81['options']);return db['CannedAnswer'][_0x4fbf('0x48')](_0x883075)[_0x4fbf('0x22')](handleEntityNotFound(_0x50559f,null))[_0x4fbf('0x22')](respondWithResult(_0x50559f,null))[_0x4fbf('0x45')](handleError(_0x50559f,null));};exports[_0x4fbf('0x21')]=function(_0x2457b6,_0x269fa7){if(_0x2457b6[_0x4fbf('0x49')]['id']){delete _0x2457b6[_0x4fbf('0x49')]['id'];}return db['CannedAnswer'][_0x4fbf('0x48')]({'where':{'id':_0x2457b6[_0x4fbf('0x47')]['id']}})[_0x4fbf('0x22')](handleEntityNotFound(_0x269fa7,null))['then'](saveUpdates(_0x2457b6[_0x4fbf('0x49')],null))[_0x4fbf('0x22')](respondWithResult(_0x269fa7,null))[_0x4fbf('0x45')](handleError(_0x269fa7,null));};exports[_0x4fbf('0x23')]=function(_0x35ea78,_0x1dbcc0){return db['CannedAnswer'][_0x4fbf('0x48')]({'where':{'id':_0x35ea78['params']['id']}})['then'](handleEntityNotFound(_0x1dbcc0,null))[_0x4fbf('0x22')](removeEntity(_0x1dbcc0,null))[_0x4fbf('0x45')](handleError(_0x1dbcc0,null));};exports[_0x4fbf('0x4a')]=function(_0x372c77,_0x3c5a8c){var _0xc46ace={'key':_0x372c77['body'][_0x4fbf('0x2e')]};if(_0x372c77[_0x4fbf('0x49')][_0x4fbf('0x4b')]){_0xc46ace[_0x4fbf('0x4b')]=_0x372c77[_0x4fbf('0x49')][_0x4fbf('0x4b')];}else if(_0x372c77[_0x4fbf('0x49')][_0x4fbf('0x4c')]){_0xc46ace[_0x4fbf('0x4c')]=_0x372c77[_0x4fbf('0x49')]['SmsAccountId'];}else if(_0x372c77[_0x4fbf('0x49')]['OpenchannelAccountId']){_0xc46ace[_0x4fbf('0x4d')]=_0x372c77[_0x4fbf('0x49')][_0x4fbf('0x4d')];}else if(_0x372c77[_0x4fbf('0x49')][_0x4fbf('0x4e')]){_0xc46ace[_0x4fbf('0x4e')]=_0x372c77[_0x4fbf('0x49')][_0x4fbf('0x4e')];}return db[_0x4fbf('0x2a')][_0x4fbf('0x48')]({'where':_0xc46ace})[_0x4fbf('0x22')](function(_0x267281){if(_0x267281){throw new db[(_0x4fbf('0x4f'))][(_0x4fbf('0x50'))](_0x4fbf('0x51'));}return db[_0x4fbf('0x2a')][_0x4fbf('0x4a')](_0x372c77[_0x4fbf('0x49')]);})[_0x4fbf('0x22')](function(_0x28f8ce){var _0x5e8174=_0x372c77[_0x4fbf('0x52')][_0x4fbf('0x53')]({'plain':!![]});if(!_0x5e8174)throw new Error(_0x4fbf('0x54'));if(_0x5e8174['role']===_0x4fbf('0x52')){var _0x4c16f6=_0x28f8ce[_0x4fbf('0x53')]({'plain':!![]});return db['UserProfileSection'][_0x4fbf('0x48')]({'where':{'name':'CannedAnswers','userProfileId':_0x5e8174[_0x4fbf('0x55')]},'raw':!![]})['then'](function(_0x2acf48){if(_0x2acf48&&_0x2acf48[_0x4fbf('0x56')]===0x0){return db[_0x4fbf('0x57')][_0x4fbf('0x4a')]({'name':_0x4c16f6['name'],'resourceId':_0x4c16f6['id'],'type':_0x2acf48[_0x4fbf('0x27')],'sectionId':_0x2acf48['id']},{})[_0x4fbf('0x22')](function(){return _0x28f8ce;});}else{return _0x28f8ce;}})[_0x4fbf('0x45')](function(_0x2f54a1){logger[_0x4fbf('0x25')](_0x4fbf('0x58'),_0x2f54a1);throw _0x2f54a1;});}return _0x28f8ce;})[_0x4fbf('0x22')](respondWithResult(_0x3c5a8c,0xc9))['catch'](handleError(_0x3c5a8c,null));};
\ No newline at end of file
+var _0x9b99=['findAll','rows','catch','show','keys','length','merge','body','find','params','create','MailAccountId','SmsAccountId','OpenchannelAccountId','ChatWebsiteId','Sequelize','ValidationError','The\x20inserted\x20key\x20already\x20exists.','user','userProfileId','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','eml-format','zip-dir','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','save','update','then','destroy','get','CannedAnswers','UserProfileResource','stack','name','send','index','fieldName','type','key','model','query','filters','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','where','filter','options','CannedAnswer','includeAll','include'];(function(_0x5e9dec,_0x3f4684){var _0x338054=function(_0x317dac){while(--_0x317dac){_0x5e9dec['push'](_0x5e9dec['shift']());}};_0x338054(++_0x3f4684);}(_0x9b99,0x17b));var _0x99b9=function(_0x495686,_0x3ce623){_0x495686=_0x495686-0x0;var _0x428c4f=_0x9b99[_0x495686];return _0x428c4f;};'use strict';var emlformat=require(_0x99b9('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x99b9('0x1'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x99b9('0x2'));var Mustache=require(_0x99b9('0x3'));var util=require(_0x99b9('0x4'));var path=require(_0x99b9('0x5'));var sox=require(_0x99b9('0x6'));var csv=require(_0x99b9('0x7'));var ejs=require(_0x99b9('0x8'));var fs=require('fs');var fs_extra=require(_0x99b9('0x9'));var _=require(_0x99b9('0xa'));var squel=require(_0x99b9('0xb'));var crypto=require(_0x99b9('0xc'));var jsforce=require(_0x99b9('0xd'));var deskjs=require(_0x99b9('0xe'));var toCsv=require(_0x99b9('0x7'));var querystring=require(_0x99b9('0xf'));var Papa=require(_0x99b9('0x10'));var Redis=require(_0x99b9('0x11'));var authService=require(_0x99b9('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0x99b9('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x99b9('0x14'))(_0x99b9('0x15'));var utils=require(_0x99b9('0x16'));var config=require(_0x99b9('0x17'));var licenseUtil=require(_0x99b9('0x18'));var db=require(_0x99b9('0x19'))['db'];function respondWithStatusCode(_0x56b3a6,_0x598860){_0x598860=_0x598860||0xcc;return function(_0x40803a){if(_0x40803a){return _0x56b3a6['sendStatus'](_0x598860);}return _0x56b3a6[_0x99b9('0x1a')](_0x598860)[_0x99b9('0x1b')]();};}function respondWithResult(_0x117fa8,_0x4b7388){_0x4b7388=_0x4b7388||0xc8;return function(_0x3763c5){if(_0x3763c5){return _0x117fa8['status'](_0x4b7388)[_0x99b9('0x1c')](_0x3763c5);}};}function respondWithFilteredResult(_0x4c03d3,_0xcfa141){return function(_0x186f79){if(_0x186f79){var _0x292715=typeof _0xcfa141[_0x99b9('0x1d')]===_0x99b9('0x1e')&&typeof _0xcfa141[_0x99b9('0x1f')]===_0x99b9('0x1e');var _0x2fe9c0=_0x186f79[_0x99b9('0x20')];var _0xe1fd86=_0x292715?0x0:_0xcfa141[_0x99b9('0x1d')];var _0x8b4614=_0x292715?_0x186f79['count']:_0xcfa141['offset']+_0xcfa141[_0x99b9('0x1f')];var _0x4a6033;if(_0x8b4614>=_0x2fe9c0){_0x8b4614=_0x2fe9c0;_0x4a6033=0xc8;}else{_0x4a6033=0xce;}_0x4c03d3[_0x99b9('0x1a')](_0x4a6033);return _0x4c03d3[_0x99b9('0x21')](_0x99b9('0x22'),_0xe1fd86+'-'+_0x8b4614+'/'+_0x2fe9c0)[_0x99b9('0x1c')](_0x186f79);}return null;};}function patchUpdates(_0x4a2edf){return function(_0x1e4a10){try{jsonpatch[_0x99b9('0x23')](_0x1e4a10,_0x4a2edf,!![]);}catch(_0x2ffa53){return BPromise['reject'](_0x2ffa53);}return _0x1e4a10[_0x99b9('0x24')]();};}function saveUpdates(_0x4d88f3,_0x280993){return function(_0x166425){if(_0x166425){return _0x166425[_0x99b9('0x25')](_0x4d88f3)[_0x99b9('0x26')](function(_0x158939){return _0x158939;});}return null;};}function removeEntity(_0x4bbf2e,_0x4cbfc6){return function(_0x4fe351){if(_0x4fe351){return _0x4fe351[_0x99b9('0x27')]()[_0x99b9('0x26')](function(){var _0x4bb343=_0x4fe351[_0x99b9('0x28')]({'plain':!![]});var _0x341ddf=_0x99b9('0x29');return db[_0x99b9('0x2a')][_0x99b9('0x27')]({'where':{'type':_0x341ddf,'resourceId':_0x4bb343['id']}})[_0x99b9('0x26')](function(){return _0x4fe351;});})[_0x99b9('0x26')](function(){_0x4bbf2e[_0x99b9('0x1a')](0xcc)['end']();});}};}function handleEntityNotFound(_0x3c8737,_0x25aa0a){return function(_0x36c61e){if(!_0x36c61e){_0x3c8737['sendStatus'](0x194);}return _0x36c61e;};}function handleError(_0x224d54,_0x5d9b8e){_0x5d9b8e=_0x5d9b8e||0x1f4;return function(_0x242de3){logger['error'](_0x242de3[_0x99b9('0x2b')]);if(_0x242de3[_0x99b9('0x2c')]){delete _0x242de3[_0x99b9('0x2c')];}_0x224d54[_0x99b9('0x1a')](_0x5d9b8e)[_0x99b9('0x2d')](_0x242de3);};}exports[_0x99b9('0x2e')]=function(_0x36de04,_0x390280){var _0x194e8f={},_0x1169a4={},_0x31f86c={'count':0x0,'rows':[]};var _0x985738=_['map'](db['CannedAnswer']['rawAttributes'],function(_0x310b11){return{'name':_0x310b11[_0x99b9('0x2f')],'type':_0x310b11[_0x99b9('0x30')][_0x99b9('0x31')]};});_0x1169a4[_0x99b9('0x32')]=_['map'](_0x985738,_0x99b9('0x2c'));_0x1169a4[_0x99b9('0x33')]=_['keys'](_0x36de04['query']);_0x1169a4[_0x99b9('0x34')]=_[_0x99b9('0x35')](_0x1169a4[_0x99b9('0x32')],_0x1169a4[_0x99b9('0x33')]);_0x194e8f[_0x99b9('0x36')]=_[_0x99b9('0x35')](_0x1169a4[_0x99b9('0x32')],qs[_0x99b9('0x37')](_0x36de04[_0x99b9('0x33')][_0x99b9('0x37')]));_0x194e8f['attributes']=_0x194e8f['attributes']['length']?_0x194e8f['attributes']:_0x1169a4[_0x99b9('0x32')];if(!_0x36de04[_0x99b9('0x33')][_0x99b9('0x38')](_0x99b9('0x39'))){_0x194e8f['limit']=qs['limit'](_0x36de04[_0x99b9('0x33')][_0x99b9('0x1f')]);_0x194e8f['offset']=qs['offset'](_0x36de04['query'][_0x99b9('0x1d')]);}_0x194e8f[_0x99b9('0x3a')]=qs[_0x99b9('0x3b')](_0x36de04[_0x99b9('0x33')][_0x99b9('0x3b')]);_0x194e8f[_0x99b9('0x3c')]=qs[_0x99b9('0x34')](_['pick'](_0x36de04[_0x99b9('0x33')],_0x1169a4['filters']),_0x985738);if(_0x36de04[_0x99b9('0x33')][_0x99b9('0x3d')]){_0x194e8f[_0x99b9('0x3c')]=_['merge'](_0x194e8f[_0x99b9('0x3c')],{'$or':[{'key':{'$like':'%'+_0x36de04[_0x99b9('0x33')]['filter']+'%'}},{'value':{'$like':'%'+_0x36de04[_0x99b9('0x33')][_0x99b9('0x3d')]+'%'}}]});}_0x194e8f=_['merge']({},_0x194e8f,_0x36de04[_0x99b9('0x3e')]);var _0x4b0c88={'where':_0x194e8f[_0x99b9('0x3c')]};return db[_0x99b9('0x3f')][_0x99b9('0x20')](_0x4b0c88)[_0x99b9('0x26')](function(_0x21c8a7){_0x31f86c['count']=_0x21c8a7;if(_0x36de04['query'][_0x99b9('0x40')]){_0x194e8f[_0x99b9('0x41')]=[{'all':!![]}];}return db[_0x99b9('0x3f')][_0x99b9('0x42')](_0x194e8f);})[_0x99b9('0x26')](function(_0x43d734){_0x31f86c[_0x99b9('0x43')]=_0x43d734;return _0x31f86c;})[_0x99b9('0x26')](respondWithFilteredResult(_0x390280,_0x194e8f))[_0x99b9('0x44')](handleError(_0x390280,null));};exports[_0x99b9('0x45')]=function(_0x1ac729,_0x228546){var _0xe685bd={'raw':!![],'where':{'id':_0x1ac729['params']['id']}},_0x408a75={};_0x408a75[_0x99b9('0x32')]=_[_0x99b9('0x46')](db[_0x99b9('0x3f')]['rawAttributes']);_0x408a75[_0x99b9('0x33')]=_[_0x99b9('0x46')](_0x1ac729[_0x99b9('0x33')]);_0x408a75[_0x99b9('0x34')]=_['intersection'](_0x408a75[_0x99b9('0x32')],_0x408a75[_0x99b9('0x33')]);_0xe685bd[_0x99b9('0x36')]=_[_0x99b9('0x35')](_0x408a75[_0x99b9('0x32')],qs[_0x99b9('0x37')](_0x1ac729['query'][_0x99b9('0x37')]));_0xe685bd[_0x99b9('0x36')]=_0xe685bd[_0x99b9('0x36')][_0x99b9('0x47')]?_0xe685bd['attributes']:_0x408a75[_0x99b9('0x32')];if(_0x1ac729[_0x99b9('0x33')][_0x99b9('0x40')]){_0xe685bd['include']=[{'all':!![]}];}_0xe685bd=_[_0x99b9('0x48')]({},_0xe685bd,_0x1ac729[_0x99b9('0x3e')]);return db[_0x99b9('0x3f')]['find'](_0xe685bd)[_0x99b9('0x26')](handleEntityNotFound(_0x228546,null))['then'](respondWithResult(_0x228546,null))[_0x99b9('0x44')](handleError(_0x228546,null));};exports[_0x99b9('0x25')]=function(_0x3a29ea,_0x61fb97){if(_0x3a29ea[_0x99b9('0x49')]['id']){delete _0x3a29ea['body']['id'];}return db[_0x99b9('0x3f')][_0x99b9('0x4a')]({'where':{'id':_0x3a29ea[_0x99b9('0x4b')]['id']}})['then'](handleEntityNotFound(_0x61fb97,null))[_0x99b9('0x26')](saveUpdates(_0x3a29ea[_0x99b9('0x49')],null))['then'](respondWithResult(_0x61fb97,null))[_0x99b9('0x44')](handleError(_0x61fb97,null));};exports['destroy']=function(_0x5c3b88,_0x49ed0a){return db[_0x99b9('0x3f')][_0x99b9('0x4a')]({'where':{'id':_0x5c3b88['params']['id']}})[_0x99b9('0x26')](handleEntityNotFound(_0x49ed0a,null))[_0x99b9('0x26')](removeEntity(_0x49ed0a,null))['catch'](handleError(_0x49ed0a,null));};exports[_0x99b9('0x4c')]=function(_0x2dc040,_0x48fe4f){var _0xfc2c6f={'key':_0x2dc040[_0x99b9('0x49')]['key']};if(_0x2dc040['body'][_0x99b9('0x4d')]){_0xfc2c6f[_0x99b9('0x4d')]=_0x2dc040[_0x99b9('0x49')][_0x99b9('0x4d')];}else if(_0x2dc040['body']['SmsAccountId']){_0xfc2c6f[_0x99b9('0x4e')]=_0x2dc040['body'][_0x99b9('0x4e')];}else if(_0x2dc040['body'][_0x99b9('0x4f')]){_0xfc2c6f[_0x99b9('0x4f')]=_0x2dc040[_0x99b9('0x49')][_0x99b9('0x4f')];}else if(_0x2dc040['body']['ChatWebsiteId']){_0xfc2c6f[_0x99b9('0x50')]=_0x2dc040['body'][_0x99b9('0x50')];}return db[_0x99b9('0x3f')]['find']({'where':_0xfc2c6f})[_0x99b9('0x26')](function(_0x1223f6){if(_0x1223f6){throw new db[(_0x99b9('0x51'))][(_0x99b9('0x52'))](_0x99b9('0x53'));}return db[_0x99b9('0x3f')][_0x99b9('0x4c')](_0x2dc040[_0x99b9('0x49')]);})[_0x99b9('0x26')](function(_0x2cbb3c){var _0x422dfe=_0x2dc040['user'][_0x99b9('0x28')]({'plain':!![]});if(!_0x422dfe)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x422dfe['role']===_0x99b9('0x54')){var _0x481754=_0x2cbb3c[_0x99b9('0x28')]({'plain':!![]});return db['UserProfileSection'][_0x99b9('0x4a')]({'where':{'name':_0x99b9('0x29'),'userProfileId':_0x422dfe[_0x99b9('0x55')]},'raw':!![]})['then'](function(_0x17b780){if(_0x17b780&&_0x17b780[_0x99b9('0x56')]===0x0){return db[_0x99b9('0x2a')][_0x99b9('0x4c')]({'name':_0x481754[_0x99b9('0x2c')],'resourceId':_0x481754['id'],'type':_0x17b780['name'],'sectionId':_0x17b780['id']},{})[_0x99b9('0x26')](function(){return _0x2cbb3c;});}else{return _0x2cbb3c;}})[_0x99b9('0x44')](function(_0x46e9cc){logger[_0x99b9('0x57')](_0x99b9('0x58'),_0x46e9cc);throw _0x46e9cc;});}return _0x2cbb3c;})['then'](respondWithResult(_0x48fe4f,0xc9))[_0x99b9('0x44')](handleError(_0x48fe4f,null));};
\ No newline at end of file