Built motion from commit 0900f080.|2.5.45
[motion2.git] / server / api / cannedAnswer / cannedAnswer.controller.js
index f65e055..a4c6faa 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xafdc=['catch','params','includeAll','options','find','body','create','MailAccountId','SmsAccountId','OpenchannelAccountId','ChatWebsiteId','ValidationError','The\x20inserted\x20key\x20already\x20exists.','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','UserProfileSection','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','html-pdf','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','sox','to-csv','lodash','squel','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','status','end','json','count','offset','apply','save','update','then','destroy','get','CannedAnswers','UserProfileResource','sendStatus','error','name','send','index','CannedAnswer','rawAttributes','fieldName','type','key','map','keys','query','filters','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','limit','order','sort','where','filter','merge','VIRTUAL','include','rows'];(function(_0x11dcd1,_0x2fa52d){var _0x45e886=function(_0x2a0ca8){while(--_0x2a0ca8){_0x11dcd1['push'](_0x11dcd1['shift']());}};_0x45e886(++_0x2fa52d);}(_0xafdc,0x10e));var _0xcafd=function(_0x168733,_0x3876a5){_0x168733=_0x168733-0x0;var _0x3db02c=_0xafdc[_0x168733];return _0x3db02c;};'use strict';var pdf=require(_0xcafd('0x0'));var emlformat=require(_0xcafd('0x1'));var rimraf=require(_0xcafd('0x2'));var zipdir=require('zip-dir');var jsonpatch=require(_0xcafd('0x3'));var rp=require(_0xcafd('0x4'));var moment=require(_0xcafd('0x5'));var BPromise=require(_0xcafd('0x6'));var Mustache=require(_0xcafd('0x7'));var util=require('util');var path=require('path');var sox=require(_0xcafd('0x8'));var csv=require(_0xcafd('0x9'));var ejs=require('ejs');var fs=require('fs');var _=require(_0xcafd('0xa'));var squel=require(_0xcafd('0xb'));var crypto=require('crypto');var jsforce=require(_0xcafd('0xc'));var deskjs=require(_0xcafd('0xd'));var toCsv=require(_0xcafd('0x9'));var querystring=require(_0xcafd('0xe'));var Papa=require('papaparse');var Redis=require(_0xcafd('0xf'));var authService=require(_0xcafd('0x10'));var qs=require(_0xcafd('0x11'));var as=require(_0xcafd('0x12'));var hardwareService=require(_0xcafd('0x13'));var logger=require(_0xcafd('0x14'))('api');var utils=require(_0xcafd('0x15'));var config=require(_0xcafd('0x16'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x2dd8cc,_0x9a3208){_0x9a3208=_0x9a3208||0xcc;return function(_0x19e41e){if(_0x19e41e){return _0x2dd8cc['sendStatus'](_0x9a3208);}return _0x2dd8cc[_0xcafd('0x17')](_0x9a3208)[_0xcafd('0x18')]();};}function respondWithResult(_0x1e5a48,_0x263c87){_0x263c87=_0x263c87||0xc8;return function(_0x343e41){if(_0x343e41){return _0x1e5a48[_0xcafd('0x17')](_0x263c87)[_0xcafd('0x19')](_0x343e41);}};}function respondWithFilteredResult(_0x154236,_0x10a946){return function(_0x47719b){if(_0x47719b){var _0x54e7a8=_0x47719b[_0xcafd('0x1a')],_0x40f40f=_0x10a946[_0xcafd('0x1b')],_0x163fa7=_0x10a946[_0xcafd('0x1b')]+_0x10a946['limit'],_0x2bcee7;if(_0x163fa7>=_0x54e7a8){_0x163fa7=_0x54e7a8;_0x2bcee7=0xc8;}else{_0x2bcee7=0xce;}_0x154236[_0xcafd('0x17')](_0x2bcee7);return _0x154236['set']('Content-Range',_0x40f40f+'-'+_0x163fa7+'/'+_0x54e7a8)['json'](_0x47719b);}return null;};}function patchUpdates(_0x51b834){return function(_0x492159){try{jsonpatch[_0xcafd('0x1c')](_0x492159,_0x51b834,!![]);}catch(_0x3889bc){return BPromise['reject'](_0x3889bc);}return _0x492159[_0xcafd('0x1d')]();};}function saveUpdates(_0x43d2ef,_0x2443bb){return function(_0x259fe7){if(_0x259fe7){return _0x259fe7[_0xcafd('0x1e')](_0x43d2ef)[_0xcafd('0x1f')](function(_0x2d2c00){return _0x2d2c00;});}return null;};}function removeEntity(_0x5ef042,_0x3044d4){return function(_0x3d38b9){if(_0x3d38b9){return _0x3d38b9[_0xcafd('0x20')]()[_0xcafd('0x1f')](function(){var _0x9e1c1=_0x3d38b9[_0xcafd('0x21')]({'plain':!![]});var _0x51e93c=_0xcafd('0x22');return db[_0xcafd('0x23')][_0xcafd('0x20')]({'where':{'type':_0x51e93c,'resourceId':_0x9e1c1['id']}})['then'](function(){return _0x3d38b9;});})[_0xcafd('0x1f')](function(){_0x5ef042[_0xcafd('0x17')](0xcc)['end']();});}};}function handleEntityNotFound(_0x290fed,_0x24606d){return function(_0xd9007e){if(!_0xd9007e){_0x290fed[_0xcafd('0x24')](0x194);}return _0xd9007e;};}function handleError(_0x1de5de,_0x4f4b97){_0x4f4b97=_0x4f4b97||0x1f4;return function(_0x3b8798){logger[_0xcafd('0x25')](_0x3b8798['stack']);if(_0x3b8798[_0xcafd('0x26')]){delete _0x3b8798[_0xcafd('0x26')];}_0x1de5de[_0xcafd('0x17')](_0x4f4b97)[_0xcafd('0x27')](_0x3b8798);};}exports[_0xcafd('0x28')]=function(_0x33b7cb,_0x7814ac){var _0x2b5da7={},_0x40e24f={},_0x5895a5={'count':0x0,'rows':[]};var _0x549761=_['map'](db[_0xcafd('0x29')][_0xcafd('0x2a')],function(_0x36cb28){return{'name':_0x36cb28[_0xcafd('0x2b')],'type':_0x36cb28[_0xcafd('0x2c')][_0xcafd('0x2d')]};});_0x40e24f['model']=_[_0xcafd('0x2e')](_0x549761,_0xcafd('0x26'));_0x40e24f['query']=_[_0xcafd('0x2f')](_0x33b7cb[_0xcafd('0x30')]);_0x40e24f[_0xcafd('0x31')]=_[_0xcafd('0x32')](_0x40e24f[_0xcafd('0x33')],_0x40e24f[_0xcafd('0x30')]);_0x2b5da7[_0xcafd('0x34')]=_[_0xcafd('0x32')](_0x40e24f[_0xcafd('0x33')],qs['fields'](_0x33b7cb[_0xcafd('0x30')][_0xcafd('0x35')]));_0x2b5da7[_0xcafd('0x34')]=_0x2b5da7[_0xcafd('0x34')][_0xcafd('0x36')]?_0x2b5da7[_0xcafd('0x34')]:_0x40e24f[_0xcafd('0x33')];if(!_0x33b7cb[_0xcafd('0x30')][_0xcafd('0x37')](_0xcafd('0x38'))){_0x2b5da7[_0xcafd('0x39')]=qs[_0xcafd('0x39')](_0x33b7cb[_0xcafd('0x30')][_0xcafd('0x39')]);_0x2b5da7[_0xcafd('0x1b')]=qs[_0xcafd('0x1b')](_0x33b7cb[_0xcafd('0x30')]['offset']);}_0x2b5da7[_0xcafd('0x3a')]=qs[_0xcafd('0x3b')](_0x33b7cb[_0xcafd('0x30')][_0xcafd('0x3b')]);_0x2b5da7[_0xcafd('0x3c')]=qs[_0xcafd('0x31')](_['pick'](_0x33b7cb[_0xcafd('0x30')],_0x40e24f[_0xcafd('0x31')]),_0x549761);if(_0x33b7cb['query'][_0xcafd('0x3d')]){_0x2b5da7[_0xcafd('0x3c')]=_[_0xcafd('0x3e')](_0x2b5da7[_0xcafd('0x3c')],{'$or':_['map'](_0x549761,function(_0x285370){if(_0x285370[_0xcafd('0x2c')]!==_0xcafd('0x3f')){var _0x163182={};_0x163182[_0x285370[_0xcafd('0x26')]]={'$like':'%'+_0x33b7cb[_0xcafd('0x30')][_0xcafd('0x3d')]+'%'};return _0x163182;}})});}_0x2b5da7=_[_0xcafd('0x3e')]({},_0x2b5da7,_0x33b7cb['options']);var _0x334153={'where':_0x2b5da7[_0xcafd('0x3c')]};return db[_0xcafd('0x29')]['count'](_0x334153)[_0xcafd('0x1f')](function(_0x377ba0){_0x5895a5[_0xcafd('0x1a')]=_0x377ba0;if(_0x33b7cb[_0xcafd('0x30')]['includeAll']){_0x2b5da7[_0xcafd('0x40')]=[{'all':!![]}];}return db[_0xcafd('0x29')]['findAll'](_0x2b5da7);})[_0xcafd('0x1f')](function(_0x3d1f24){_0x5895a5[_0xcafd('0x41')]=_0x3d1f24;return _0x5895a5;})[_0xcafd('0x1f')](respondWithFilteredResult(_0x7814ac,_0x2b5da7))[_0xcafd('0x42')](handleError(_0x7814ac,null));};exports['show']=function(_0x177e89,_0x352b2e){var _0x49a2b4={'raw':!![],'where':{'id':_0x177e89[_0xcafd('0x43')]['id']}},_0x147ddc={};_0x147ddc[_0xcafd('0x33')]=_[_0xcafd('0x2f')](db[_0xcafd('0x29')][_0xcafd('0x2a')]);_0x147ddc[_0xcafd('0x30')]=_['keys'](_0x177e89[_0xcafd('0x30')]);_0x147ddc[_0xcafd('0x31')]=_['intersection'](_0x147ddc[_0xcafd('0x33')],_0x147ddc[_0xcafd('0x30')]);_0x49a2b4[_0xcafd('0x34')]=_[_0xcafd('0x32')](_0x147ddc['model'],qs[_0xcafd('0x35')](_0x177e89[_0xcafd('0x30')][_0xcafd('0x35')]));_0x49a2b4['attributes']=_0x49a2b4['attributes'][_0xcafd('0x36')]?_0x49a2b4[_0xcafd('0x34')]:_0x147ddc['model'];if(_0x177e89[_0xcafd('0x30')][_0xcafd('0x44')]){_0x49a2b4['include']=[{'all':!![]}];}_0x49a2b4=_[_0xcafd('0x3e')]({},_0x49a2b4,_0x177e89[_0xcafd('0x45')]);return db[_0xcafd('0x29')][_0xcafd('0x46')](_0x49a2b4)[_0xcafd('0x1f')](handleEntityNotFound(_0x352b2e,null))[_0xcafd('0x1f')](respondWithResult(_0x352b2e,null))[_0xcafd('0x42')](handleError(_0x352b2e,null));};exports[_0xcafd('0x1e')]=function(_0x238fd2,_0x24b173){if(_0x238fd2[_0xcafd('0x47')]['id']){delete _0x238fd2[_0xcafd('0x47')]['id'];}return db['CannedAnswer']['find']({'where':{'id':_0x238fd2['params']['id']}})['then'](handleEntityNotFound(_0x24b173,null))[_0xcafd('0x1f')](saveUpdates(_0x238fd2[_0xcafd('0x47')],null))[_0xcafd('0x1f')](respondWithResult(_0x24b173,null))[_0xcafd('0x42')](handleError(_0x24b173,null));};exports[_0xcafd('0x20')]=function(_0x2edd10,_0x1dc1b2){return db[_0xcafd('0x29')][_0xcafd('0x46')]({'where':{'id':_0x2edd10['params']['id']}})['then'](handleEntityNotFound(_0x1dc1b2,null))[_0xcafd('0x1f')](removeEntity(_0x1dc1b2,null))[_0xcafd('0x42')](handleError(_0x1dc1b2,null));};exports[_0xcafd('0x48')]=function(_0x3a0ff9,_0x419e18){var _0x1d5834={'key':_0x3a0ff9[_0xcafd('0x47')][_0xcafd('0x2d')]};if(_0x3a0ff9[_0xcafd('0x47')]['MailAccountId']){_0x1d5834[_0xcafd('0x49')]=_0x3a0ff9['body'][_0xcafd('0x49')];}else if(_0x3a0ff9['body'][_0xcafd('0x4a')]){_0x1d5834[_0xcafd('0x4a')]=_0x3a0ff9[_0xcafd('0x47')][_0xcafd('0x4a')];}else if(_0x3a0ff9[_0xcafd('0x47')][_0xcafd('0x4b')]){_0x1d5834[_0xcafd('0x4b')]=_0x3a0ff9[_0xcafd('0x47')][_0xcafd('0x4b')];}else if(_0x3a0ff9[_0xcafd('0x47')]['ChatWebsiteId']){_0x1d5834[_0xcafd('0x4c')]=_0x3a0ff9[_0xcafd('0x47')][_0xcafd('0x4c')];}return db[_0xcafd('0x29')][_0xcafd('0x46')]({'where':_0x1d5834})[_0xcafd('0x1f')](function(_0x1b362a){if(_0x1b362a){throw new db['Sequelize'][(_0xcafd('0x4d'))](_0xcafd('0x4e'));}return db[_0xcafd('0x29')][_0xcafd('0x48')](_0x3a0ff9['body']);})[_0xcafd('0x1f')](function(_0x36563f){var _0x404b7e=_0x3a0ff9['user']['get']({'plain':!![]});if(!_0x404b7e)throw new Error(_0xcafd('0x4f'));if(_0x404b7e[_0xcafd('0x50')]===_0xcafd('0x51')){var _0xb54836=_0x36563f[_0xcafd('0x21')]({'plain':!![]});return db[_0xcafd('0x52')]['find']({'where':{'name':_0xcafd('0x22'),'userProfileId':_0x404b7e['userProfileId']},'raw':!![]})[_0xcafd('0x1f')](function(_0x4f066d){if(_0x4f066d&&_0x4f066d['autoAssociation']===0x0){return db[_0xcafd('0x23')][_0xcafd('0x48')]({'name':_0xb54836[_0xcafd('0x26')],'resourceId':_0xb54836['id'],'type':_0x4f066d[_0xcafd('0x26')],'sectionId':_0x4f066d['id']},{})[_0xcafd('0x1f')](function(){return _0x36563f;});}else{return _0x36563f;}})[_0xcafd('0x42')](function(_0x1373bd){logger[_0xcafd('0x25')](_0xcafd('0x53'),_0x1373bd);throw _0x1373bd;});}return _0x36563f;})['then'](respondWithResult(_0x419e18,0xc9))[_0xcafd('0x42')](handleError(_0x419e18,null));};
\ No newline at end of file
+var _0x77f8=['fs-extra','crypto','jsforce','desk.js','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','status','end','json','offset','undefined','count','limit','set','Content-Range','apply','save','update','get','destroy','then','sendStatus','error','stack','name','send','index','map','CannedAnswer','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','where','pick','filter','merge','includeAll','findAll','rows','catch','show','params','include','options','find','body','MailAccountId','SmsAccountId','OpenchannelAccountId','ChatWebsiteId','Sequelize','ValidationError','The\x20inserted\x20key\x20already\x20exists.','create','user','CannedAnswers','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','path','sox','to-csv'];(function(_0x1ef8f6,_0x18a001){var _0x49bd57=function(_0x5b60c8){while(--_0x5b60c8){_0x1ef8f6['push'](_0x1ef8f6['shift']());}};_0x49bd57(++_0x18a001);}(_0x77f8,0x15a));var _0x877f=function(_0x422905,_0x3bce3a){_0x422905=_0x422905-0x0;var _0x33dc6c=_0x77f8[_0x422905];return _0x33dc6c;};'use strict';var emlformat=require(_0x877f('0x0'));var rimraf=require(_0x877f('0x1'));var zipdir=require(_0x877f('0x2'));var jsonpatch=require(_0x877f('0x3'));var rp=require(_0x877f('0x4'));var moment=require('moment');var BPromise=require(_0x877f('0x5'));var Mustache=require(_0x877f('0x6'));var util=require('util');var path=require(_0x877f('0x7'));var sox=require(_0x877f('0x8'));var csv=require(_0x877f('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x877f('0xa'));var _=require('lodash');var squel=require('squel');var crypto=require(_0x877f('0xb'));var jsforce=require(_0x877f('0xc'));var deskjs=require(_0x877f('0xd'));var toCsv=require(_0x877f('0x9'));var querystring=require('querystring');var Papa=require(_0x877f('0xe'));var Redis=require('ioredis');var authService=require(_0x877f('0xf'));var qs=require(_0x877f('0x10'));var as=require(_0x877f('0x11'));var hardwareService=require(_0x877f('0x12'));var logger=require(_0x877f('0x13'))('api');var utils=require(_0x877f('0x14'));var config=require(_0x877f('0x15'));var licenseUtil=require(_0x877f('0x16'));var db=require(_0x877f('0x17'))['db'];function respondWithStatusCode(_0x2999e6,_0x2f2259){_0x2f2259=_0x2f2259||0xcc;return function(_0x584534){if(_0x584534){return _0x2999e6['sendStatus'](_0x2f2259);}return _0x2999e6[_0x877f('0x18')](_0x2f2259)[_0x877f('0x19')]();};}function respondWithResult(_0xb4758,_0x2b0a06){_0x2b0a06=_0x2b0a06||0xc8;return function(_0x23fdd5){if(_0x23fdd5){return _0xb4758['status'](_0x2b0a06)[_0x877f('0x1a')](_0x23fdd5);}};}function respondWithFilteredResult(_0x13c42b,_0xd72997){return function(_0x5ec749){if(_0x5ec749){var _0x5660a8=typeof _0xd72997[_0x877f('0x1b')]===_0x877f('0x1c')&&typeof _0xd72997['limit']===_0x877f('0x1c');var _0x365b44=_0x5ec749[_0x877f('0x1d')];var _0xe17b6c=_0x5660a8?0x0:_0xd72997[_0x877f('0x1b')];var _0x3529ee=_0x5660a8?_0x5ec749[_0x877f('0x1d')]:_0xd72997['offset']+_0xd72997[_0x877f('0x1e')];var _0x49fce5;if(_0x3529ee>=_0x365b44){_0x3529ee=_0x365b44;_0x49fce5=0xc8;}else{_0x49fce5=0xce;}_0x13c42b[_0x877f('0x18')](_0x49fce5);return _0x13c42b[_0x877f('0x1f')](_0x877f('0x20'),_0xe17b6c+'-'+_0x3529ee+'/'+_0x365b44)['json'](_0x5ec749);}return null;};}function patchUpdates(_0x188576){return function(_0x2409d6){try{jsonpatch[_0x877f('0x21')](_0x2409d6,_0x188576,!![]);}catch(_0x508c9d){return BPromise['reject'](_0x508c9d);}return _0x2409d6[_0x877f('0x22')]();};}function saveUpdates(_0x3d78ef,_0x3ae7be){return function(_0xeb87fd){if(_0xeb87fd){return _0xeb87fd[_0x877f('0x23')](_0x3d78ef)['then'](function(_0x3c5a3a){return _0x3c5a3a;});}return null;};}function removeEntity(_0x2de1bc,_0x2a9f34){return function(_0x176aae){if(_0x176aae){return _0x176aae['destroy']()['then'](function(){var _0x42fa31=_0x176aae[_0x877f('0x24')]({'plain':!![]});var _0x1732da='CannedAnswers';return db['UserProfileResource'][_0x877f('0x25')]({'where':{'type':_0x1732da,'resourceId':_0x42fa31['id']}})[_0x877f('0x26')](function(){return _0x176aae;});})[_0x877f('0x26')](function(){_0x2de1bc['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x54a309,_0x465bb9){return function(_0x3de8de){if(!_0x3de8de){_0x54a309[_0x877f('0x27')](0x194);}return _0x3de8de;};}function handleError(_0x36a6ad,_0x1f0acc){_0x1f0acc=_0x1f0acc||0x1f4;return function(_0x267f81){logger[_0x877f('0x28')](_0x267f81[_0x877f('0x29')]);if(_0x267f81[_0x877f('0x2a')]){delete _0x267f81[_0x877f('0x2a')];}_0x36a6ad['status'](_0x1f0acc)[_0x877f('0x2b')](_0x267f81);};}exports[_0x877f('0x2c')]=function(_0x44c439,_0x38ee14){var _0x39390c={},_0x556df0={},_0x2a4bc7={'count':0x0,'rows':[]};var _0x349670=_[_0x877f('0x2d')](db[_0x877f('0x2e')][_0x877f('0x2f')],function(_0x180a3a){return{'name':_0x180a3a[_0x877f('0x30')],'type':_0x180a3a[_0x877f('0x31')][_0x877f('0x32')]};});_0x556df0[_0x877f('0x33')]=_['map'](_0x349670,_0x877f('0x2a'));_0x556df0[_0x877f('0x34')]=_[_0x877f('0x35')](_0x44c439[_0x877f('0x34')]);_0x556df0[_0x877f('0x36')]=_[_0x877f('0x37')](_0x556df0[_0x877f('0x33')],_0x556df0[_0x877f('0x34')]);_0x39390c[_0x877f('0x38')]=_[_0x877f('0x37')](_0x556df0[_0x877f('0x33')],qs[_0x877f('0x39')](_0x44c439[_0x877f('0x34')]['fields']));_0x39390c[_0x877f('0x38')]=_0x39390c[_0x877f('0x38')][_0x877f('0x3a')]?_0x39390c[_0x877f('0x38')]:_0x556df0[_0x877f('0x33')];if(!_0x44c439[_0x877f('0x34')][_0x877f('0x3b')]('nolimit')){_0x39390c['limit']=qs[_0x877f('0x1e')](_0x44c439[_0x877f('0x34')][_0x877f('0x1e')]);_0x39390c[_0x877f('0x1b')]=qs[_0x877f('0x1b')](_0x44c439[_0x877f('0x34')][_0x877f('0x1b')]);}_0x39390c[_0x877f('0x3c')]=qs['sort'](_0x44c439['query'][_0x877f('0x3d')]);_0x39390c[_0x877f('0x3e')]=qs[_0x877f('0x36')](_[_0x877f('0x3f')](_0x44c439[_0x877f('0x34')],_0x556df0['filters']),_0x349670);if(_0x44c439['query'][_0x877f('0x40')]){_0x39390c['where']=_[_0x877f('0x41')](_0x39390c[_0x877f('0x3e')],{'$or':[{'key':{'$like':'%'+_0x44c439[_0x877f('0x34')][_0x877f('0x40')]+'%'}},{'value':{'$like':'%'+_0x44c439['query']['filter']+'%'}}]});}_0x39390c=_['merge']({},_0x39390c,_0x44c439['options']);var _0x16fc1c={'where':_0x39390c[_0x877f('0x3e')]};return db[_0x877f('0x2e')][_0x877f('0x1d')](_0x16fc1c)[_0x877f('0x26')](function(_0x10384c){_0x2a4bc7[_0x877f('0x1d')]=_0x10384c;if(_0x44c439[_0x877f('0x34')][_0x877f('0x42')]){_0x39390c['include']=[{'all':!![]}];}return db[_0x877f('0x2e')][_0x877f('0x43')](_0x39390c);})[_0x877f('0x26')](function(_0x1f7779){_0x2a4bc7[_0x877f('0x44')]=_0x1f7779;return _0x2a4bc7;})[_0x877f('0x26')](respondWithFilteredResult(_0x38ee14,_0x39390c))[_0x877f('0x45')](handleError(_0x38ee14,null));};exports[_0x877f('0x46')]=function(_0x56dfd9,_0xf5cef5){var _0x4eb87e={'raw':!![],'where':{'id':_0x56dfd9[_0x877f('0x47')]['id']}},_0x5025fd={};_0x5025fd[_0x877f('0x33')]=_[_0x877f('0x35')](db[_0x877f('0x2e')][_0x877f('0x2f')]);_0x5025fd[_0x877f('0x34')]=_[_0x877f('0x35')](_0x56dfd9['query']);_0x5025fd[_0x877f('0x36')]=_[_0x877f('0x37')](_0x5025fd[_0x877f('0x33')],_0x5025fd['query']);_0x4eb87e[_0x877f('0x38')]=_[_0x877f('0x37')](_0x5025fd[_0x877f('0x33')],qs['fields'](_0x56dfd9['query'][_0x877f('0x39')]));_0x4eb87e[_0x877f('0x38')]=_0x4eb87e[_0x877f('0x38')]['length']?_0x4eb87e['attributes']:_0x5025fd[_0x877f('0x33')];if(_0x56dfd9[_0x877f('0x34')][_0x877f('0x42')]){_0x4eb87e[_0x877f('0x48')]=[{'all':!![]}];}_0x4eb87e=_['merge']({},_0x4eb87e,_0x56dfd9[_0x877f('0x49')]);return db[_0x877f('0x2e')][_0x877f('0x4a')](_0x4eb87e)[_0x877f('0x26')](handleEntityNotFound(_0xf5cef5,null))[_0x877f('0x26')](respondWithResult(_0xf5cef5,null))[_0x877f('0x45')](handleError(_0xf5cef5,null));};exports[_0x877f('0x23')]=function(_0x8fd1fe,_0xd435bd){if(_0x8fd1fe[_0x877f('0x4b')]['id']){delete _0x8fd1fe[_0x877f('0x4b')]['id'];}return db['CannedAnswer'][_0x877f('0x4a')]({'where':{'id':_0x8fd1fe[_0x877f('0x47')]['id']}})[_0x877f('0x26')](handleEntityNotFound(_0xd435bd,null))[_0x877f('0x26')](saveUpdates(_0x8fd1fe[_0x877f('0x4b')],null))[_0x877f('0x26')](respondWithResult(_0xd435bd,null))[_0x877f('0x45')](handleError(_0xd435bd,null));};exports[_0x877f('0x25')]=function(_0x17d489,_0x5aca61){return db[_0x877f('0x2e')]['find']({'where':{'id':_0x17d489[_0x877f('0x47')]['id']}})['then'](handleEntityNotFound(_0x5aca61,null))[_0x877f('0x26')](removeEntity(_0x5aca61,null))[_0x877f('0x45')](handleError(_0x5aca61,null));};exports['create']=function(_0x22ed17,_0x3ff2e6){var _0xe00906={'key':_0x22ed17[_0x877f('0x4b')][_0x877f('0x32')]};if(_0x22ed17[_0x877f('0x4b')][_0x877f('0x4c')]){_0xe00906['MailAccountId']=_0x22ed17['body'][_0x877f('0x4c')];}else if(_0x22ed17[_0x877f('0x4b')]['SmsAccountId']){_0xe00906['SmsAccountId']=_0x22ed17[_0x877f('0x4b')][_0x877f('0x4d')];}else if(_0x22ed17[_0x877f('0x4b')][_0x877f('0x4e')]){_0xe00906[_0x877f('0x4e')]=_0x22ed17[_0x877f('0x4b')][_0x877f('0x4e')];}else if(_0x22ed17['body'][_0x877f('0x4f')]){_0xe00906[_0x877f('0x4f')]=_0x22ed17[_0x877f('0x4b')]['ChatWebsiteId'];}return db[_0x877f('0x2e')]['find']({'where':_0xe00906})[_0x877f('0x26')](function(_0x3bcc2f){if(_0x3bcc2f){throw new db[(_0x877f('0x50'))][(_0x877f('0x51'))](_0x877f('0x52'));}return db[_0x877f('0x2e')][_0x877f('0x53')](_0x22ed17[_0x877f('0x4b')]);})[_0x877f('0x26')](function(_0x18ab2e){var _0x20a1ef=_0x22ed17[_0x877f('0x54')][_0x877f('0x24')]({'plain':!![]});if(!_0x20a1ef)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x20a1ef['role']===_0x877f('0x54')){var _0x44cee8=_0x18ab2e['get']({'plain':!![]});return db['UserProfileSection'][_0x877f('0x4a')]({'where':{'name':_0x877f('0x55'),'userProfileId':_0x20a1ef['userProfileId']},'raw':!![]})[_0x877f('0x26')](function(_0x2e2432){if(_0x2e2432&&_0x2e2432[_0x877f('0x56')]===0x0){return db[_0x877f('0x57')][_0x877f('0x53')]({'name':_0x44cee8[_0x877f('0x2a')],'resourceId':_0x44cee8['id'],'type':_0x2e2432[_0x877f('0x2a')],'sectionId':_0x2e2432['id']},{})[_0x877f('0x26')](function(){return _0x18ab2e;});}else{return _0x18ab2e;}})['catch'](function(_0x4d35ed){logger['error'](_0x877f('0x58'),_0x4d35ed);throw _0x4d35ed;});}return _0x18ab2e;})[_0x877f('0x26')](respondWithResult(_0x3ff2e6,0xc9))[_0x877f('0x45')](handleError(_0x3ff2e6,null));};
\ No newline at end of file