Built motion from commit 639a1a7f.|2.6.19
[motion2.git] / server / api / cannedAnswer / cannedAnswer.controller.js
index 5fa6b89..0fad67d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x89f9=['ChatWebsiteId','ValidationError','The\x20inserted\x20key\x20already\x20exists.','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','CannedAnswers','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/license/util','../../mysqldb','status','end','json','offset','undefined','limit','count','Content-Range','apply','reject','save','update','then','get','UserProfileResource','sendStatus','error','stack','name','send','index','rawAttributes','fieldName','key','map','query','keys','filters','attributes','intersection','model','fields','length','hasOwnProperty','nolimit','order','sort','where','filter','merge','CannedAnswer','includeAll','include','findAll','catch','show','params','body','find','destroy','create','MailAccountId','SmsAccountId','OpenchannelAccountId'];(function(_0x31fdc1,_0xfdd4e0){var _0x109528=function(_0x2f31b2){while(--_0x2f31b2){_0x31fdc1['push'](_0x31fdc1['shift']());}};_0x109528(++_0xfdd4e0);}(_0x89f9,0x68));var _0x989f=function(_0x1efdc0,_0x5a2099){_0x1efdc0=_0x1efdc0-0x0;var _0x3350fb=_0x89f9[_0x1efdc0];return _0x3350fb;};'use strict';var emlformat=require(_0x989f('0x0'));var rimraf=require(_0x989f('0x1'));var zipdir=require(_0x989f('0x2'));var jsonpatch=require(_0x989f('0x3'));var rp=require(_0x989f('0x4'));var moment=require(_0x989f('0x5'));var BPromise=require(_0x989f('0x6'));var Mustache=require(_0x989f('0x7'));var util=require(_0x989f('0x8'));var path=require(_0x989f('0x9'));var sox=require(_0x989f('0xa'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x989f('0xb'));var _=require(_0x989f('0xc'));var squel=require(_0x989f('0xd'));var crypto=require(_0x989f('0xe'));var jsforce=require(_0x989f('0xf'));var deskjs=require(_0x989f('0x10'));var toCsv=require('to-csv');var querystring=require(_0x989f('0x11'));var Papa=require(_0x989f('0x12'));var Redis=require(_0x989f('0x13'));var authService=require(_0x989f('0x14'));var qs=require(_0x989f('0x15'));var as=require(_0x989f('0x16'));var hardwareService=require(_0x989f('0x17'));var logger=require(_0x989f('0x18'))(_0x989f('0x19'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x989f('0x1a'));var db=require(_0x989f('0x1b'))['db'];function respondWithStatusCode(_0x4c036c,_0x445d36){_0x445d36=_0x445d36||0xcc;return function(_0xc44ae9){if(_0xc44ae9){return _0x4c036c['sendStatus'](_0x445d36);}return _0x4c036c[_0x989f('0x1c')](_0x445d36)[_0x989f('0x1d')]();};}function respondWithResult(_0x181bc0,_0x2e8fb7){_0x2e8fb7=_0x2e8fb7||0xc8;return function(_0x238e74){if(_0x238e74){return _0x181bc0[_0x989f('0x1c')](_0x2e8fb7)[_0x989f('0x1e')](_0x238e74);}};}function respondWithFilteredResult(_0x590595,_0x140474){return function(_0x34ba67){if(_0x34ba67){var _0x6413df=typeof _0x140474[_0x989f('0x1f')]===_0x989f('0x20')&&typeof _0x140474[_0x989f('0x21')]===_0x989f('0x20');var _0x572be1=_0x34ba67[_0x989f('0x22')];var _0x1fc70e=_0x6413df?0x0:_0x140474[_0x989f('0x1f')];var _0xe61197=_0x6413df?_0x34ba67[_0x989f('0x22')]:_0x140474[_0x989f('0x1f')]+_0x140474['limit'];var _0x407dc1;if(_0xe61197>=_0x572be1){_0xe61197=_0x572be1;_0x407dc1=0xc8;}else{_0x407dc1=0xce;}_0x590595[_0x989f('0x1c')](_0x407dc1);return _0x590595['set'](_0x989f('0x23'),_0x1fc70e+'-'+_0xe61197+'/'+_0x572be1)[_0x989f('0x1e')](_0x34ba67);}return null;};}function patchUpdates(_0x3e8afa){return function(_0x3216b4){try{jsonpatch[_0x989f('0x24')](_0x3216b4,_0x3e8afa,!![]);}catch(_0x3d1df6){return BPromise[_0x989f('0x25')](_0x3d1df6);}return _0x3216b4[_0x989f('0x26')]();};}function saveUpdates(_0x5ac893,_0x2cc5eb){return function(_0x72896b){if(_0x72896b){return _0x72896b[_0x989f('0x27')](_0x5ac893)[_0x989f('0x28')](function(_0x2f0c2e){return _0x2f0c2e;});}return null;};}function removeEntity(_0x521c95,_0x40d0a6){return function(_0x3e5e39){if(_0x3e5e39){return _0x3e5e39['destroy']()[_0x989f('0x28')](function(){var _0x106511=_0x3e5e39[_0x989f('0x29')]({'plain':!![]});var _0x1212f4='CannedAnswers';return db[_0x989f('0x2a')]['destroy']({'where':{'type':_0x1212f4,'resourceId':_0x106511['id']}})[_0x989f('0x28')](function(){return _0x3e5e39;});})[_0x989f('0x28')](function(){_0x521c95[_0x989f('0x1c')](0xcc)[_0x989f('0x1d')]();});}};}function handleEntityNotFound(_0x476bb5,_0x3e352b){return function(_0x4bf7f9){if(!_0x4bf7f9){_0x476bb5[_0x989f('0x2b')](0x194);}return _0x4bf7f9;};}function handleError(_0x17ece7,_0x44e91f){_0x44e91f=_0x44e91f||0x1f4;return function(_0x16a807){logger[_0x989f('0x2c')](_0x16a807[_0x989f('0x2d')]);if(_0x16a807[_0x989f('0x2e')]){delete _0x16a807[_0x989f('0x2e')];}_0x17ece7['status'](_0x44e91f)[_0x989f('0x2f')](_0x16a807);};}exports[_0x989f('0x30')]=function(_0x23835d,_0x384bf5){var _0x1588b8={},_0x46b4d2={},_0x25b1ed={'count':0x0,'rows':[]};var _0x49b7ea=_['map'](db['CannedAnswer'][_0x989f('0x31')],function(_0x3dd3ca){return{'name':_0x3dd3ca[_0x989f('0x32')],'type':_0x3dd3ca['type'][_0x989f('0x33')]};});_0x46b4d2['model']=_[_0x989f('0x34')](_0x49b7ea,_0x989f('0x2e'));_0x46b4d2[_0x989f('0x35')]=_[_0x989f('0x36')](_0x23835d[_0x989f('0x35')]);_0x46b4d2[_0x989f('0x37')]=_['intersection'](_0x46b4d2['model'],_0x46b4d2[_0x989f('0x35')]);_0x1588b8[_0x989f('0x38')]=_[_0x989f('0x39')](_0x46b4d2[_0x989f('0x3a')],qs[_0x989f('0x3b')](_0x23835d[_0x989f('0x35')][_0x989f('0x3b')]));_0x1588b8[_0x989f('0x38')]=_0x1588b8[_0x989f('0x38')][_0x989f('0x3c')]?_0x1588b8['attributes']:_0x46b4d2[_0x989f('0x3a')];if(!_0x23835d[_0x989f('0x35')][_0x989f('0x3d')](_0x989f('0x3e'))){_0x1588b8[_0x989f('0x21')]=qs[_0x989f('0x21')](_0x23835d[_0x989f('0x35')][_0x989f('0x21')]);_0x1588b8[_0x989f('0x1f')]=qs['offset'](_0x23835d[_0x989f('0x35')][_0x989f('0x1f')]);}_0x1588b8[_0x989f('0x3f')]=qs['sort'](_0x23835d[_0x989f('0x35')][_0x989f('0x40')]);_0x1588b8[_0x989f('0x41')]=qs[_0x989f('0x37')](_['pick'](_0x23835d[_0x989f('0x35')],_0x46b4d2[_0x989f('0x37')]),_0x49b7ea);if(_0x23835d['query'][_0x989f('0x42')]){_0x1588b8[_0x989f('0x41')]=_[_0x989f('0x43')](_0x1588b8[_0x989f('0x41')],{'$or':[{'key':{'$like':'%'+_0x23835d[_0x989f('0x35')][_0x989f('0x42')]+'%'}},{'value':{'$like':'%'+_0x23835d[_0x989f('0x35')][_0x989f('0x42')]+'%'}}]});}_0x1588b8=_[_0x989f('0x43')]({},_0x1588b8,_0x23835d['options']);var _0xe822d1={'where':_0x1588b8[_0x989f('0x41')]};return db[_0x989f('0x44')][_0x989f('0x22')](_0xe822d1)[_0x989f('0x28')](function(_0x2184b8){_0x25b1ed[_0x989f('0x22')]=_0x2184b8;if(_0x23835d[_0x989f('0x35')][_0x989f('0x45')]){_0x1588b8[_0x989f('0x46')]=[{'all':!![]}];}return db['CannedAnswer'][_0x989f('0x47')](_0x1588b8);})[_0x989f('0x28')](function(_0x335dd2){_0x25b1ed['rows']=_0x335dd2;return _0x25b1ed;})[_0x989f('0x28')](respondWithFilteredResult(_0x384bf5,_0x1588b8))[_0x989f('0x48')](handleError(_0x384bf5,null));};exports[_0x989f('0x49')]=function(_0x19e3f9,_0x22fee1){var _0x13a4a1={'raw':!![],'where':{'id':_0x19e3f9[_0x989f('0x4a')]['id']}},_0x4fdd35={};_0x4fdd35[_0x989f('0x3a')]=_['keys'](db[_0x989f('0x44')]['rawAttributes']);_0x4fdd35[_0x989f('0x35')]=_[_0x989f('0x36')](_0x19e3f9[_0x989f('0x35')]);_0x4fdd35[_0x989f('0x37')]=_['intersection'](_0x4fdd35['model'],_0x4fdd35['query']);_0x13a4a1[_0x989f('0x38')]=_[_0x989f('0x39')](_0x4fdd35[_0x989f('0x3a')],qs[_0x989f('0x3b')](_0x19e3f9[_0x989f('0x35')]['fields']));_0x13a4a1[_0x989f('0x38')]=_0x13a4a1[_0x989f('0x38')][_0x989f('0x3c')]?_0x13a4a1['attributes']:_0x4fdd35[_0x989f('0x3a')];if(_0x19e3f9[_0x989f('0x35')][_0x989f('0x45')]){_0x13a4a1[_0x989f('0x46')]=[{'all':!![]}];}_0x13a4a1=_[_0x989f('0x43')]({},_0x13a4a1,_0x19e3f9['options']);return db[_0x989f('0x44')]['find'](_0x13a4a1)[_0x989f('0x28')](handleEntityNotFound(_0x22fee1,null))['then'](respondWithResult(_0x22fee1,null))['catch'](handleError(_0x22fee1,null));};exports[_0x989f('0x27')]=function(_0x2ed1f5,_0x6b2e18){if(_0x2ed1f5[_0x989f('0x4b')]['id']){delete _0x2ed1f5[_0x989f('0x4b')]['id'];}return db[_0x989f('0x44')][_0x989f('0x4c')]({'where':{'id':_0x2ed1f5[_0x989f('0x4a')]['id']}})[_0x989f('0x28')](handleEntityNotFound(_0x6b2e18,null))[_0x989f('0x28')](saveUpdates(_0x2ed1f5[_0x989f('0x4b')],null))[_0x989f('0x28')](respondWithResult(_0x6b2e18,null))[_0x989f('0x48')](handleError(_0x6b2e18,null));};exports[_0x989f('0x4d')]=function(_0x5f5d40,_0x5d0b8f){return db[_0x989f('0x44')]['find']({'where':{'id':_0x5f5d40[_0x989f('0x4a')]['id']}})[_0x989f('0x28')](handleEntityNotFound(_0x5d0b8f,null))[_0x989f('0x28')](removeEntity(_0x5d0b8f,null))[_0x989f('0x48')](handleError(_0x5d0b8f,null));};exports[_0x989f('0x4e')]=function(_0x33637b,_0x4f108b){var _0x154963={'key':_0x33637b['body']['key']};if(_0x33637b[_0x989f('0x4b')][_0x989f('0x4f')]){_0x154963[_0x989f('0x4f')]=_0x33637b[_0x989f('0x4b')][_0x989f('0x4f')];}else if(_0x33637b[_0x989f('0x4b')][_0x989f('0x50')]){_0x154963[_0x989f('0x50')]=_0x33637b[_0x989f('0x4b')][_0x989f('0x50')];}else if(_0x33637b[_0x989f('0x4b')]['OpenchannelAccountId']){_0x154963[_0x989f('0x51')]=_0x33637b[_0x989f('0x4b')][_0x989f('0x51')];}else if(_0x33637b[_0x989f('0x4b')][_0x989f('0x52')]){_0x154963[_0x989f('0x52')]=_0x33637b['body'][_0x989f('0x52')];}return db['CannedAnswer'][_0x989f('0x4c')]({'where':_0x154963})[_0x989f('0x28')](function(_0x50cb42){if(_0x50cb42){throw new db['Sequelize'][(_0x989f('0x53'))](_0x989f('0x54'));}return db[_0x989f('0x44')][_0x989f('0x4e')](_0x33637b['body']);})['then'](function(_0x5761f2){var _0x357697=_0x33637b[_0x989f('0x55')]['get']({'plain':!![]});if(!_0x357697)throw new Error(_0x989f('0x56'));if(_0x357697[_0x989f('0x57')]==='user'){var _0x4aaea0=_0x5761f2['get']({'plain':!![]});return db[_0x989f('0x58')][_0x989f('0x4c')]({'where':{'name':_0x989f('0x59'),'userProfileId':_0x357697[_0x989f('0x5a')]},'raw':!![]})[_0x989f('0x28')](function(_0x5707f9){if(_0x5707f9&&_0x5707f9[_0x989f('0x5b')]===0x0){return db[_0x989f('0x2a')][_0x989f('0x4e')]({'name':_0x4aaea0[_0x989f('0x2e')],'resourceId':_0x4aaea0['id'],'type':_0x5707f9[_0x989f('0x2e')],'sectionId':_0x5707f9['id']},{})[_0x989f('0x28')](function(){return _0x5761f2;});}else{return _0x5761f2;}})[_0x989f('0x48')](function(_0x511032){logger[_0x989f('0x2c')](_0x989f('0x5c'),_0x511032);throw _0x511032;});}return _0x5761f2;})[_0x989f('0x28')](respondWithResult(_0x4f108b,0xc9))[_0x989f('0x48')](handleError(_0x4f108b,null));};
\ No newline at end of file
+var _0x490b=['fields','hasOwnProperty','nolimit','order','sort','where','pick','filter','options','includeAll','include','findAll','rows','catch','show','params','rawAttributes','find','body','create','MailAccountId','SmsAccountId','OpenchannelAccountId','ChatWebsiteId','Sequelize','The\x20inserted\x20key\x20already\x20exists.','user','UserProfileSection','userProfileId','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','eml-format','zip-dir','fast-json-patch','request-promise','moment','util','sox','ejs','lodash','squel','crypto','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','limit','undefined','count','Content-Range','apply','reject','save','update','destroy','get','CannedAnswers','then','error','name','send','map','CannedAnswer','key','model','query','keys','filters','intersection','attributes'];(function(_0x43b3e5,_0xf9a63){var _0x52307c=function(_0x5612cf){while(--_0x5612cf){_0x43b3e5['push'](_0x43b3e5['shift']());}};_0x52307c(++_0xf9a63);}(_0x490b,0x1c3));var _0xb490=function(_0x151418,_0x2cbffa){_0x151418=_0x151418-0x0;var _0x40e29a=_0x490b[_0x151418];return _0x40e29a;};'use strict';var emlformat=require(_0xb490('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xb490('0x1'));var jsonpatch=require(_0xb490('0x2'));var rp=require(_0xb490('0x3'));var moment=require(_0xb490('0x4'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0xb490('0x5'));var path=require('path');var sox=require(_0xb490('0x6'));var csv=require('to-csv');var ejs=require(_0xb490('0x7'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xb490('0x8'));var squel=require(_0xb490('0x9'));var crypto=require(_0xb490('0xa'));var jsforce=require('jsforce');var deskjs=require(_0xb490('0xb'));var toCsv=require(_0xb490('0xc'));var querystring=require(_0xb490('0xd'));var Papa=require(_0xb490('0xe'));var Redis=require(_0xb490('0xf'));var authService=require(_0xb490('0x10'));var qs=require(_0xb490('0x11'));var as=require(_0xb490('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xb490('0x13'))(_0xb490('0x14'));var utils=require(_0xb490('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0xb490('0x16'));var db=require(_0xb490('0x17'))['db'];function respondWithStatusCode(_0x467ea4,_0x21af1e){_0x21af1e=_0x21af1e||0xcc;return function(_0x2d2522){if(_0x2d2522){return _0x467ea4[_0xb490('0x18')](_0x21af1e);}return _0x467ea4[_0xb490('0x19')](_0x21af1e)[_0xb490('0x1a')]();};}function respondWithResult(_0x215d5e,_0x57dc3e){_0x57dc3e=_0x57dc3e||0xc8;return function(_0x38bc71){if(_0x38bc71){return _0x215d5e[_0xb490('0x19')](_0x57dc3e)[_0xb490('0x1b')](_0x38bc71);}};}function respondWithFilteredResult(_0x543f46,_0x26c3aa){return function(_0x311a1f){if(_0x311a1f){var _0x145429=typeof _0x26c3aa[_0xb490('0x1c')]==='undefined'&&typeof _0x26c3aa[_0xb490('0x1d')]===_0xb490('0x1e');var _0x5253af=_0x311a1f[_0xb490('0x1f')];var _0x4901d1=_0x145429?0x0:_0x26c3aa[_0xb490('0x1c')];var _0x3bc713=_0x145429?_0x311a1f['count']:_0x26c3aa[_0xb490('0x1c')]+_0x26c3aa[_0xb490('0x1d')];var _0xa7a066;if(_0x3bc713>=_0x5253af){_0x3bc713=_0x5253af;_0xa7a066=0xc8;}else{_0xa7a066=0xce;}_0x543f46[_0xb490('0x19')](_0xa7a066);return _0x543f46['set'](_0xb490('0x20'),_0x4901d1+'-'+_0x3bc713+'/'+_0x5253af)[_0xb490('0x1b')](_0x311a1f);}return null;};}function patchUpdates(_0x140301){return function(_0x5d22c7){try{jsonpatch[_0xb490('0x21')](_0x5d22c7,_0x140301,!![]);}catch(_0x3bfb26){return BPromise[_0xb490('0x22')](_0x3bfb26);}return _0x5d22c7[_0xb490('0x23')]();};}function saveUpdates(_0x7d96a0,_0x439229){return function(_0x5f0874){if(_0x5f0874){return _0x5f0874[_0xb490('0x24')](_0x7d96a0)['then'](function(_0x485afb){return _0x485afb;});}return null;};}function removeEntity(_0x2327dd,_0x55785e){return function(_0x6cf490){if(_0x6cf490){return _0x6cf490[_0xb490('0x25')]()['then'](function(){var _0x365911=_0x6cf490[_0xb490('0x26')]({'plain':!![]});var _0x423634=_0xb490('0x27');return db['UserProfileResource']['destroy']({'where':{'type':_0x423634,'resourceId':_0x365911['id']}})[_0xb490('0x28')](function(){return _0x6cf490;});})[_0xb490('0x28')](function(){_0x2327dd[_0xb490('0x19')](0xcc)[_0xb490('0x1a')]();});}};}function handleEntityNotFound(_0x3ec8ea,_0x2c5c24){return function(_0x386ea1){if(!_0x386ea1){_0x3ec8ea[_0xb490('0x18')](0x194);}return _0x386ea1;};}function handleError(_0xeeb396,_0x24b9f8){_0x24b9f8=_0x24b9f8||0x1f4;return function(_0x39d6c6){logger[_0xb490('0x29')](_0x39d6c6['stack']);if(_0x39d6c6[_0xb490('0x2a')]){delete _0x39d6c6[_0xb490('0x2a')];}_0xeeb396['status'](_0x24b9f8)[_0xb490('0x2b')](_0x39d6c6);};}exports['index']=function(_0x169672,_0x2932c0){var _0x547b47={},_0x3cd019={},_0x44ec12={'count':0x0,'rows':[]};var _0x547f14=_[_0xb490('0x2c')](db[_0xb490('0x2d')]['rawAttributes'],function(_0x230b3c){return{'name':_0x230b3c['fieldName'],'type':_0x230b3c['type'][_0xb490('0x2e')]};});_0x3cd019[_0xb490('0x2f')]=_[_0xb490('0x2c')](_0x547f14,_0xb490('0x2a'));_0x3cd019[_0xb490('0x30')]=_[_0xb490('0x31')](_0x169672[_0xb490('0x30')]);_0x3cd019[_0xb490('0x32')]=_[_0xb490('0x33')](_0x3cd019[_0xb490('0x2f')],_0x3cd019['query']);_0x547b47[_0xb490('0x34')]=_['intersection'](_0x3cd019[_0xb490('0x2f')],qs[_0xb490('0x35')](_0x169672[_0xb490('0x30')]['fields']));_0x547b47[_0xb490('0x34')]=_0x547b47[_0xb490('0x34')]['length']?_0x547b47[_0xb490('0x34')]:_0x3cd019[_0xb490('0x2f')];if(!_0x169672[_0xb490('0x30')][_0xb490('0x36')](_0xb490('0x37'))){_0x547b47[_0xb490('0x1d')]=qs[_0xb490('0x1d')](_0x169672[_0xb490('0x30')][_0xb490('0x1d')]);_0x547b47['offset']=qs[_0xb490('0x1c')](_0x169672['query'][_0xb490('0x1c')]);}_0x547b47[_0xb490('0x38')]=qs[_0xb490('0x39')](_0x169672[_0xb490('0x30')]['sort']);_0x547b47[_0xb490('0x3a')]=qs[_0xb490('0x32')](_[_0xb490('0x3b')](_0x169672[_0xb490('0x30')],_0x3cd019[_0xb490('0x32')]),_0x547f14);if(_0x169672[_0xb490('0x30')][_0xb490('0x3c')]){_0x547b47[_0xb490('0x3a')]=_['merge'](_0x547b47[_0xb490('0x3a')],{'$or':[{'key':{'$like':'%'+_0x169672['query'][_0xb490('0x3c')]+'%'}},{'value':{'$like':'%'+_0x169672[_0xb490('0x30')]['filter']+'%'}}]});}_0x547b47=_['merge']({},_0x547b47,_0x169672[_0xb490('0x3d')]);var _0x5b8f6b={'where':_0x547b47[_0xb490('0x3a')]};return db[_0xb490('0x2d')][_0xb490('0x1f')](_0x5b8f6b)[_0xb490('0x28')](function(_0x20b5be){_0x44ec12['count']=_0x20b5be;if(_0x169672[_0xb490('0x30')][_0xb490('0x3e')]){_0x547b47[_0xb490('0x3f')]=[{'all':!![]}];}return db['CannedAnswer'][_0xb490('0x40')](_0x547b47);})[_0xb490('0x28')](function(_0x355bd3){_0x44ec12[_0xb490('0x41')]=_0x355bd3;return _0x44ec12;})[_0xb490('0x28')](respondWithFilteredResult(_0x2932c0,_0x547b47))[_0xb490('0x42')](handleError(_0x2932c0,null));};exports[_0xb490('0x43')]=function(_0x36a867,_0x366d74){var _0x59a5e9={'raw':!![],'where':{'id':_0x36a867[_0xb490('0x44')]['id']}},_0x24eea3={};_0x24eea3[_0xb490('0x2f')]=_[_0xb490('0x31')](db[_0xb490('0x2d')][_0xb490('0x45')]);_0x24eea3[_0xb490('0x30')]=_['keys'](_0x36a867[_0xb490('0x30')]);_0x24eea3[_0xb490('0x32')]=_[_0xb490('0x33')](_0x24eea3[_0xb490('0x2f')],_0x24eea3['query']);_0x59a5e9[_0xb490('0x34')]=_['intersection'](_0x24eea3[_0xb490('0x2f')],qs[_0xb490('0x35')](_0x36a867[_0xb490('0x30')][_0xb490('0x35')]));_0x59a5e9[_0xb490('0x34')]=_0x59a5e9[_0xb490('0x34')]['length']?_0x59a5e9[_0xb490('0x34')]:_0x24eea3['model'];if(_0x36a867[_0xb490('0x30')]['includeAll']){_0x59a5e9['include']=[{'all':!![]}];}_0x59a5e9=_['merge']({},_0x59a5e9,_0x36a867[_0xb490('0x3d')]);return db['CannedAnswer'][_0xb490('0x46')](_0x59a5e9)[_0xb490('0x28')](handleEntityNotFound(_0x366d74,null))['then'](respondWithResult(_0x366d74,null))[_0xb490('0x42')](handleError(_0x366d74,null));};exports[_0xb490('0x24')]=function(_0x415256,_0x10bf15){if(_0x415256['body']['id']){delete _0x415256[_0xb490('0x47')]['id'];}return db[_0xb490('0x2d')][_0xb490('0x46')]({'where':{'id':_0x415256['params']['id']}})[_0xb490('0x28')](handleEntityNotFound(_0x10bf15,null))[_0xb490('0x28')](saveUpdates(_0x415256[_0xb490('0x47')],null))[_0xb490('0x28')](respondWithResult(_0x10bf15,null))['catch'](handleError(_0x10bf15,null));};exports[_0xb490('0x25')]=function(_0x6e4802,_0x1070bc){return db[_0xb490('0x2d')]['find']({'where':{'id':_0x6e4802[_0xb490('0x44')]['id']}})['then'](handleEntityNotFound(_0x1070bc,null))['then'](removeEntity(_0x1070bc,null))['catch'](handleError(_0x1070bc,null));};exports[_0xb490('0x48')]=function(_0x2a5236,_0xaec795){var _0x37c435={'key':_0x2a5236[_0xb490('0x47')][_0xb490('0x2e')]};if(_0x2a5236['body'][_0xb490('0x49')]){_0x37c435['MailAccountId']=_0x2a5236[_0xb490('0x47')][_0xb490('0x49')];}else if(_0x2a5236[_0xb490('0x47')][_0xb490('0x4a')]){_0x37c435['SmsAccountId']=_0x2a5236['body'][_0xb490('0x4a')];}else if(_0x2a5236[_0xb490('0x47')][_0xb490('0x4b')]){_0x37c435[_0xb490('0x4b')]=_0x2a5236[_0xb490('0x47')][_0xb490('0x4b')];}else if(_0x2a5236['body'][_0xb490('0x4c')]){_0x37c435[_0xb490('0x4c')]=_0x2a5236['body']['ChatWebsiteId'];}return db['CannedAnswer'][_0xb490('0x46')]({'where':_0x37c435})[_0xb490('0x28')](function(_0x37fdcb){if(_0x37fdcb){throw new db[(_0xb490('0x4d'))]['ValidationError'](_0xb490('0x4e'));}return db[_0xb490('0x2d')][_0xb490('0x48')](_0x2a5236[_0xb490('0x47')]);})[_0xb490('0x28')](function(_0x331a61){var _0x29aca5=_0x2a5236['user']['get']({'plain':!![]});if(!_0x29aca5)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x29aca5['role']===_0xb490('0x4f')){var _0x49731d=_0x331a61[_0xb490('0x26')]({'plain':!![]});return db[_0xb490('0x50')][_0xb490('0x46')]({'where':{'name':_0xb490('0x27'),'userProfileId':_0x29aca5[_0xb490('0x51')]},'raw':!![]})[_0xb490('0x28')](function(_0x5d1539){if(_0x5d1539&&_0x5d1539['autoAssociation']===0x0){return db[_0xb490('0x52')][_0xb490('0x48')]({'name':_0x49731d[_0xb490('0x2a')],'resourceId':_0x49731d['id'],'type':_0x5d1539['name'],'sectionId':_0x5d1539['id']},{})['then'](function(){return _0x331a61;});}else{return _0x331a61;}})[_0xb490('0x42')](function(_0x3bfa97){logger['error'](_0xb490('0x53'),_0x3bfa97);throw _0x3bfa97;});}return _0x331a61;})[_0xb490('0x28')](respondWithResult(_0xaec795,0xc9))['catch'](handleError(_0xaec795,null));};
\ No newline at end of file