Built motion from commit efa66e19.|2.6.22
[motion2.git] / server / api / cannedAnswer / cannedAnswer.controller.js
index 5fa6b89..faa62de 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 _0xeada=['stack','name','send','index','CannedAnswer','rawAttributes','fieldName','type','key','model','map','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','where','filter','merge','options','includeAll','include','findAll','rows','show','params','catch','body','find','MailAccountId','SmsAccountId','OpenchannelAccountId','ChatWebsiteId','Sequelize','ValidationError','The\x20inserted\x20key\x20already\x20exists.','create','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','eml-format','rimraf','moment','bluebird','mustache','util','sox','to-csv','fs-extra','lodash','squel','jsforce','papaparse','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../mysqldb','sendStatus','status','end','json','offset','undefined','count','limit','set','Content-Range','reject','save','update','then','destroy','CannedAnswers','UserProfileResource','error'];(function(_0x3054be,_0x1bdc8b){var _0x3df150=function(_0x56cfbf){while(--_0x56cfbf){_0x3054be['push'](_0x3054be['shift']());}};_0x3df150(++_0x1bdc8b);}(_0xeada,0x17b));var _0xaead=function(_0x2641f9,_0x26715f){_0x2641f9=_0x2641f9-0x0;var _0x585741=_0xeada[_0x2641f9];return _0x585741;};'use strict';var emlformat=require(_0xaead('0x0'));var rimraf=require(_0xaead('0x1'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0xaead('0x2'));var BPromise=require(_0xaead('0x3'));var Mustache=require(_0xaead('0x4'));var util=require(_0xaead('0x5'));var path=require('path');var sox=require(_0xaead('0x6'));var csv=require(_0xaead('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xaead('0x8'));var _=require(_0xaead('0x9'));var squel=require(_0xaead('0xa'));var crypto=require('crypto');var jsforce=require(_0xaead('0xb'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0xaead('0xc'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0xaead('0xd'));var hardwareService=require(_0xaead('0xe'));var logger=require(_0xaead('0xf'))('api');var utils=require(_0xaead('0x10'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0xaead('0x11'))['db'];function respondWithStatusCode(_0x3fff40,_0x51fa61){_0x51fa61=_0x51fa61||0xcc;return function(_0x1d0c20){if(_0x1d0c20){return _0x3fff40[_0xaead('0x12')](_0x51fa61);}return _0x3fff40[_0xaead('0x13')](_0x51fa61)[_0xaead('0x14')]();};}function respondWithResult(_0x321d9f,_0x5a78b6){_0x5a78b6=_0x5a78b6||0xc8;return function(_0x3ac8fb){if(_0x3ac8fb){return _0x321d9f[_0xaead('0x13')](_0x5a78b6)[_0xaead('0x15')](_0x3ac8fb);}};}function respondWithFilteredResult(_0x436b61,_0xa9ba0f){return function(_0x334b42){if(_0x334b42){var _0x2a079e=typeof _0xa9ba0f[_0xaead('0x16')]===_0xaead('0x17')&&typeof _0xa9ba0f['limit']===_0xaead('0x17');var _0x1ca25f=_0x334b42[_0xaead('0x18')];var _0x436896=_0x2a079e?0x0:_0xa9ba0f['offset'];var _0xa284c6=_0x2a079e?_0x334b42['count']:_0xa9ba0f[_0xaead('0x16')]+_0xa9ba0f[_0xaead('0x19')];var _0x4c2c3b;if(_0xa284c6>=_0x1ca25f){_0xa284c6=_0x1ca25f;_0x4c2c3b=0xc8;}else{_0x4c2c3b=0xce;}_0x436b61[_0xaead('0x13')](_0x4c2c3b);return _0x436b61[_0xaead('0x1a')](_0xaead('0x1b'),_0x436896+'-'+_0xa284c6+'/'+_0x1ca25f)['json'](_0x334b42);}return null;};}function patchUpdates(_0x3b1995){return function(_0x56a2da){try{jsonpatch['apply'](_0x56a2da,_0x3b1995,!![]);}catch(_0x2d309e){return BPromise[_0xaead('0x1c')](_0x2d309e);}return _0x56a2da[_0xaead('0x1d')]();};}function saveUpdates(_0x524d73,_0x499e6e){return function(_0x32e58d){if(_0x32e58d){return _0x32e58d[_0xaead('0x1e')](_0x524d73)[_0xaead('0x1f')](function(_0x3c890b){return _0x3c890b;});}return null;};}function removeEntity(_0x414cd4,_0x4c0d4a){return function(_0x95584f){if(_0x95584f){return _0x95584f[_0xaead('0x20')]()[_0xaead('0x1f')](function(){var _0x54e1e8=_0x95584f['get']({'plain':!![]});var _0x150a15=_0xaead('0x21');return db[_0xaead('0x22')]['destroy']({'where':{'type':_0x150a15,'resourceId':_0x54e1e8['id']}})[_0xaead('0x1f')](function(){return _0x95584f;});})[_0xaead('0x1f')](function(){_0x414cd4[_0xaead('0x13')](0xcc)['end']();});}};}function handleEntityNotFound(_0x2459e4,_0x19bcf1){return function(_0x1e1385){if(!_0x1e1385){_0x2459e4[_0xaead('0x12')](0x194);}return _0x1e1385;};}function handleError(_0x3e3ffb,_0x89096b){_0x89096b=_0x89096b||0x1f4;return function(_0x47f8fe){logger[_0xaead('0x23')](_0x47f8fe[_0xaead('0x24')]);if(_0x47f8fe[_0xaead('0x25')]){delete _0x47f8fe['name'];}_0x3e3ffb[_0xaead('0x13')](_0x89096b)[_0xaead('0x26')](_0x47f8fe);};}exports[_0xaead('0x27')]=function(_0xdc22f4,_0x543a94){var _0x2d143e={},_0x54ee95={},_0x277303={'count':0x0,'rows':[]};var _0x2f5392=_['map'](db[_0xaead('0x28')][_0xaead('0x29')],function(_0x1c54bf){return{'name':_0x1c54bf[_0xaead('0x2a')],'type':_0x1c54bf[_0xaead('0x2b')][_0xaead('0x2c')]};});_0x54ee95[_0xaead('0x2d')]=_[_0xaead('0x2e')](_0x2f5392,_0xaead('0x25'));_0x54ee95[_0xaead('0x2f')]=_[_0xaead('0x30')](_0xdc22f4[_0xaead('0x2f')]);_0x54ee95[_0xaead('0x31')]=_[_0xaead('0x32')](_0x54ee95[_0xaead('0x2d')],_0x54ee95[_0xaead('0x2f')]);_0x2d143e[_0xaead('0x33')]=_[_0xaead('0x32')](_0x54ee95['model'],qs[_0xaead('0x34')](_0xdc22f4[_0xaead('0x2f')][_0xaead('0x34')]));_0x2d143e[_0xaead('0x33')]=_0x2d143e['attributes'][_0xaead('0x35')]?_0x2d143e[_0xaead('0x33')]:_0x54ee95['model'];if(!_0xdc22f4['query'][_0xaead('0x36')]('nolimit')){_0x2d143e['limit']=qs[_0xaead('0x19')](_0xdc22f4[_0xaead('0x2f')]['limit']);_0x2d143e['offset']=qs['offset'](_0xdc22f4[_0xaead('0x2f')][_0xaead('0x16')]);}_0x2d143e['order']=qs['sort'](_0xdc22f4[_0xaead('0x2f')]['sort']);_0x2d143e[_0xaead('0x37')]=qs[_0xaead('0x31')](_['pick'](_0xdc22f4[_0xaead('0x2f')],_0x54ee95['filters']),_0x2f5392);if(_0xdc22f4[_0xaead('0x2f')][_0xaead('0x38')]){_0x2d143e[_0xaead('0x37')]=_[_0xaead('0x39')](_0x2d143e[_0xaead('0x37')],{'$or':[{'key':{'$like':'%'+_0xdc22f4['query'][_0xaead('0x38')]+'%'}},{'value':{'$like':'%'+_0xdc22f4[_0xaead('0x2f')][_0xaead('0x38')]+'%'}}]});}_0x2d143e=_[_0xaead('0x39')]({},_0x2d143e,_0xdc22f4[_0xaead('0x3a')]);var _0x5c4e8e={'where':_0x2d143e[_0xaead('0x37')]};return db[_0xaead('0x28')][_0xaead('0x18')](_0x5c4e8e)[_0xaead('0x1f')](function(_0x2126e5){_0x277303[_0xaead('0x18')]=_0x2126e5;if(_0xdc22f4[_0xaead('0x2f')][_0xaead('0x3b')]){_0x2d143e[_0xaead('0x3c')]=[{'all':!![]}];}return db[_0xaead('0x28')][_0xaead('0x3d')](_0x2d143e);})[_0xaead('0x1f')](function(_0xfa4dc9){_0x277303[_0xaead('0x3e')]=_0xfa4dc9;return _0x277303;})['then'](respondWithFilteredResult(_0x543a94,_0x2d143e))['catch'](handleError(_0x543a94,null));};exports[_0xaead('0x3f')]=function(_0x225565,_0x2c2161){var _0x322849={'raw':!![],'where':{'id':_0x225565[_0xaead('0x40')]['id']}},_0x52a408={};_0x52a408[_0xaead('0x2d')]=_[_0xaead('0x30')](db[_0xaead('0x28')][_0xaead('0x29')]);_0x52a408[_0xaead('0x2f')]=_[_0xaead('0x30')](_0x225565[_0xaead('0x2f')]);_0x52a408[_0xaead('0x31')]=_[_0xaead('0x32')](_0x52a408[_0xaead('0x2d')],_0x52a408[_0xaead('0x2f')]);_0x322849['attributes']=_[_0xaead('0x32')](_0x52a408[_0xaead('0x2d')],qs[_0xaead('0x34')](_0x225565[_0xaead('0x2f')][_0xaead('0x34')]));_0x322849['attributes']=_0x322849[_0xaead('0x33')][_0xaead('0x35')]?_0x322849['attributes']:_0x52a408[_0xaead('0x2d')];if(_0x225565[_0xaead('0x2f')]['includeAll']){_0x322849['include']=[{'all':!![]}];}_0x322849=_[_0xaead('0x39')]({},_0x322849,_0x225565['options']);return db[_0xaead('0x28')]['find'](_0x322849)['then'](handleEntityNotFound(_0x2c2161,null))[_0xaead('0x1f')](respondWithResult(_0x2c2161,null))[_0xaead('0x41')](handleError(_0x2c2161,null));};exports[_0xaead('0x1e')]=function(_0x4730c9,_0x3bc71d){if(_0x4730c9[_0xaead('0x42')]['id']){delete _0x4730c9['body']['id'];}return db[_0xaead('0x28')]['find']({'where':{'id':_0x4730c9[_0xaead('0x40')]['id']}})[_0xaead('0x1f')](handleEntityNotFound(_0x3bc71d,null))['then'](saveUpdates(_0x4730c9[_0xaead('0x42')],null))['then'](respondWithResult(_0x3bc71d,null))[_0xaead('0x41')](handleError(_0x3bc71d,null));};exports[_0xaead('0x20')]=function(_0x3b8bec,_0x231687){return db[_0xaead('0x28')][_0xaead('0x43')]({'where':{'id':_0x3b8bec['params']['id']}})[_0xaead('0x1f')](handleEntityNotFound(_0x231687,null))[_0xaead('0x1f')](removeEntity(_0x231687,null))['catch'](handleError(_0x231687,null));};exports['create']=function(_0x1c103a,_0x296f3e){var _0x1cfe9f={'key':_0x1c103a[_0xaead('0x42')][_0xaead('0x2c')]};if(_0x1c103a[_0xaead('0x42')][_0xaead('0x44')]){_0x1cfe9f['MailAccountId']=_0x1c103a[_0xaead('0x42')][_0xaead('0x44')];}else if(_0x1c103a[_0xaead('0x42')][_0xaead('0x45')]){_0x1cfe9f[_0xaead('0x45')]=_0x1c103a[_0xaead('0x42')][_0xaead('0x45')];}else if(_0x1c103a[_0xaead('0x42')][_0xaead('0x46')]){_0x1cfe9f[_0xaead('0x46')]=_0x1c103a[_0xaead('0x42')][_0xaead('0x46')];}else if(_0x1c103a[_0xaead('0x42')]['ChatWebsiteId']){_0x1cfe9f[_0xaead('0x47')]=_0x1c103a[_0xaead('0x42')][_0xaead('0x47')];}return db['CannedAnswer']['find']({'where':_0x1cfe9f})['then'](function(_0x2f8c76){if(_0x2f8c76){throw new db[(_0xaead('0x48'))][(_0xaead('0x49'))](_0xaead('0x4a'));}return db['CannedAnswer'][_0xaead('0x4b')](_0x1c103a[_0xaead('0x42')]);})[_0xaead('0x1f')](function(_0x84b37b){var _0xc984f9=_0x1c103a[_0xaead('0x4c')][_0xaead('0x4d')]({'plain':!![]});if(!_0xc984f9)throw new Error(_0xaead('0x4e'));if(_0xc984f9[_0xaead('0x4f')]===_0xaead('0x4c')){var _0x54b671=_0x84b37b[_0xaead('0x4d')]({'plain':!![]});return db[_0xaead('0x50')][_0xaead('0x43')]({'where':{'name':_0xaead('0x21'),'userProfileId':_0xc984f9[_0xaead('0x51')]},'raw':!![]})[_0xaead('0x1f')](function(_0x23ad9b){if(_0x23ad9b&&_0x23ad9b['autoAssociation']===0x0){return db[_0xaead('0x22')][_0xaead('0x4b')]({'name':_0x54b671[_0xaead('0x25')],'resourceId':_0x54b671['id'],'type':_0x23ad9b[_0xaead('0x25')],'sectionId':_0x23ad9b['id']},{})[_0xaead('0x1f')](function(){return _0x84b37b;});}else{return _0x84b37b;}})['catch'](function(_0x107487){logger[_0xaead('0x23')](_0xaead('0x52'),_0x107487);throw _0x107487;});}return _0x84b37b;})['then'](respondWithResult(_0x296f3e,0xc9))[_0xaead('0x41')](handleError(_0x296f3e,null));};
\ No newline at end of file