Built motion from commit 00bf23f6.|2.6.16
[motion2.git] / server / api / cannedAnswer / cannedAnswer.controller.js
index 90cd4da..4038f7a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x4be6=['nolimit','order','sort','where','pick','merge','filter','options','includeAll','include','findAll','rows','catch','show','params','find','body','create','MailAccountId','SmsAccountId','OpenchannelAccountId','ChatWebsiteId','Sequelize','ValidationError','The\x20inserted\x20key\x20already\x20exists.','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','UserProfileSection','userProfileId','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','util','path','ejs','lodash','squel','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','json','offset','undefined','limit','count','set','reject','save','update','then','destroy','get','CannedAnswers','end','error','stack','name','send','index','map','CannedAnswer','rawAttributes','fieldName','key','model','keys','filters','query','intersection','fields','attributes','length'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0x4be6,0x7a));var _0x64be=function(_0x2bd0dd,_0x167fb0){_0x2bd0dd=_0x2bd0dd-0x0;var _0x4637bb=_0x4be6[_0x2bd0dd];return _0x4637bb;};'use strict';var emlformat=require(_0x64be('0x0'));var rimraf=require(_0x64be('0x1'));var zipdir=require(_0x64be('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x64be('0x3'));var moment=require(_0x64be('0x4'));var BPromise=require(_0x64be('0x5'));var Mustache=require('mustache');var util=require(_0x64be('0x6'));var path=require(_0x64be('0x7'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0x64be('0x8'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x64be('0x9'));var squel=require(_0x64be('0xa'));var crypto=require('crypto');var jsforce=require(_0x64be('0xb'));var deskjs=require(_0x64be('0xc'));var toCsv=require(_0x64be('0xd'));var querystring=require(_0x64be('0xe'));var Papa=require(_0x64be('0xf'));var Redis=require(_0x64be('0x10'));var authService=require(_0x64be('0x11'));var qs=require(_0x64be('0x12'));var as=require(_0x64be('0x13'));var hardwareService=require(_0x64be('0x14'));var logger=require('../../config/logger')('api');var utils=require(_0x64be('0x15'));var config=require(_0x64be('0x16'));var licenseUtil=require(_0x64be('0x17'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x532c02,_0x2bb5cd){_0x2bb5cd=_0x2bb5cd||0xcc;return function(_0x2dd03f){if(_0x2dd03f){return _0x532c02[_0x64be('0x18')](_0x2bb5cd);}return _0x532c02[_0x64be('0x19')](_0x2bb5cd)['end']();};}function respondWithResult(_0x34832b,_0x3d024e){_0x3d024e=_0x3d024e||0xc8;return function(_0x49ede1){if(_0x49ede1){return _0x34832b['status'](_0x3d024e)[_0x64be('0x1a')](_0x49ede1);}};}function respondWithFilteredResult(_0x15cc38,_0x455380){return function(_0x309775){if(_0x309775){var _0x2f16d9=typeof _0x455380[_0x64be('0x1b')]===_0x64be('0x1c')&&typeof _0x455380[_0x64be('0x1d')]===_0x64be('0x1c');var _0x1b2277=_0x309775[_0x64be('0x1e')];var _0x38d75e=_0x2f16d9?0x0:_0x455380[_0x64be('0x1b')];var _0x4fb63f=_0x2f16d9?_0x309775[_0x64be('0x1e')]:_0x455380[_0x64be('0x1b')]+_0x455380[_0x64be('0x1d')];var _0x1d71cb;if(_0x4fb63f>=_0x1b2277){_0x4fb63f=_0x1b2277;_0x1d71cb=0xc8;}else{_0x1d71cb=0xce;}_0x15cc38[_0x64be('0x19')](_0x1d71cb);return _0x15cc38[_0x64be('0x1f')]('Content-Range',_0x38d75e+'-'+_0x4fb63f+'/'+_0x1b2277)['json'](_0x309775);}return null;};}function patchUpdates(_0x4b9a5c){return function(_0x5a09e3){try{jsonpatch['apply'](_0x5a09e3,_0x4b9a5c,!![]);}catch(_0x202d00){return BPromise[_0x64be('0x20')](_0x202d00);}return _0x5a09e3[_0x64be('0x21')]();};}function saveUpdates(_0x1900de,_0x48bf08){return function(_0x1819f2){if(_0x1819f2){return _0x1819f2[_0x64be('0x22')](_0x1900de)[_0x64be('0x23')](function(_0x5558a3){return _0x5558a3;});}return null;};}function removeEntity(_0x2d1740,_0x2f1ad5){return function(_0x1db4e8){if(_0x1db4e8){return _0x1db4e8[_0x64be('0x24')]()[_0x64be('0x23')](function(){var _0x47219c=_0x1db4e8[_0x64be('0x25')]({'plain':!![]});var _0x4b2a8f=_0x64be('0x26');return db['UserProfileResource'][_0x64be('0x24')]({'where':{'type':_0x4b2a8f,'resourceId':_0x47219c['id']}})[_0x64be('0x23')](function(){return _0x1db4e8;});})[_0x64be('0x23')](function(){_0x2d1740['status'](0xcc)[_0x64be('0x27')]();});}};}function handleEntityNotFound(_0x1df124,_0x13a513){return function(_0x4a8787){if(!_0x4a8787){_0x1df124[_0x64be('0x18')](0x194);}return _0x4a8787;};}function handleError(_0x36233b,_0x57e66a){_0x57e66a=_0x57e66a||0x1f4;return function(_0x4736d2){logger[_0x64be('0x28')](_0x4736d2[_0x64be('0x29')]);if(_0x4736d2[_0x64be('0x2a')]){delete _0x4736d2['name'];}_0x36233b['status'](_0x57e66a)[_0x64be('0x2b')](_0x4736d2);};}exports[_0x64be('0x2c')]=function(_0x464841,_0x1e0852){var _0xd3e44a={},_0x2fb94f={},_0x7c0802={'count':0x0,'rows':[]};var _0x24c6ec=_[_0x64be('0x2d')](db[_0x64be('0x2e')][_0x64be('0x2f')],function(_0x3190d1){return{'name':_0x3190d1[_0x64be('0x30')],'type':_0x3190d1['type'][_0x64be('0x31')]};});_0x2fb94f[_0x64be('0x32')]=_['map'](_0x24c6ec,'name');_0x2fb94f['query']=_[_0x64be('0x33')](_0x464841['query']);_0x2fb94f[_0x64be('0x34')]=_['intersection'](_0x2fb94f['model'],_0x2fb94f[_0x64be('0x35')]);_0xd3e44a['attributes']=_[_0x64be('0x36')](_0x2fb94f[_0x64be('0x32')],qs[_0x64be('0x37')](_0x464841[_0x64be('0x35')][_0x64be('0x37')]));_0xd3e44a[_0x64be('0x38')]=_0xd3e44a[_0x64be('0x38')][_0x64be('0x39')]?_0xd3e44a[_0x64be('0x38')]:_0x2fb94f[_0x64be('0x32')];if(!_0x464841[_0x64be('0x35')]['hasOwnProperty'](_0x64be('0x3a'))){_0xd3e44a[_0x64be('0x1d')]=qs[_0x64be('0x1d')](_0x464841[_0x64be('0x35')][_0x64be('0x1d')]);_0xd3e44a[_0x64be('0x1b')]=qs['offset'](_0x464841['query'][_0x64be('0x1b')]);}_0xd3e44a[_0x64be('0x3b')]=qs[_0x64be('0x3c')](_0x464841['query'][_0x64be('0x3c')]);_0xd3e44a[_0x64be('0x3d')]=qs[_0x64be('0x34')](_[_0x64be('0x3e')](_0x464841[_0x64be('0x35')],_0x2fb94f[_0x64be('0x34')]),_0x24c6ec);if(_0x464841[_0x64be('0x35')]['filter']){_0xd3e44a[_0x64be('0x3d')]=_[_0x64be('0x3f')](_0xd3e44a[_0x64be('0x3d')],{'$or':[{'key':{'$like':'%'+_0x464841[_0x64be('0x35')][_0x64be('0x40')]+'%'}},{'value':{'$like':'%'+_0x464841['query'][_0x64be('0x40')]+'%'}}]});}_0xd3e44a=_[_0x64be('0x3f')]({},_0xd3e44a,_0x464841[_0x64be('0x41')]);var _0x43f698={'where':_0xd3e44a[_0x64be('0x3d')]};return db['CannedAnswer'][_0x64be('0x1e')](_0x43f698)[_0x64be('0x23')](function(_0x3f30d2){_0x7c0802[_0x64be('0x1e')]=_0x3f30d2;if(_0x464841['query'][_0x64be('0x42')]){_0xd3e44a[_0x64be('0x43')]=[{'all':!![]}];}return db[_0x64be('0x2e')][_0x64be('0x44')](_0xd3e44a);})[_0x64be('0x23')](function(_0x1a31ff){_0x7c0802[_0x64be('0x45')]=_0x1a31ff;return _0x7c0802;})[_0x64be('0x23')](respondWithFilteredResult(_0x1e0852,_0xd3e44a))[_0x64be('0x46')](handleError(_0x1e0852,null));};exports[_0x64be('0x47')]=function(_0x3262b3,_0x50f51f){var _0x37bfd5={'raw':!![],'where':{'id':_0x3262b3[_0x64be('0x48')]['id']}},_0x377d26={};_0x377d26[_0x64be('0x32')]=_[_0x64be('0x33')](db[_0x64be('0x2e')][_0x64be('0x2f')]);_0x377d26[_0x64be('0x35')]=_[_0x64be('0x33')](_0x3262b3[_0x64be('0x35')]);_0x377d26[_0x64be('0x34')]=_[_0x64be('0x36')](_0x377d26[_0x64be('0x32')],_0x377d26[_0x64be('0x35')]);_0x37bfd5[_0x64be('0x38')]=_[_0x64be('0x36')](_0x377d26[_0x64be('0x32')],qs[_0x64be('0x37')](_0x3262b3[_0x64be('0x35')][_0x64be('0x37')]));_0x37bfd5[_0x64be('0x38')]=_0x37bfd5[_0x64be('0x38')]['length']?_0x37bfd5[_0x64be('0x38')]:_0x377d26['model'];if(_0x3262b3[_0x64be('0x35')][_0x64be('0x42')]){_0x37bfd5[_0x64be('0x43')]=[{'all':!![]}];}_0x37bfd5=_[_0x64be('0x3f')]({},_0x37bfd5,_0x3262b3[_0x64be('0x41')]);return db[_0x64be('0x2e')][_0x64be('0x49')](_0x37bfd5)[_0x64be('0x23')](handleEntityNotFound(_0x50f51f,null))['then'](respondWithResult(_0x50f51f,null))[_0x64be('0x46')](handleError(_0x50f51f,null));};exports['update']=function(_0x15280a,_0x3c8c17){if(_0x15280a[_0x64be('0x4a')]['id']){delete _0x15280a[_0x64be('0x4a')]['id'];}return db[_0x64be('0x2e')]['find']({'where':{'id':_0x15280a['params']['id']}})[_0x64be('0x23')](handleEntityNotFound(_0x3c8c17,null))['then'](saveUpdates(_0x15280a['body'],null))[_0x64be('0x23')](respondWithResult(_0x3c8c17,null))['catch'](handleError(_0x3c8c17,null));};exports[_0x64be('0x24')]=function(_0x371fbf,_0x2856fa){return db[_0x64be('0x2e')][_0x64be('0x49')]({'where':{'id':_0x371fbf[_0x64be('0x48')]['id']}})[_0x64be('0x23')](handleEntityNotFound(_0x2856fa,null))[_0x64be('0x23')](removeEntity(_0x2856fa,null))[_0x64be('0x46')](handleError(_0x2856fa,null));};exports[_0x64be('0x4b')]=function(_0x234257,_0x1c11a4){var _0x550c01={'key':_0x234257['body'][_0x64be('0x31')]};if(_0x234257[_0x64be('0x4a')][_0x64be('0x4c')]){_0x550c01[_0x64be('0x4c')]=_0x234257[_0x64be('0x4a')][_0x64be('0x4c')];}else if(_0x234257[_0x64be('0x4a')][_0x64be('0x4d')]){_0x550c01[_0x64be('0x4d')]=_0x234257[_0x64be('0x4a')][_0x64be('0x4d')];}else if(_0x234257[_0x64be('0x4a')][_0x64be('0x4e')]){_0x550c01[_0x64be('0x4e')]=_0x234257[_0x64be('0x4a')][_0x64be('0x4e')];}else if(_0x234257[_0x64be('0x4a')][_0x64be('0x4f')]){_0x550c01[_0x64be('0x4f')]=_0x234257[_0x64be('0x4a')][_0x64be('0x4f')];}return db[_0x64be('0x2e')][_0x64be('0x49')]({'where':_0x550c01})[_0x64be('0x23')](function(_0xc4828a){if(_0xc4828a){throw new db[(_0x64be('0x50'))][(_0x64be('0x51'))](_0x64be('0x52'));}return db['CannedAnswer']['create'](_0x234257[_0x64be('0x4a')]);})[_0x64be('0x23')](function(_0x19ab72){var _0x1621a7=_0x234257['user'][_0x64be('0x25')]({'plain':!![]});if(!_0x1621a7)throw new Error(_0x64be('0x53'));if(_0x1621a7[_0x64be('0x54')]===_0x64be('0x55')){var _0x551e65=_0x19ab72[_0x64be('0x25')]({'plain':!![]});return db[_0x64be('0x56')][_0x64be('0x49')]({'where':{'name':'CannedAnswers','userProfileId':_0x1621a7[_0x64be('0x57')]},'raw':!![]})[_0x64be('0x23')](function(_0x38f4b7){if(_0x38f4b7&&_0x38f4b7['autoAssociation']===0x0){return db[_0x64be('0x58')][_0x64be('0x4b')]({'name':_0x551e65[_0x64be('0x2a')],'resourceId':_0x551e65['id'],'type':_0x38f4b7[_0x64be('0x2a')],'sectionId':_0x38f4b7['id']},{})[_0x64be('0x23')](function(){return _0x19ab72;});}else{return _0x19ab72;}})[_0x64be('0x46')](function(_0x4cefe4){logger[_0x64be('0x28')](_0x64be('0x59'),_0x4cefe4);throw _0x4cefe4;});}return _0x19ab72;})[_0x64be('0x23')](respondWithResult(_0x1c11a4,0xc9))[_0x64be('0x46')](handleError(_0x1c11a4,null));};
\ No newline at end of file
+var _0x8de3=['then','destroy','get','UserProfileResource','error','stack','name','send','index','CannedAnswer','rawAttributes','fieldName','type','model','map','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','where','pick','filter','options','includeAll','findAll','rows','catch','show','params','include','find','update','body','create','key','MailAccountId','SmsAccountId','OpenchannelAccountId','ChatWebsiteId','ValidationError','The\x20inserted\x20key\x20already\x20exists.','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','CannedAnswers','autoAssociation','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','to-csv','fs-extra','lodash','squel','crypto','desk.js','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','undefined','limit','count','offset','set','Content-Range','apply','reject'];(function(_0x413b4d,_0xa3459c){var _0x8b810a=function(_0x22d441){while(--_0x22d441){_0x413b4d['push'](_0x413b4d['shift']());}};_0x8b810a(++_0xa3459c);}(_0x8de3,0x19d));var _0x38de=function(_0x5e3cef,_0x3c57f5){_0x5e3cef=_0x5e3cef-0x0;var _0x34c370=_0x8de3[_0x5e3cef];return _0x34c370;};'use strict';var emlformat=require(_0x38de('0x0'));var rimraf=require(_0x38de('0x1'));var zipdir=require(_0x38de('0x2'));var jsonpatch=require(_0x38de('0x3'));var rp=require(_0x38de('0x4'));var moment=require(_0x38de('0x5'));var BPromise=require(_0x38de('0x6'));var Mustache=require(_0x38de('0x7'));var util=require(_0x38de('0x8'));var path=require(_0x38de('0x9'));var sox=require('sox');var csv=require(_0x38de('0xa'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x38de('0xb'));var _=require(_0x38de('0xc'));var squel=require(_0x38de('0xd'));var crypto=require(_0x38de('0xe'));var jsforce=require('jsforce');var deskjs=require(_0x38de('0xf'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0x38de('0x10'));var authService=require(_0x38de('0x11'));var qs=require(_0x38de('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x38de('0x13'));var logger=require(_0x38de('0x14'))(_0x38de('0x15'));var utils=require('../../config/utils');var config=require(_0x38de('0x16'));var licenseUtil=require(_0x38de('0x17'));var db=require(_0x38de('0x18'))['db'];function respondWithStatusCode(_0x109c64,_0x42c5b2){_0x42c5b2=_0x42c5b2||0xcc;return function(_0xb97760){if(_0xb97760){return _0x109c64[_0x38de('0x19')](_0x42c5b2);}return _0x109c64[_0x38de('0x1a')](_0x42c5b2)[_0x38de('0x1b')]();};}function respondWithResult(_0x46994b,_0x1277d1){_0x1277d1=_0x1277d1||0xc8;return function(_0x2fc70b){if(_0x2fc70b){return _0x46994b['status'](_0x1277d1)[_0x38de('0x1c')](_0x2fc70b);}};}function respondWithFilteredResult(_0x3c2ef7,_0x2088db){return function(_0x3bd612){if(_0x3bd612){var _0x473cd4=typeof _0x2088db['offset']===_0x38de('0x1d')&&typeof _0x2088db[_0x38de('0x1e')]===_0x38de('0x1d');var _0x3c5e72=_0x3bd612[_0x38de('0x1f')];var _0x383386=_0x473cd4?0x0:_0x2088db[_0x38de('0x20')];var _0x3e3eca=_0x473cd4?_0x3bd612[_0x38de('0x1f')]:_0x2088db[_0x38de('0x20')]+_0x2088db[_0x38de('0x1e')];var _0x428926;if(_0x3e3eca>=_0x3c5e72){_0x3e3eca=_0x3c5e72;_0x428926=0xc8;}else{_0x428926=0xce;}_0x3c2ef7[_0x38de('0x1a')](_0x428926);return _0x3c2ef7[_0x38de('0x21')](_0x38de('0x22'),_0x383386+'-'+_0x3e3eca+'/'+_0x3c5e72)[_0x38de('0x1c')](_0x3bd612);}return null;};}function patchUpdates(_0x3cdb47){return function(_0x5c9ab8){try{jsonpatch[_0x38de('0x23')](_0x5c9ab8,_0x3cdb47,!![]);}catch(_0x364776){return BPromise[_0x38de('0x24')](_0x364776);}return _0x5c9ab8['save']();};}function saveUpdates(_0x59c549,_0x33605e){return function(_0x45c2cf){if(_0x45c2cf){return _0x45c2cf['update'](_0x59c549)[_0x38de('0x25')](function(_0x50a6f5){return _0x50a6f5;});}return null;};}function removeEntity(_0x49de2e,_0x4f60db){return function(_0x37a2e4){if(_0x37a2e4){return _0x37a2e4[_0x38de('0x26')]()['then'](function(){var _0x1d9faf=_0x37a2e4[_0x38de('0x27')]({'plain':!![]});var _0x1d35b7='CannedAnswers';return db[_0x38de('0x28')][_0x38de('0x26')]({'where':{'type':_0x1d35b7,'resourceId':_0x1d9faf['id']}})[_0x38de('0x25')](function(){return _0x37a2e4;});})[_0x38de('0x25')](function(){_0x49de2e[_0x38de('0x1a')](0xcc)[_0x38de('0x1b')]();});}};}function handleEntityNotFound(_0x1f25f9,_0x40581a){return function(_0x160a50){if(!_0x160a50){_0x1f25f9['sendStatus'](0x194);}return _0x160a50;};}function handleError(_0xa9eeac,_0x3faba2){_0x3faba2=_0x3faba2||0x1f4;return function(_0x478f94){logger[_0x38de('0x29')](_0x478f94[_0x38de('0x2a')]);if(_0x478f94[_0x38de('0x2b')]){delete _0x478f94['name'];}_0xa9eeac[_0x38de('0x1a')](_0x3faba2)[_0x38de('0x2c')](_0x478f94);};}exports[_0x38de('0x2d')]=function(_0x1cde59,_0x23299e){var _0x5e0faa={},_0x5425a2={},_0x51a854={'count':0x0,'rows':[]};var _0x35b030=_['map'](db[_0x38de('0x2e')][_0x38de('0x2f')],function(_0x46b830){return{'name':_0x46b830[_0x38de('0x30')],'type':_0x46b830[_0x38de('0x31')]['key']};});_0x5425a2[_0x38de('0x32')]=_[_0x38de('0x33')](_0x35b030,_0x38de('0x2b'));_0x5425a2[_0x38de('0x34')]=_[_0x38de('0x35')](_0x1cde59[_0x38de('0x34')]);_0x5425a2[_0x38de('0x36')]=_[_0x38de('0x37')](_0x5425a2[_0x38de('0x32')],_0x5425a2[_0x38de('0x34')]);_0x5e0faa[_0x38de('0x38')]=_[_0x38de('0x37')](_0x5425a2[_0x38de('0x32')],qs['fields'](_0x1cde59['query'][_0x38de('0x39')]));_0x5e0faa[_0x38de('0x38')]=_0x5e0faa[_0x38de('0x38')][_0x38de('0x3a')]?_0x5e0faa['attributes']:_0x5425a2[_0x38de('0x32')];if(!_0x1cde59[_0x38de('0x34')][_0x38de('0x3b')](_0x38de('0x3c'))){_0x5e0faa[_0x38de('0x1e')]=qs[_0x38de('0x1e')](_0x1cde59['query'][_0x38de('0x1e')]);_0x5e0faa[_0x38de('0x20')]=qs[_0x38de('0x20')](_0x1cde59[_0x38de('0x34')][_0x38de('0x20')]);}_0x5e0faa['order']=qs[_0x38de('0x3d')](_0x1cde59[_0x38de('0x34')][_0x38de('0x3d')]);_0x5e0faa[_0x38de('0x3e')]=qs[_0x38de('0x36')](_[_0x38de('0x3f')](_0x1cde59[_0x38de('0x34')],_0x5425a2[_0x38de('0x36')]),_0x35b030);if(_0x1cde59[_0x38de('0x34')][_0x38de('0x40')]){_0x5e0faa[_0x38de('0x3e')]=_['merge'](_0x5e0faa[_0x38de('0x3e')],{'$or':[{'key':{'$like':'%'+_0x1cde59[_0x38de('0x34')][_0x38de('0x40')]+'%'}},{'value':{'$like':'%'+_0x1cde59[_0x38de('0x34')]['filter']+'%'}}]});}_0x5e0faa=_['merge']({},_0x5e0faa,_0x1cde59[_0x38de('0x41')]);var _0x36063f={'where':_0x5e0faa[_0x38de('0x3e')]};return db[_0x38de('0x2e')]['count'](_0x36063f)[_0x38de('0x25')](function(_0x517f8c){_0x51a854[_0x38de('0x1f')]=_0x517f8c;if(_0x1cde59[_0x38de('0x34')][_0x38de('0x42')]){_0x5e0faa['include']=[{'all':!![]}];}return db[_0x38de('0x2e')][_0x38de('0x43')](_0x5e0faa);})[_0x38de('0x25')](function(_0x4b449f){_0x51a854[_0x38de('0x44')]=_0x4b449f;return _0x51a854;})[_0x38de('0x25')](respondWithFilteredResult(_0x23299e,_0x5e0faa))[_0x38de('0x45')](handleError(_0x23299e,null));};exports[_0x38de('0x46')]=function(_0x444b40,_0x20cd8a){var _0x44373f={'raw':!![],'where':{'id':_0x444b40[_0x38de('0x47')]['id']}},_0x4771c0={};_0x4771c0['model']=_[_0x38de('0x35')](db[_0x38de('0x2e')]['rawAttributes']);_0x4771c0[_0x38de('0x34')]=_[_0x38de('0x35')](_0x444b40['query']);_0x4771c0[_0x38de('0x36')]=_[_0x38de('0x37')](_0x4771c0[_0x38de('0x32')],_0x4771c0[_0x38de('0x34')]);_0x44373f[_0x38de('0x38')]=_[_0x38de('0x37')](_0x4771c0['model'],qs['fields'](_0x444b40['query'][_0x38de('0x39')]));_0x44373f['attributes']=_0x44373f[_0x38de('0x38')][_0x38de('0x3a')]?_0x44373f['attributes']:_0x4771c0['model'];if(_0x444b40[_0x38de('0x34')][_0x38de('0x42')]){_0x44373f[_0x38de('0x48')]=[{'all':!![]}];}_0x44373f=_['merge']({},_0x44373f,_0x444b40['options']);return db[_0x38de('0x2e')][_0x38de('0x49')](_0x44373f)[_0x38de('0x25')](handleEntityNotFound(_0x20cd8a,null))[_0x38de('0x25')](respondWithResult(_0x20cd8a,null))[_0x38de('0x45')](handleError(_0x20cd8a,null));};exports[_0x38de('0x4a')]=function(_0x3ebe93,_0x4acf7e){if(_0x3ebe93[_0x38de('0x4b')]['id']){delete _0x3ebe93['body']['id'];}return db[_0x38de('0x2e')]['find']({'where':{'id':_0x3ebe93[_0x38de('0x47')]['id']}})['then'](handleEntityNotFound(_0x4acf7e,null))[_0x38de('0x25')](saveUpdates(_0x3ebe93['body'],null))['then'](respondWithResult(_0x4acf7e,null))[_0x38de('0x45')](handleError(_0x4acf7e,null));};exports['destroy']=function(_0x14f699,_0x29e110){return db[_0x38de('0x2e')][_0x38de('0x49')]({'where':{'id':_0x14f699[_0x38de('0x47')]['id']}})[_0x38de('0x25')](handleEntityNotFound(_0x29e110,null))['then'](removeEntity(_0x29e110,null))[_0x38de('0x45')](handleError(_0x29e110,null));};exports[_0x38de('0x4c')]=function(_0x2d22dd,_0x1f3e25){var _0x188311={'key':_0x2d22dd[_0x38de('0x4b')][_0x38de('0x4d')]};if(_0x2d22dd[_0x38de('0x4b')][_0x38de('0x4e')]){_0x188311[_0x38de('0x4e')]=_0x2d22dd[_0x38de('0x4b')][_0x38de('0x4e')];}else if(_0x2d22dd[_0x38de('0x4b')]['SmsAccountId']){_0x188311['SmsAccountId']=_0x2d22dd[_0x38de('0x4b')][_0x38de('0x4f')];}else if(_0x2d22dd['body'][_0x38de('0x50')]){_0x188311[_0x38de('0x50')]=_0x2d22dd[_0x38de('0x4b')][_0x38de('0x50')];}else if(_0x2d22dd[_0x38de('0x4b')][_0x38de('0x51')]){_0x188311['ChatWebsiteId']=_0x2d22dd[_0x38de('0x4b')]['ChatWebsiteId'];}return db['CannedAnswer'][_0x38de('0x49')]({'where':_0x188311})[_0x38de('0x25')](function(_0x37347e){if(_0x37347e){throw new db['Sequelize'][(_0x38de('0x52'))](_0x38de('0x53'));}return db[_0x38de('0x2e')][_0x38de('0x4c')](_0x2d22dd['body']);})[_0x38de('0x25')](function(_0x23f77b){var _0x5d4c47=_0x2d22dd[_0x38de('0x54')][_0x38de('0x27')]({'plain':!![]});if(!_0x5d4c47)throw new Error(_0x38de('0x55'));if(_0x5d4c47[_0x38de('0x56')]===_0x38de('0x54')){var _0x479c74=_0x23f77b[_0x38de('0x27')]({'plain':!![]});return db[_0x38de('0x57')][_0x38de('0x49')]({'where':{'name':_0x38de('0x58'),'userProfileId':_0x5d4c47['userProfileId']},'raw':!![]})[_0x38de('0x25')](function(_0x249fbd){if(_0x249fbd&&_0x249fbd[_0x38de('0x59')]===0x0){return db['UserProfileResource']['create']({'name':_0x479c74[_0x38de('0x2b')],'resourceId':_0x479c74['id'],'type':_0x249fbd[_0x38de('0x2b')],'sectionId':_0x249fbd['id']},{})[_0x38de('0x25')](function(){return _0x23f77b;});}else{return _0x23f77b;}})[_0x38de('0x45')](function(_0x3eab35){logger[_0x38de('0x29')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x3eab35);throw _0x3eab35;});}return _0x23f77b;})[_0x38de('0x25')](respondWithResult(_0x1f3e25,0xc9))['catch'](handleError(_0x1f3e25,null));};
\ No newline at end of file