Built motion from commit ffdca78c.|2.6.24
[motion2.git] / server / api / cannedAnswer / cannedAnswer.controller.js
index 2843115..9710d4a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb9ff=['path','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','apply','reject','save','update','then','destroy','UserProfileResource','error','stack','name','index','map','CannedAnswer','fieldName','type','key','model','keys','query','filters','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','where','filter','merge','options','include','rows','catch','show','params','rawAttributes','length','find','body','MailAccountId','SmsAccountId','OpenchannelAccountId','ChatWebsiteId','Sequelize','ValidationError','The\x20inserted\x20key\x20already\x20exists.','create','user','role','UserProfileSection','CannedAnswers','userProfileId','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','mustache','util'];(function(_0x277fa3,_0x3b2dde){var _0x2e4520=function(_0x209eab){while(--_0x209eab){_0x277fa3['push'](_0x277fa3['shift']());}};_0x2e4520(++_0x3b2dde);}(_0xb9ff,0xa5));var _0xfb9f=function(_0x4eb4e1,_0x1b3caa){_0x4eb4e1=_0x4eb4e1-0x0;var _0x116b49=_0xb9ff[_0x4eb4e1];return _0x116b49;};'use strict';var emlformat=require(_0xfb9f('0x0'));var rimraf=require(_0xfb9f('0x1'));var zipdir=require(_0xfb9f('0x2'));var jsonpatch=require(_0xfb9f('0x3'));var rp=require(_0xfb9f('0x4'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0xfb9f('0x5'));var util=require(_0xfb9f('0x6'));var path=require(_0xfb9f('0x7'));var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xfb9f('0x8'));var _=require(_0xfb9f('0x9'));var squel=require(_0xfb9f('0xa'));var crypto=require(_0xfb9f('0xb'));var jsforce=require(_0xfb9f('0xc'));var deskjs=require(_0xfb9f('0xd'));var toCsv=require('to-csv');var querystring=require(_0xfb9f('0xe'));var Papa=require('papaparse');var Redis=require(_0xfb9f('0xf'));var authService=require('../../components/auth/service');var qs=require(_0xfb9f('0x10'));var as=require(_0xfb9f('0x11'));var hardwareService=require(_0xfb9f('0x12'));var logger=require(_0xfb9f('0x13'))(_0xfb9f('0x14'));var utils=require(_0xfb9f('0x15'));var config=require(_0xfb9f('0x16'));var licenseUtil=require('../../config/license/util');var db=require(_0xfb9f('0x17'))['db'];function respondWithStatusCode(_0x1d10ea,_0x44b23e){_0x44b23e=_0x44b23e||0xcc;return function(_0x3214e1){if(_0x3214e1){return _0x1d10ea[_0xfb9f('0x18')](_0x44b23e);}return _0x1d10ea[_0xfb9f('0x19')](_0x44b23e)[_0xfb9f('0x1a')]();};}function respondWithResult(_0x2a988c,_0x2e1ac4){_0x2e1ac4=_0x2e1ac4||0xc8;return function(_0x42b03c){if(_0x42b03c){return _0x2a988c[_0xfb9f('0x19')](_0x2e1ac4)[_0xfb9f('0x1b')](_0x42b03c);}};}function respondWithFilteredResult(_0x5b90ae,_0x235726){return function(_0xce55c5){if(_0xce55c5){var _0x2a8060=typeof _0x235726[_0xfb9f('0x1c')]===_0xfb9f('0x1d')&&typeof _0x235726[_0xfb9f('0x1e')]===_0xfb9f('0x1d');var _0xb09ac0=_0xce55c5[_0xfb9f('0x1f')];var _0x2fb696=_0x2a8060?0x0:_0x235726[_0xfb9f('0x1c')];var _0x1449e4=_0x2a8060?_0xce55c5[_0xfb9f('0x1f')]:_0x235726[_0xfb9f('0x1c')]+_0x235726[_0xfb9f('0x1e')];var _0x23d1f0;if(_0x1449e4>=_0xb09ac0){_0x1449e4=_0xb09ac0;_0x23d1f0=0xc8;}else{_0x23d1f0=0xce;}_0x5b90ae[_0xfb9f('0x19')](_0x23d1f0);return _0x5b90ae[_0xfb9f('0x20')]('Content-Range',_0x2fb696+'-'+_0x1449e4+'/'+_0xb09ac0)[_0xfb9f('0x1b')](_0xce55c5);}return null;};}function patchUpdates(_0x429bd0){return function(_0x24c00f){try{jsonpatch[_0xfb9f('0x21')](_0x24c00f,_0x429bd0,!![]);}catch(_0x45f08d){return BPromise[_0xfb9f('0x22')](_0x45f08d);}return _0x24c00f[_0xfb9f('0x23')]();};}function saveUpdates(_0x5b95bf,_0x5c1af7){return function(_0x303d48){if(_0x303d48){return _0x303d48[_0xfb9f('0x24')](_0x5b95bf)[_0xfb9f('0x25')](function(_0x6c732e){return _0x6c732e;});}return null;};}function removeEntity(_0x5bb2d1,_0x3f5755){return function(_0x38dce1){if(_0x38dce1){return _0x38dce1[_0xfb9f('0x26')]()[_0xfb9f('0x25')](function(){var _0x4162f1=_0x38dce1['get']({'plain':!![]});var _0x53e20c='CannedAnswers';return db[_0xfb9f('0x27')][_0xfb9f('0x26')]({'where':{'type':_0x53e20c,'resourceId':_0x4162f1['id']}})['then'](function(){return _0x38dce1;});})[_0xfb9f('0x25')](function(){_0x5bb2d1[_0xfb9f('0x19')](0xcc)[_0xfb9f('0x1a')]();});}};}function handleEntityNotFound(_0x11b7f2,_0x51afcc){return function(_0x1a453b){if(!_0x1a453b){_0x11b7f2['sendStatus'](0x194);}return _0x1a453b;};}function handleError(_0x1c70b6,_0x50f0b7){_0x50f0b7=_0x50f0b7||0x1f4;return function(_0x4fb9f6){logger[_0xfb9f('0x28')](_0x4fb9f6[_0xfb9f('0x29')]);if(_0x4fb9f6['name']){delete _0x4fb9f6[_0xfb9f('0x2a')];}_0x1c70b6[_0xfb9f('0x19')](_0x50f0b7)['send'](_0x4fb9f6);};}exports[_0xfb9f('0x2b')]=function(_0x46d35b,_0xabb1a4){var _0x21cda9={},_0x4c1878={},_0xfdafe2={'count':0x0,'rows':[]};var _0x42ea86=_[_0xfb9f('0x2c')](db[_0xfb9f('0x2d')]['rawAttributes'],function(_0x13b56d){return{'name':_0x13b56d[_0xfb9f('0x2e')],'type':_0x13b56d[_0xfb9f('0x2f')][_0xfb9f('0x30')]};});_0x4c1878[_0xfb9f('0x31')]=_[_0xfb9f('0x2c')](_0x42ea86,_0xfb9f('0x2a'));_0x4c1878['query']=_[_0xfb9f('0x32')](_0x46d35b[_0xfb9f('0x33')]);_0x4c1878[_0xfb9f('0x34')]=_[_0xfb9f('0x35')](_0x4c1878[_0xfb9f('0x31')],_0x4c1878[_0xfb9f('0x33')]);_0x21cda9[_0xfb9f('0x36')]=_['intersection'](_0x4c1878[_0xfb9f('0x31')],qs[_0xfb9f('0x37')](_0x46d35b[_0xfb9f('0x33')]['fields']));_0x21cda9['attributes']=_0x21cda9[_0xfb9f('0x36')]['length']?_0x21cda9[_0xfb9f('0x36')]:_0x4c1878[_0xfb9f('0x31')];if(!_0x46d35b[_0xfb9f('0x33')][_0xfb9f('0x38')](_0xfb9f('0x39'))){_0x21cda9[_0xfb9f('0x1e')]=qs[_0xfb9f('0x1e')](_0x46d35b[_0xfb9f('0x33')][_0xfb9f('0x1e')]);_0x21cda9[_0xfb9f('0x1c')]=qs[_0xfb9f('0x1c')](_0x46d35b[_0xfb9f('0x33')][_0xfb9f('0x1c')]);}_0x21cda9[_0xfb9f('0x3a')]=qs['sort'](_0x46d35b[_0xfb9f('0x33')][_0xfb9f('0x3b')]);_0x21cda9[_0xfb9f('0x3c')]=qs['filters'](_['pick'](_0x46d35b['query'],_0x4c1878['filters']),_0x42ea86);if(_0x46d35b[_0xfb9f('0x33')][_0xfb9f('0x3d')]){_0x21cda9[_0xfb9f('0x3c')]=_[_0xfb9f('0x3e')](_0x21cda9[_0xfb9f('0x3c')],{'$or':[{'key':{'$like':'%'+_0x46d35b[_0xfb9f('0x33')][_0xfb9f('0x3d')]+'%'}},{'value':{'$like':'%'+_0x46d35b['query']['filter']+'%'}}]});}_0x21cda9=_[_0xfb9f('0x3e')]({},_0x21cda9,_0x46d35b[_0xfb9f('0x3f')]);var _0x66ef94={'where':_0x21cda9[_0xfb9f('0x3c')]};return db[_0xfb9f('0x2d')]['count'](_0x66ef94)[_0xfb9f('0x25')](function(_0x4230cd){_0xfdafe2[_0xfb9f('0x1f')]=_0x4230cd;if(_0x46d35b[_0xfb9f('0x33')]['includeAll']){_0x21cda9[_0xfb9f('0x40')]=[{'all':!![]}];}return db[_0xfb9f('0x2d')]['findAll'](_0x21cda9);})[_0xfb9f('0x25')](function(_0x5355f5){_0xfdafe2[_0xfb9f('0x41')]=_0x5355f5;return _0xfdafe2;})[_0xfb9f('0x25')](respondWithFilteredResult(_0xabb1a4,_0x21cda9))[_0xfb9f('0x42')](handleError(_0xabb1a4,null));};exports[_0xfb9f('0x43')]=function(_0x4afd50,_0x40ce1d){var _0x2c3987={'raw':!![],'where':{'id':_0x4afd50[_0xfb9f('0x44')]['id']}},_0x2eba96={};_0x2eba96[_0xfb9f('0x31')]=_[_0xfb9f('0x32')](db[_0xfb9f('0x2d')][_0xfb9f('0x45')]);_0x2eba96['query']=_['keys'](_0x4afd50['query']);_0x2eba96[_0xfb9f('0x34')]=_[_0xfb9f('0x35')](_0x2eba96['model'],_0x2eba96['query']);_0x2c3987['attributes']=_['intersection'](_0x2eba96[_0xfb9f('0x31')],qs[_0xfb9f('0x37')](_0x4afd50[_0xfb9f('0x33')][_0xfb9f('0x37')]));_0x2c3987[_0xfb9f('0x36')]=_0x2c3987[_0xfb9f('0x36')][_0xfb9f('0x46')]?_0x2c3987[_0xfb9f('0x36')]:_0x2eba96['model'];if(_0x4afd50['query']['includeAll']){_0x2c3987[_0xfb9f('0x40')]=[{'all':!![]}];}_0x2c3987=_[_0xfb9f('0x3e')]({},_0x2c3987,_0x4afd50[_0xfb9f('0x3f')]);return db[_0xfb9f('0x2d')][_0xfb9f('0x47')](_0x2c3987)[_0xfb9f('0x25')](handleEntityNotFound(_0x40ce1d,null))[_0xfb9f('0x25')](respondWithResult(_0x40ce1d,null))[_0xfb9f('0x42')](handleError(_0x40ce1d,null));};exports['update']=function(_0x1082c8,_0x50c188){if(_0x1082c8[_0xfb9f('0x48')]['id']){delete _0x1082c8[_0xfb9f('0x48')]['id'];}return db[_0xfb9f('0x2d')][_0xfb9f('0x47')]({'where':{'id':_0x1082c8[_0xfb9f('0x44')]['id']}})[_0xfb9f('0x25')](handleEntityNotFound(_0x50c188,null))['then'](saveUpdates(_0x1082c8['body'],null))[_0xfb9f('0x25')](respondWithResult(_0x50c188,null))[_0xfb9f('0x42')](handleError(_0x50c188,null));};exports[_0xfb9f('0x26')]=function(_0x5e5084,_0x197bcd){return db[_0xfb9f('0x2d')][_0xfb9f('0x47')]({'where':{'id':_0x5e5084['params']['id']}})[_0xfb9f('0x25')](handleEntityNotFound(_0x197bcd,null))[_0xfb9f('0x25')](removeEntity(_0x197bcd,null))[_0xfb9f('0x42')](handleError(_0x197bcd,null));};exports['create']=function(_0x2d9467,_0x3b60f0){var _0x44f680={'key':_0x2d9467[_0xfb9f('0x48')][_0xfb9f('0x30')]};if(_0x2d9467[_0xfb9f('0x48')][_0xfb9f('0x49')]){_0x44f680['MailAccountId']=_0x2d9467[_0xfb9f('0x48')][_0xfb9f('0x49')];}else if(_0x2d9467[_0xfb9f('0x48')][_0xfb9f('0x4a')]){_0x44f680[_0xfb9f('0x4a')]=_0x2d9467[_0xfb9f('0x48')][_0xfb9f('0x4a')];}else if(_0x2d9467[_0xfb9f('0x48')][_0xfb9f('0x4b')]){_0x44f680[_0xfb9f('0x4b')]=_0x2d9467[_0xfb9f('0x48')][_0xfb9f('0x4b')];}else if(_0x2d9467[_0xfb9f('0x48')][_0xfb9f('0x4c')]){_0x44f680[_0xfb9f('0x4c')]=_0x2d9467[_0xfb9f('0x48')]['ChatWebsiteId'];}return db[_0xfb9f('0x2d')]['find']({'where':_0x44f680})[_0xfb9f('0x25')](function(_0x411e1a){if(_0x411e1a){throw new db[(_0xfb9f('0x4d'))][(_0xfb9f('0x4e'))](_0xfb9f('0x4f'));}return db['CannedAnswer'][_0xfb9f('0x50')](_0x2d9467['body']);})['then'](function(_0x3d616c){var _0x26ab4d=_0x2d9467[_0xfb9f('0x51')]['get']({'plain':!![]});if(!_0x26ab4d)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x26ab4d[_0xfb9f('0x52')]===_0xfb9f('0x51')){var _0xdc906=_0x3d616c['get']({'plain':!![]});return db[_0xfb9f('0x53')][_0xfb9f('0x47')]({'where':{'name':_0xfb9f('0x54'),'userProfileId':_0x26ab4d[_0xfb9f('0x55')]},'raw':!![]})[_0xfb9f('0x25')](function(_0x435fcf){if(_0x435fcf&&_0x435fcf['autoAssociation']===0x0){return db[_0xfb9f('0x27')][_0xfb9f('0x50')]({'name':_0xdc906[_0xfb9f('0x2a')],'resourceId':_0xdc906['id'],'type':_0x435fcf[_0xfb9f('0x2a')],'sectionId':_0x435fcf['id']},{})[_0xfb9f('0x25')](function(){return _0x3d616c;});}else{return _0x3d616c;}})[_0xfb9f('0x42')](function(_0x3d06cf){logger['error']('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x3d06cf);throw _0x3d06cf;});}return _0x3d616c;})[_0xfb9f('0x25')](respondWithResult(_0x3b60f0,0xc9))[_0xfb9f('0x42')](handleError(_0x3b60f0,null));};
\ No newline at end of file
+var _0xa3d9=['../../mysqldb','sendStatus','end','status','json','offset','limit','count','set','Content-Range','apply','reject','save','update','destroy','then','CannedAnswers','UserProfileResource','stack','name','send','index','CannedAnswer','rawAttributes','fieldName','type','key','model','map','query','keys','filters','intersection','attributes','fields','nolimit','order','sort','where','filter','merge','options','findAll','catch','show','params','length','includeAll','find','body','MailAccountId','SmsAccountId','OpenchannelAccountId','ChatWebsiteId','ValidationError','The\x20inserted\x20key\x20already\x20exists.','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','get','UserProfileSection','userProfileId','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','eml-format','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','fs-extra','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util'];(function(_0x316e55,_0x1c89e7){var _0x39ab39=function(_0x5a37d3){while(--_0x5a37d3){_0x316e55['push'](_0x316e55['shift']());}};_0x39ab39(++_0x1c89e7);}(_0xa3d9,0xf2));var _0x9a3d=function(_0x17fbc2,_0x1f2de7){_0x17fbc2=_0x17fbc2-0x0;var _0x38b500=_0xa3d9[_0x17fbc2];return _0x38b500;};'use strict';var emlformat=require(_0x9a3d('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0x9a3d('0x1'));var rp=require(_0x9a3d('0x2'));var moment=require(_0x9a3d('0x3'));var BPromise=require(_0x9a3d('0x4'));var Mustache=require(_0x9a3d('0x5'));var util=require(_0x9a3d('0x6'));var path=require(_0x9a3d('0x7'));var sox=require(_0x9a3d('0x8'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x9a3d('0x9'));var _=require('lodash');var squel=require(_0x9a3d('0xa'));var crypto=require(_0x9a3d('0xb'));var jsforce=require(_0x9a3d('0xc'));var deskjs=require(_0x9a3d('0xd'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x9a3d('0xe'));var Redis=require(_0x9a3d('0xf'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x9a3d('0x10'));var logger=require(_0x9a3d('0x11'))(_0x9a3d('0x12'));var utils=require(_0x9a3d('0x13'));var config=require(_0x9a3d('0x14'));var licenseUtil=require(_0x9a3d('0x15'));var db=require(_0x9a3d('0x16'))['db'];function respondWithStatusCode(_0x2ed9a7,_0x5ad281){_0x5ad281=_0x5ad281||0xcc;return function(_0x4d1fbc){if(_0x4d1fbc){return _0x2ed9a7[_0x9a3d('0x17')](_0x5ad281);}return _0x2ed9a7['status'](_0x5ad281)[_0x9a3d('0x18')]();};}function respondWithResult(_0x131cda,_0x572520){_0x572520=_0x572520||0xc8;return function(_0x18281e){if(_0x18281e){return _0x131cda[_0x9a3d('0x19')](_0x572520)[_0x9a3d('0x1a')](_0x18281e);}};}function respondWithFilteredResult(_0x138d64,_0x436002){return function(_0x22b6ab){if(_0x22b6ab){var _0xf226c8=typeof _0x436002[_0x9a3d('0x1b')]==='undefined'&&typeof _0x436002[_0x9a3d('0x1c')]==='undefined';var _0x3417fe=_0x22b6ab[_0x9a3d('0x1d')];var _0x330ced=_0xf226c8?0x0:_0x436002[_0x9a3d('0x1b')];var _0x16c891=_0xf226c8?_0x22b6ab[_0x9a3d('0x1d')]:_0x436002[_0x9a3d('0x1b')]+_0x436002[_0x9a3d('0x1c')];var _0x13420b;if(_0x16c891>=_0x3417fe){_0x16c891=_0x3417fe;_0x13420b=0xc8;}else{_0x13420b=0xce;}_0x138d64[_0x9a3d('0x19')](_0x13420b);return _0x138d64[_0x9a3d('0x1e')](_0x9a3d('0x1f'),_0x330ced+'-'+_0x16c891+'/'+_0x3417fe)[_0x9a3d('0x1a')](_0x22b6ab);}return null;};}function patchUpdates(_0x2e2243){return function(_0x50962d){try{jsonpatch[_0x9a3d('0x20')](_0x50962d,_0x2e2243,!![]);}catch(_0x2576d7){return BPromise[_0x9a3d('0x21')](_0x2576d7);}return _0x50962d[_0x9a3d('0x22')]();};}function saveUpdates(_0x286aec,_0x125d94){return function(_0x2da30e){if(_0x2da30e){return _0x2da30e[_0x9a3d('0x23')](_0x286aec)['then'](function(_0x43d1a8){return _0x43d1a8;});}return null;};}function removeEntity(_0x2d21ad,_0x52ec0e){return function(_0x1e666f){if(_0x1e666f){return _0x1e666f[_0x9a3d('0x24')]()[_0x9a3d('0x25')](function(){var _0x5cf650=_0x1e666f['get']({'plain':!![]});var _0x4bb451=_0x9a3d('0x26');return db[_0x9a3d('0x27')][_0x9a3d('0x24')]({'where':{'type':_0x4bb451,'resourceId':_0x5cf650['id']}})[_0x9a3d('0x25')](function(){return _0x1e666f;});})['then'](function(){_0x2d21ad[_0x9a3d('0x19')](0xcc)['end']();});}};}function handleEntityNotFound(_0x47a75f,_0x5ef8c0){return function(_0x118aae){if(!_0x118aae){_0x47a75f[_0x9a3d('0x17')](0x194);}return _0x118aae;};}function handleError(_0x149843,_0x50d2ef){_0x50d2ef=_0x50d2ef||0x1f4;return function(_0x4caa60){logger['error'](_0x4caa60[_0x9a3d('0x28')]);if(_0x4caa60[_0x9a3d('0x29')]){delete _0x4caa60['name'];}_0x149843['status'](_0x50d2ef)[_0x9a3d('0x2a')](_0x4caa60);};}exports[_0x9a3d('0x2b')]=function(_0x388460,_0x8313b9){var _0x2d3ee2={},_0x55f05d={},_0x1ec2cc={'count':0x0,'rows':[]};var _0x2e8ba0=_['map'](db[_0x9a3d('0x2c')][_0x9a3d('0x2d')],function(_0x227565){return{'name':_0x227565[_0x9a3d('0x2e')],'type':_0x227565[_0x9a3d('0x2f')][_0x9a3d('0x30')]};});_0x55f05d[_0x9a3d('0x31')]=_[_0x9a3d('0x32')](_0x2e8ba0,_0x9a3d('0x29'));_0x55f05d[_0x9a3d('0x33')]=_[_0x9a3d('0x34')](_0x388460[_0x9a3d('0x33')]);_0x55f05d[_0x9a3d('0x35')]=_[_0x9a3d('0x36')](_0x55f05d['model'],_0x55f05d[_0x9a3d('0x33')]);_0x2d3ee2[_0x9a3d('0x37')]=_[_0x9a3d('0x36')](_0x55f05d[_0x9a3d('0x31')],qs[_0x9a3d('0x38')](_0x388460[_0x9a3d('0x33')][_0x9a3d('0x38')]));_0x2d3ee2[_0x9a3d('0x37')]=_0x2d3ee2[_0x9a3d('0x37')]['length']?_0x2d3ee2['attributes']:_0x55f05d[_0x9a3d('0x31')];if(!_0x388460[_0x9a3d('0x33')]['hasOwnProperty'](_0x9a3d('0x39'))){_0x2d3ee2[_0x9a3d('0x1c')]=qs[_0x9a3d('0x1c')](_0x388460[_0x9a3d('0x33')]['limit']);_0x2d3ee2['offset']=qs[_0x9a3d('0x1b')](_0x388460[_0x9a3d('0x33')][_0x9a3d('0x1b')]);}_0x2d3ee2[_0x9a3d('0x3a')]=qs[_0x9a3d('0x3b')](_0x388460[_0x9a3d('0x33')][_0x9a3d('0x3b')]);_0x2d3ee2[_0x9a3d('0x3c')]=qs[_0x9a3d('0x35')](_['pick'](_0x388460[_0x9a3d('0x33')],_0x55f05d['filters']),_0x2e8ba0);if(_0x388460[_0x9a3d('0x33')][_0x9a3d('0x3d')]){_0x2d3ee2[_0x9a3d('0x3c')]=_[_0x9a3d('0x3e')](_0x2d3ee2['where'],{'$or':[{'key':{'$like':'%'+_0x388460['query'][_0x9a3d('0x3d')]+'%'}},{'value':{'$like':'%'+_0x388460['query'][_0x9a3d('0x3d')]+'%'}}]});}_0x2d3ee2=_['merge']({},_0x2d3ee2,_0x388460[_0x9a3d('0x3f')]);var _0x3d20d0={'where':_0x2d3ee2['where']};return db['CannedAnswer'][_0x9a3d('0x1d')](_0x3d20d0)[_0x9a3d('0x25')](function(_0x208362){_0x1ec2cc[_0x9a3d('0x1d')]=_0x208362;if(_0x388460[_0x9a3d('0x33')]['includeAll']){_0x2d3ee2['include']=[{'all':!![]}];}return db[_0x9a3d('0x2c')][_0x9a3d('0x40')](_0x2d3ee2);})['then'](function(_0x596586){_0x1ec2cc['rows']=_0x596586;return _0x1ec2cc;})[_0x9a3d('0x25')](respondWithFilteredResult(_0x8313b9,_0x2d3ee2))[_0x9a3d('0x41')](handleError(_0x8313b9,null));};exports[_0x9a3d('0x42')]=function(_0x22d6ce,_0x3cf612){var _0x38acac={'raw':!![],'where':{'id':_0x22d6ce[_0x9a3d('0x43')]['id']}},_0x4d9bed={};_0x4d9bed['model']=_[_0x9a3d('0x34')](db[_0x9a3d('0x2c')][_0x9a3d('0x2d')]);_0x4d9bed[_0x9a3d('0x33')]=_[_0x9a3d('0x34')](_0x22d6ce[_0x9a3d('0x33')]);_0x4d9bed[_0x9a3d('0x35')]=_[_0x9a3d('0x36')](_0x4d9bed[_0x9a3d('0x31')],_0x4d9bed[_0x9a3d('0x33')]);_0x38acac[_0x9a3d('0x37')]=_[_0x9a3d('0x36')](_0x4d9bed[_0x9a3d('0x31')],qs[_0x9a3d('0x38')](_0x22d6ce['query'][_0x9a3d('0x38')]));_0x38acac[_0x9a3d('0x37')]=_0x38acac[_0x9a3d('0x37')][_0x9a3d('0x44')]?_0x38acac[_0x9a3d('0x37')]:_0x4d9bed[_0x9a3d('0x31')];if(_0x22d6ce[_0x9a3d('0x33')][_0x9a3d('0x45')]){_0x38acac['include']=[{'all':!![]}];}_0x38acac=_['merge']({},_0x38acac,_0x22d6ce[_0x9a3d('0x3f')]);return db[_0x9a3d('0x2c')][_0x9a3d('0x46')](_0x38acac)['then'](handleEntityNotFound(_0x3cf612,null))[_0x9a3d('0x25')](respondWithResult(_0x3cf612,null))[_0x9a3d('0x41')](handleError(_0x3cf612,null));};exports['update']=function(_0x286c05,_0x271eb2){if(_0x286c05[_0x9a3d('0x47')]['id']){delete _0x286c05[_0x9a3d('0x47')]['id'];}return db['CannedAnswer'][_0x9a3d('0x46')]({'where':{'id':_0x286c05[_0x9a3d('0x43')]['id']}})[_0x9a3d('0x25')](handleEntityNotFound(_0x271eb2,null))[_0x9a3d('0x25')](saveUpdates(_0x286c05[_0x9a3d('0x47')],null))[_0x9a3d('0x25')](respondWithResult(_0x271eb2,null))[_0x9a3d('0x41')](handleError(_0x271eb2,null));};exports['destroy']=function(_0x4caad5,_0x483c78){return db[_0x9a3d('0x2c')][_0x9a3d('0x46')]({'where':{'id':_0x4caad5[_0x9a3d('0x43')]['id']}})['then'](handleEntityNotFound(_0x483c78,null))[_0x9a3d('0x25')](removeEntity(_0x483c78,null))[_0x9a3d('0x41')](handleError(_0x483c78,null));};exports['create']=function(_0x4de4d0,_0x3e2a03){var _0x3bead1={'key':_0x4de4d0[_0x9a3d('0x47')][_0x9a3d('0x30')]};if(_0x4de4d0[_0x9a3d('0x47')][_0x9a3d('0x48')]){_0x3bead1[_0x9a3d('0x48')]=_0x4de4d0[_0x9a3d('0x47')][_0x9a3d('0x48')];}else if(_0x4de4d0[_0x9a3d('0x47')]['SmsAccountId']){_0x3bead1['SmsAccountId']=_0x4de4d0[_0x9a3d('0x47')][_0x9a3d('0x49')];}else if(_0x4de4d0[_0x9a3d('0x47')]['OpenchannelAccountId']){_0x3bead1['OpenchannelAccountId']=_0x4de4d0[_0x9a3d('0x47')][_0x9a3d('0x4a')];}else if(_0x4de4d0[_0x9a3d('0x47')][_0x9a3d('0x4b')]){_0x3bead1[_0x9a3d('0x4b')]=_0x4de4d0[_0x9a3d('0x47')][_0x9a3d('0x4b')];}return db[_0x9a3d('0x2c')][_0x9a3d('0x46')]({'where':_0x3bead1})[_0x9a3d('0x25')](function(_0x29fec9){if(_0x29fec9){throw new db['Sequelize'][(_0x9a3d('0x4c'))](_0x9a3d('0x4d'));}return db['CannedAnswer'][_0x9a3d('0x4e')](_0x4de4d0['body']);})[_0x9a3d('0x25')](function(_0x4a2127){var _0x2165d4=_0x4de4d0[_0x9a3d('0x4f')]['get']({'plain':!![]});if(!_0x2165d4)throw new Error(_0x9a3d('0x50'));if(_0x2165d4[_0x9a3d('0x51')]===_0x9a3d('0x4f')){var _0x42269b=_0x4a2127[_0x9a3d('0x52')]({'plain':!![]});return db[_0x9a3d('0x53')][_0x9a3d('0x46')]({'where':{'name':_0x9a3d('0x26'),'userProfileId':_0x2165d4[_0x9a3d('0x54')]},'raw':!![]})[_0x9a3d('0x25')](function(_0x45cc7c){if(_0x45cc7c&&_0x45cc7c[_0x9a3d('0x55')]===0x0){return db[_0x9a3d('0x27')][_0x9a3d('0x4e')]({'name':_0x42269b['name'],'resourceId':_0x42269b['id'],'type':_0x45cc7c[_0x9a3d('0x29')],'sectionId':_0x45cc7c['id']},{})[_0x9a3d('0x25')](function(){return _0x4a2127;});}else{return _0x4a2127;}})[_0x9a3d('0x41')](function(_0x450639){logger[_0x9a3d('0x56')](_0x9a3d('0x57'),_0x450639);throw _0x450639;});}return _0x4a2127;})[_0x9a3d('0x25')](respondWithResult(_0x3e2a03,0xc9))['catch'](handleError(_0x3e2a03,null));};
\ No newline at end of file