Built motion from commit 497d3d92.|2.5.43
[motion2.git] / server / api / cannedAnswer / cannedAnswer.controller.js
index 3fae20f..3ca4b21 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x4f0f=['save','update','then','destroy','get','UserProfileResource','stack','name','send','CannedAnswer','rawAttributes','fieldName','type','key','keys','query','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filters','pick','merge','filter','options','includeAll','include','findAll','catch','show','model','find','body','params','create','MailAccountId','SmsAccountId','OpenchannelAccountId','ChatWebsiteId','Sequelize','ValidationError','The\x20inserted\x20key\x20already\x20exists.','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','CannedAnswers','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','eml-format','zip-dir','fast-json-patch','moment','mustache','util','path','to-csv','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','../../components/auth/service','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','sendStatus','status','end','json','offset','limit','count','set','Content-Range','apply','reject'];(function(_0x45e24b,_0x259b37){var _0x4b1fb2=function(_0x54cf56){while(--_0x54cf56){_0x45e24b['push'](_0x45e24b['shift']());}};_0x4b1fb2(++_0x259b37);}(_0x4f0f,0x184));var _0xf4f0=function(_0x2a7b1b,_0x2d4cea){_0x2a7b1b=_0x2a7b1b-0x0;var _0x42e247=_0x4f0f[_0x2a7b1b];return _0x42e247;};'use strict';var emlformat=require(_0xf4f0('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xf4f0('0x1'));var jsonpatch=require(_0xf4f0('0x2'));var rp=require('request-promise');var moment=require(_0xf4f0('0x3'));var BPromise=require('bluebird');var Mustache=require(_0xf4f0('0x4'));var util=require(_0xf4f0('0x5'));var path=require(_0xf4f0('0x6'));var sox=require('sox');var csv=require(_0xf4f0('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xf4f0('0x8'));var _=require(_0xf4f0('0x9'));var squel=require(_0xf4f0('0xa'));var crypto=require(_0xf4f0('0xb'));var jsforce=require(_0xf4f0('0xc'));var deskjs=require(_0xf4f0('0xd'));var toCsv=require(_0xf4f0('0x7'));var querystring=require(_0xf4f0('0xe'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0xf4f0('0xf'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xf4f0('0x10'));var logger=require(_0xf4f0('0x11'))(_0xf4f0('0x12'));var utils=require('../../config/utils');var config=require(_0xf4f0('0x13'));var licenseUtil=require(_0xf4f0('0x14'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0xaed50c,_0x2e7613){_0x2e7613=_0x2e7613||0xcc;return function(_0x4ce536){if(_0x4ce536){return _0xaed50c[_0xf4f0('0x15')](_0x2e7613);}return _0xaed50c[_0xf4f0('0x16')](_0x2e7613)[_0xf4f0('0x17')]();};}function respondWithResult(_0x15111f,_0x8e7c7f){_0x8e7c7f=_0x8e7c7f||0xc8;return function(_0x4c168f){if(_0x4c168f){return _0x15111f['status'](_0x8e7c7f)[_0xf4f0('0x18')](_0x4c168f);}};}function respondWithFilteredResult(_0xa22c3e,_0xa56c76){return function(_0x33fef9){if(_0x33fef9){var _0x2de482=typeof _0xa56c76[_0xf4f0('0x19')]==='undefined'&&typeof _0xa56c76[_0xf4f0('0x1a')]==='undefined';var _0x42e9a6=_0x33fef9[_0xf4f0('0x1b')];var _0x512391=_0x2de482?0x0:_0xa56c76['offset'];var _0x3672ba=_0x2de482?_0x33fef9['count']:_0xa56c76[_0xf4f0('0x19')]+_0xa56c76[_0xf4f0('0x1a')];var _0x3e5fe6;if(_0x3672ba>=_0x42e9a6){_0x3672ba=_0x42e9a6;_0x3e5fe6=0xc8;}else{_0x3e5fe6=0xce;}_0xa22c3e[_0xf4f0('0x16')](_0x3e5fe6);return _0xa22c3e[_0xf4f0('0x1c')](_0xf4f0('0x1d'),_0x512391+'-'+_0x3672ba+'/'+_0x42e9a6)[_0xf4f0('0x18')](_0x33fef9);}return null;};}function patchUpdates(_0x38494c){return function(_0x6207de){try{jsonpatch[_0xf4f0('0x1e')](_0x6207de,_0x38494c,!![]);}catch(_0xe32a6b){return BPromise[_0xf4f0('0x1f')](_0xe32a6b);}return _0x6207de[_0xf4f0('0x20')]();};}function saveUpdates(_0x310c5d,_0x195a0e){return function(_0x11138a){if(_0x11138a){return _0x11138a[_0xf4f0('0x21')](_0x310c5d)[_0xf4f0('0x22')](function(_0xdb55ab){return _0xdb55ab;});}return null;};}function removeEntity(_0x2675de,_0x41d73a){return function(_0x32f8c7){if(_0x32f8c7){return _0x32f8c7[_0xf4f0('0x23')]()['then'](function(){var _0x2cc44f=_0x32f8c7[_0xf4f0('0x24')]({'plain':!![]});var _0x53ba9c='CannedAnswers';return db[_0xf4f0('0x25')][_0xf4f0('0x23')]({'where':{'type':_0x53ba9c,'resourceId':_0x2cc44f['id']}})[_0xf4f0('0x22')](function(){return _0x32f8c7;});})['then'](function(){_0x2675de[_0xf4f0('0x16')](0xcc)['end']();});}};}function handleEntityNotFound(_0x432ba0,_0x3e48a3){return function(_0xf828c0){if(!_0xf828c0){_0x432ba0['sendStatus'](0x194);}return _0xf828c0;};}function handleError(_0x5695c9,_0x4d646e){_0x4d646e=_0x4d646e||0x1f4;return function(_0x35e2fd){logger['error'](_0x35e2fd[_0xf4f0('0x26')]);if(_0x35e2fd[_0xf4f0('0x27')]){delete _0x35e2fd[_0xf4f0('0x27')];}_0x5695c9[_0xf4f0('0x16')](_0x4d646e)[_0xf4f0('0x28')](_0x35e2fd);};}exports['index']=function(_0x3af86f,_0x10e2ea){var _0x319065={},_0x151aac={},_0x49503f={'count':0x0,'rows':[]};var _0x252085=_['map'](db[_0xf4f0('0x29')][_0xf4f0('0x2a')],function(_0x58da38){return{'name':_0x58da38[_0xf4f0('0x2b')],'type':_0x58da38[_0xf4f0('0x2c')][_0xf4f0('0x2d')]};});_0x151aac['model']=_['map'](_0x252085,_0xf4f0('0x27'));_0x151aac['query']=_[_0xf4f0('0x2e')](_0x3af86f[_0xf4f0('0x2f')]);_0x151aac['filters']=_[_0xf4f0('0x30')](_0x151aac['model'],_0x151aac[_0xf4f0('0x2f')]);_0x319065[_0xf4f0('0x31')]=_[_0xf4f0('0x30')](_0x151aac['model'],qs[_0xf4f0('0x32')](_0x3af86f['query']['fields']));_0x319065['attributes']=_0x319065[_0xf4f0('0x31')][_0xf4f0('0x33')]?_0x319065['attributes']:_0x151aac['model'];if(!_0x3af86f[_0xf4f0('0x2f')][_0xf4f0('0x34')](_0xf4f0('0x35'))){_0x319065[_0xf4f0('0x1a')]=qs[_0xf4f0('0x1a')](_0x3af86f[_0xf4f0('0x2f')][_0xf4f0('0x1a')]);_0x319065[_0xf4f0('0x19')]=qs[_0xf4f0('0x19')](_0x3af86f[_0xf4f0('0x2f')][_0xf4f0('0x19')]);}_0x319065[_0xf4f0('0x36')]=qs['sort'](_0x3af86f[_0xf4f0('0x2f')][_0xf4f0('0x37')]);_0x319065[_0xf4f0('0x38')]=qs[_0xf4f0('0x39')](_[_0xf4f0('0x3a')](_0x3af86f[_0xf4f0('0x2f')],_0x151aac[_0xf4f0('0x39')]),_0x252085);if(_0x3af86f[_0xf4f0('0x2f')]['filter']){_0x319065['where']=_[_0xf4f0('0x3b')](_0x319065[_0xf4f0('0x38')],{'$or':[{'key':{'$like':'%'+_0x3af86f['query'][_0xf4f0('0x3c')]+'%'}},{'value':{'$like':'%'+_0x3af86f[_0xf4f0('0x2f')]['filter']+'%'}}]});}_0x319065=_['merge']({},_0x319065,_0x3af86f[_0xf4f0('0x3d')]);var _0x48b01f={'where':_0x319065['where']};return db['CannedAnswer'][_0xf4f0('0x1b')](_0x48b01f)[_0xf4f0('0x22')](function(_0x15ca74){_0x49503f[_0xf4f0('0x1b')]=_0x15ca74;if(_0x3af86f[_0xf4f0('0x2f')][_0xf4f0('0x3e')]){_0x319065[_0xf4f0('0x3f')]=[{'all':!![]}];}return db['CannedAnswer'][_0xf4f0('0x40')](_0x319065);})[_0xf4f0('0x22')](function(_0x73f422){_0x49503f['rows']=_0x73f422;return _0x49503f;})['then'](respondWithFilteredResult(_0x10e2ea,_0x319065))[_0xf4f0('0x41')](handleError(_0x10e2ea,null));};exports[_0xf4f0('0x42')]=function(_0xeca992,_0x1504c2){var _0x40f31d={'raw':!![],'where':{'id':_0xeca992['params']['id']}},_0x171fc1={};_0x171fc1[_0xf4f0('0x43')]=_[_0xf4f0('0x2e')](db['CannedAnswer'][_0xf4f0('0x2a')]);_0x171fc1[_0xf4f0('0x2f')]=_[_0xf4f0('0x2e')](_0xeca992[_0xf4f0('0x2f')]);_0x171fc1[_0xf4f0('0x39')]=_[_0xf4f0('0x30')](_0x171fc1[_0xf4f0('0x43')],_0x171fc1[_0xf4f0('0x2f')]);_0x40f31d[_0xf4f0('0x31')]=_[_0xf4f0('0x30')](_0x171fc1[_0xf4f0('0x43')],qs[_0xf4f0('0x32')](_0xeca992['query']['fields']));_0x40f31d['attributes']=_0x40f31d[_0xf4f0('0x31')][_0xf4f0('0x33')]?_0x40f31d['attributes']:_0x171fc1['model'];if(_0xeca992['query']['includeAll']){_0x40f31d[_0xf4f0('0x3f')]=[{'all':!![]}];}_0x40f31d=_['merge']({},_0x40f31d,_0xeca992[_0xf4f0('0x3d')]);return db[_0xf4f0('0x29')][_0xf4f0('0x44')](_0x40f31d)[_0xf4f0('0x22')](handleEntityNotFound(_0x1504c2,null))[_0xf4f0('0x22')](respondWithResult(_0x1504c2,null))['catch'](handleError(_0x1504c2,null));};exports[_0xf4f0('0x21')]=function(_0x506506,_0x519c14){if(_0x506506[_0xf4f0('0x45')]['id']){delete _0x506506[_0xf4f0('0x45')]['id'];}return db[_0xf4f0('0x29')]['find']({'where':{'id':_0x506506[_0xf4f0('0x46')]['id']}})[_0xf4f0('0x22')](handleEntityNotFound(_0x519c14,null))['then'](saveUpdates(_0x506506[_0xf4f0('0x45')],null))['then'](respondWithResult(_0x519c14,null))['catch'](handleError(_0x519c14,null));};exports[_0xf4f0('0x23')]=function(_0x3f68de,_0x2b2517){return db['CannedAnswer'][_0xf4f0('0x44')]({'where':{'id':_0x3f68de[_0xf4f0('0x46')]['id']}})[_0xf4f0('0x22')](handleEntityNotFound(_0x2b2517,null))[_0xf4f0('0x22')](removeEntity(_0x2b2517,null))['catch'](handleError(_0x2b2517,null));};exports[_0xf4f0('0x47')]=function(_0x3fb3c3,_0x275cd8){var _0x1f59f4={'key':_0x3fb3c3['body'][_0xf4f0('0x2d')]};if(_0x3fb3c3['body']['MailAccountId']){_0x1f59f4[_0xf4f0('0x48')]=_0x3fb3c3[_0xf4f0('0x45')][_0xf4f0('0x48')];}else if(_0x3fb3c3[_0xf4f0('0x45')]['SmsAccountId']){_0x1f59f4[_0xf4f0('0x49')]=_0x3fb3c3[_0xf4f0('0x45')][_0xf4f0('0x49')];}else if(_0x3fb3c3[_0xf4f0('0x45')]['OpenchannelAccountId']){_0x1f59f4[_0xf4f0('0x4a')]=_0x3fb3c3[_0xf4f0('0x45')][_0xf4f0('0x4a')];}else if(_0x3fb3c3[_0xf4f0('0x45')][_0xf4f0('0x4b')]){_0x1f59f4[_0xf4f0('0x4b')]=_0x3fb3c3[_0xf4f0('0x45')]['ChatWebsiteId'];}return db[_0xf4f0('0x29')][_0xf4f0('0x44')]({'where':_0x1f59f4})[_0xf4f0('0x22')](function(_0x2ecfa9){if(_0x2ecfa9){throw new db[(_0xf4f0('0x4c'))][(_0xf4f0('0x4d'))](_0xf4f0('0x4e'));}return db[_0xf4f0('0x29')]['create'](_0x3fb3c3[_0xf4f0('0x45')]);})['then'](function(_0x2e8529){var _0x3e0dd1=_0x3fb3c3['user'][_0xf4f0('0x24')]({'plain':!![]});if(!_0x3e0dd1)throw new Error(_0xf4f0('0x4f'));if(_0x3e0dd1[_0xf4f0('0x50')]==='user'){var _0x46aec5=_0x2e8529[_0xf4f0('0x24')]({'plain':!![]});return db['UserProfileSection'][_0xf4f0('0x44')]({'where':{'name':_0xf4f0('0x51'),'userProfileId':_0x3e0dd1['userProfileId']},'raw':!![]})[_0xf4f0('0x22')](function(_0x25f158){if(_0x25f158&&_0x25f158['autoAssociation']===0x0){return db['UserProfileResource'][_0xf4f0('0x47')]({'name':_0x46aec5[_0xf4f0('0x27')],'resourceId':_0x46aec5['id'],'type':_0x25f158[_0xf4f0('0x27')],'sectionId':_0x25f158['id']},{})[_0xf4f0('0x22')](function(){return _0x2e8529;});}else{return _0x2e8529;}})[_0xf4f0('0x41')](function(_0x3eafa7){logger[_0xf4f0('0x52')](_0xf4f0('0x53'),_0x3eafa7);throw _0x3eafa7;});}return _0x2e8529;})[_0xf4f0('0x22')](respondWithResult(_0x275cd8,0xc9))[_0xf4f0('0x41')](handleError(_0x275cd8,null));};
\ No newline at end of file
+var _0x8b8a=['../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','count','apply','reject','save','update','then','destroy','error','name','send','index','map','CannedAnswer','fieldName','type','key','model','query','keys','filters','fields','attributes','nolimit','limit','order','sort','where','merge','filter','includeAll','include','rows','catch','params','intersection','options','body','find','create','MailAccountId','SmsAccountId','OpenchannelAccountId','ChatWebsiteId','Sequelize','ValidationError','The\x20inserted\x20key\x20already\x20exists.','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment'];(function(_0x37b279,_0x3ba2aa){var _0x537f36=function(_0x1051ce){while(--_0x1051ce){_0x37b279['push'](_0x37b279['shift']());}};_0x537f36(++_0x3ba2aa);}(_0x8b8a,0x146));var _0xa8b8=function(_0x162133,_0x286b9d){_0x162133=_0x162133-0x0;var _0x64641a=_0x8b8a[_0x162133];return _0x64641a;};'use strict';var emlformat=require(_0xa8b8('0x0'));var rimraf=require(_0xa8b8('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xa8b8('0x2'));var rp=require(_0xa8b8('0x3'));var moment=require(_0xa8b8('0x4'));var BPromise=require(_0xa8b8('0x5'));var Mustache=require(_0xa8b8('0x6'));var util=require(_0xa8b8('0x7'));var path=require('path');var sox=require('sox');var csv=require(_0xa8b8('0x8'));var ejs=require(_0xa8b8('0x9'));var fs=require('fs');var fs_extra=require(_0xa8b8('0xa'));var _=require(_0xa8b8('0xb'));var squel=require(_0xa8b8('0xc'));var crypto=require(_0xa8b8('0xd'));var jsforce=require(_0xa8b8('0xe'));var deskjs=require(_0xa8b8('0xf'));var toCsv=require('to-csv');var querystring=require(_0xa8b8('0x10'));var Papa=require(_0xa8b8('0x11'));var Redis=require(_0xa8b8('0x12'));var authService=require('../../components/auth/service');var qs=require(_0xa8b8('0x13'));var as=require(_0xa8b8('0x14'));var hardwareService=require(_0xa8b8('0x15'));var logger=require(_0xa8b8('0x16'))(_0xa8b8('0x17'));var utils=require(_0xa8b8('0x18'));var config=require(_0xa8b8('0x19'));var licenseUtil=require(_0xa8b8('0x1a'));var db=require(_0xa8b8('0x1b'))['db'];function respondWithStatusCode(_0x10cefc,_0xd5d7fa){_0xd5d7fa=_0xd5d7fa||0xcc;return function(_0x1df77a){if(_0x1df77a){return _0x10cefc[_0xa8b8('0x1c')](_0xd5d7fa);}return _0x10cefc[_0xa8b8('0x1d')](_0xd5d7fa)[_0xa8b8('0x1e')]();};}function respondWithResult(_0x243bd5,_0x265709){_0x265709=_0x265709||0xc8;return function(_0x39efa){if(_0x39efa){return _0x243bd5[_0xa8b8('0x1d')](_0x265709)[_0xa8b8('0x1f')](_0x39efa);}};}function respondWithFilteredResult(_0x135d03,_0x113efd){return function(_0x2fb760){if(_0x2fb760){var _0xd59c85=typeof _0x113efd[_0xa8b8('0x20')]===_0xa8b8('0x21')&&typeof _0x113efd['limit']===_0xa8b8('0x21');var _0x5c9078=_0x2fb760[_0xa8b8('0x22')];var _0x51b355=_0xd59c85?0x0:_0x113efd[_0xa8b8('0x20')];var _0x5b0835=_0xd59c85?_0x2fb760['count']:_0x113efd[_0xa8b8('0x20')]+_0x113efd['limit'];var _0x5d4d49;if(_0x5b0835>=_0x5c9078){_0x5b0835=_0x5c9078;_0x5d4d49=0xc8;}else{_0x5d4d49=0xce;}_0x135d03['status'](_0x5d4d49);return _0x135d03['set']('Content-Range',_0x51b355+'-'+_0x5b0835+'/'+_0x5c9078)[_0xa8b8('0x1f')](_0x2fb760);}return null;};}function patchUpdates(_0x285d62){return function(_0xf7c313){try{jsonpatch[_0xa8b8('0x23')](_0xf7c313,_0x285d62,!![]);}catch(_0x5b6b21){return BPromise[_0xa8b8('0x24')](_0x5b6b21);}return _0xf7c313[_0xa8b8('0x25')]();};}function saveUpdates(_0x3ace92,_0x145eb3){return function(_0x5f42b7){if(_0x5f42b7){return _0x5f42b7[_0xa8b8('0x26')](_0x3ace92)[_0xa8b8('0x27')](function(_0x887436){return _0x887436;});}return null;};}function removeEntity(_0x2590cf,_0x504c71){return function(_0x39ca63){if(_0x39ca63){return _0x39ca63['destroy']()[_0xa8b8('0x27')](function(){var _0x4d0c2e=_0x39ca63['get']({'plain':!![]});var _0x54195e='CannedAnswers';return db['UserProfileResource'][_0xa8b8('0x28')]({'where':{'type':_0x54195e,'resourceId':_0x4d0c2e['id']}})['then'](function(){return _0x39ca63;});})['then'](function(){_0x2590cf[_0xa8b8('0x1d')](0xcc)[_0xa8b8('0x1e')]();});}};}function handleEntityNotFound(_0x3012af,_0x4e5f1d){return function(_0x5619a7){if(!_0x5619a7){_0x3012af['sendStatus'](0x194);}return _0x5619a7;};}function handleError(_0xb25dde,_0x5f1737){_0x5f1737=_0x5f1737||0x1f4;return function(_0x455d4c){logger[_0xa8b8('0x29')](_0x455d4c['stack']);if(_0x455d4c[_0xa8b8('0x2a')]){delete _0x455d4c[_0xa8b8('0x2a')];}_0xb25dde[_0xa8b8('0x1d')](_0x5f1737)[_0xa8b8('0x2b')](_0x455d4c);};}exports[_0xa8b8('0x2c')]=function(_0x18777e,_0x34f402){var _0xe094fe={},_0x2a42b6={},_0x33b171={'count':0x0,'rows':[]};var _0x5eb423=_[_0xa8b8('0x2d')](db[_0xa8b8('0x2e')]['rawAttributes'],function(_0x1e7024){return{'name':_0x1e7024[_0xa8b8('0x2f')],'type':_0x1e7024[_0xa8b8('0x30')][_0xa8b8('0x31')]};});_0x2a42b6[_0xa8b8('0x32')]=_[_0xa8b8('0x2d')](_0x5eb423,_0xa8b8('0x2a'));_0x2a42b6[_0xa8b8('0x33')]=_[_0xa8b8('0x34')](_0x18777e[_0xa8b8('0x33')]);_0x2a42b6[_0xa8b8('0x35')]=_['intersection'](_0x2a42b6[_0xa8b8('0x32')],_0x2a42b6[_0xa8b8('0x33')]);_0xe094fe['attributes']=_['intersection'](_0x2a42b6[_0xa8b8('0x32')],qs[_0xa8b8('0x36')](_0x18777e[_0xa8b8('0x33')][_0xa8b8('0x36')]));_0xe094fe[_0xa8b8('0x37')]=_0xe094fe[_0xa8b8('0x37')]['length']?_0xe094fe[_0xa8b8('0x37')]:_0x2a42b6[_0xa8b8('0x32')];if(!_0x18777e[_0xa8b8('0x33')]['hasOwnProperty'](_0xa8b8('0x38'))){_0xe094fe[_0xa8b8('0x39')]=qs[_0xa8b8('0x39')](_0x18777e[_0xa8b8('0x33')][_0xa8b8('0x39')]);_0xe094fe[_0xa8b8('0x20')]=qs[_0xa8b8('0x20')](_0x18777e[_0xa8b8('0x33')][_0xa8b8('0x20')]);}_0xe094fe[_0xa8b8('0x3a')]=qs[_0xa8b8('0x3b')](_0x18777e[_0xa8b8('0x33')][_0xa8b8('0x3b')]);_0xe094fe[_0xa8b8('0x3c')]=qs[_0xa8b8('0x35')](_['pick'](_0x18777e[_0xa8b8('0x33')],_0x2a42b6['filters']),_0x5eb423);if(_0x18777e[_0xa8b8('0x33')]['filter']){_0xe094fe[_0xa8b8('0x3c')]=_[_0xa8b8('0x3d')](_0xe094fe['where'],{'$or':[{'key':{'$like':'%'+_0x18777e['query'][_0xa8b8('0x3e')]+'%'}},{'value':{'$like':'%'+_0x18777e[_0xa8b8('0x33')][_0xa8b8('0x3e')]+'%'}}]});}_0xe094fe=_[_0xa8b8('0x3d')]({},_0xe094fe,_0x18777e['options']);var _0x281424={'where':_0xe094fe[_0xa8b8('0x3c')]};return db['CannedAnswer'][_0xa8b8('0x22')](_0x281424)['then'](function(_0x412a98){_0x33b171[_0xa8b8('0x22')]=_0x412a98;if(_0x18777e[_0xa8b8('0x33')][_0xa8b8('0x3f')]){_0xe094fe[_0xa8b8('0x40')]=[{'all':!![]}];}return db[_0xa8b8('0x2e')]['findAll'](_0xe094fe);})[_0xa8b8('0x27')](function(_0x5a93d7){_0x33b171[_0xa8b8('0x41')]=_0x5a93d7;return _0x33b171;})[_0xa8b8('0x27')](respondWithFilteredResult(_0x34f402,_0xe094fe))[_0xa8b8('0x42')](handleError(_0x34f402,null));};exports['show']=function(_0x55d6a4,_0x5b95b0){var _0x53d6ef={'raw':!![],'where':{'id':_0x55d6a4[_0xa8b8('0x43')]['id']}},_0x208aa5={};_0x208aa5['model']=_['keys'](db[_0xa8b8('0x2e')]['rawAttributes']);_0x208aa5[_0xa8b8('0x33')]=_[_0xa8b8('0x34')](_0x55d6a4[_0xa8b8('0x33')]);_0x208aa5[_0xa8b8('0x35')]=_[_0xa8b8('0x44')](_0x208aa5[_0xa8b8('0x32')],_0x208aa5[_0xa8b8('0x33')]);_0x53d6ef[_0xa8b8('0x37')]=_[_0xa8b8('0x44')](_0x208aa5[_0xa8b8('0x32')],qs[_0xa8b8('0x36')](_0x55d6a4['query']['fields']));_0x53d6ef['attributes']=_0x53d6ef[_0xa8b8('0x37')]['length']?_0x53d6ef['attributes']:_0x208aa5[_0xa8b8('0x32')];if(_0x55d6a4[_0xa8b8('0x33')][_0xa8b8('0x3f')]){_0x53d6ef['include']=[{'all':!![]}];}_0x53d6ef=_['merge']({},_0x53d6ef,_0x55d6a4[_0xa8b8('0x45')]);return db[_0xa8b8('0x2e')]['find'](_0x53d6ef)[_0xa8b8('0x27')](handleEntityNotFound(_0x5b95b0,null))['then'](respondWithResult(_0x5b95b0,null))[_0xa8b8('0x42')](handleError(_0x5b95b0,null));};exports[_0xa8b8('0x26')]=function(_0x23c5c7,_0x3ed1bc){if(_0x23c5c7[_0xa8b8('0x46')]['id']){delete _0x23c5c7['body']['id'];}return db['CannedAnswer'][_0xa8b8('0x47')]({'where':{'id':_0x23c5c7[_0xa8b8('0x43')]['id']}})[_0xa8b8('0x27')](handleEntityNotFound(_0x3ed1bc,null))[_0xa8b8('0x27')](saveUpdates(_0x23c5c7[_0xa8b8('0x46')],null))[_0xa8b8('0x27')](respondWithResult(_0x3ed1bc,null))[_0xa8b8('0x42')](handleError(_0x3ed1bc,null));};exports['destroy']=function(_0x1c055b,_0x4dc518){return db[_0xa8b8('0x2e')]['find']({'where':{'id':_0x1c055b[_0xa8b8('0x43')]['id']}})[_0xa8b8('0x27')](handleEntityNotFound(_0x4dc518,null))['then'](removeEntity(_0x4dc518,null))[_0xa8b8('0x42')](handleError(_0x4dc518,null));};exports[_0xa8b8('0x48')]=function(_0x1d1c38,_0x47d5a6){var _0x586142={'key':_0x1d1c38[_0xa8b8('0x46')][_0xa8b8('0x31')]};if(_0x1d1c38[_0xa8b8('0x46')][_0xa8b8('0x49')]){_0x586142[_0xa8b8('0x49')]=_0x1d1c38['body'][_0xa8b8('0x49')];}else if(_0x1d1c38[_0xa8b8('0x46')][_0xa8b8('0x4a')]){_0x586142[_0xa8b8('0x4a')]=_0x1d1c38[_0xa8b8('0x46')][_0xa8b8('0x4a')];}else if(_0x1d1c38[_0xa8b8('0x46')][_0xa8b8('0x4b')]){_0x586142[_0xa8b8('0x4b')]=_0x1d1c38['body'][_0xa8b8('0x4b')];}else if(_0x1d1c38[_0xa8b8('0x46')][_0xa8b8('0x4c')]){_0x586142[_0xa8b8('0x4c')]=_0x1d1c38[_0xa8b8('0x46')]['ChatWebsiteId'];}return db[_0xa8b8('0x2e')]['find']({'where':_0x586142})[_0xa8b8('0x27')](function(_0xd14746){if(_0xd14746){throw new db[(_0xa8b8('0x4d'))][(_0xa8b8('0x4e'))](_0xa8b8('0x4f'));}return db[_0xa8b8('0x2e')][_0xa8b8('0x48')](_0x1d1c38[_0xa8b8('0x46')]);})[_0xa8b8('0x27')](function(_0x8295bb){var _0x4bdba4=_0x1d1c38[_0xa8b8('0x50')][_0xa8b8('0x51')]({'plain':!![]});if(!_0x4bdba4)throw new Error(_0xa8b8('0x52'));if(_0x4bdba4[_0xa8b8('0x53')]===_0xa8b8('0x50')){var _0x466896=_0x8295bb[_0xa8b8('0x51')]({'plain':!![]});return db['UserProfileSection']['find']({'where':{'name':'CannedAnswers','userProfileId':_0x4bdba4[_0xa8b8('0x54')]},'raw':!![]})['then'](function(_0x37a3a0){if(_0x37a3a0&&_0x37a3a0[_0xa8b8('0x55')]===0x0){return db[_0xa8b8('0x56')][_0xa8b8('0x48')]({'name':_0x466896['name'],'resourceId':_0x466896['id'],'type':_0x37a3a0[_0xa8b8('0x2a')],'sectionId':_0x37a3a0['id']},{})[_0xa8b8('0x27')](function(){return _0x8295bb;});}else{return _0x8295bb;}})[_0xa8b8('0x42')](function(_0x3aae43){logger[_0xa8b8('0x29')](_0xa8b8('0x57'),_0x3aae43);throw _0x3aae43;});}return _0x8295bb;})[_0xa8b8('0x27')](respondWithResult(_0x47d5a6,0xc9))[_0xa8b8('0x42')](handleError(_0x47d5a6,null));};
\ No newline at end of file