Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / cannedAnswer / cannedAnswer.controller.js
index 50d62bf..c426712 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x971d=['ChatWebsiteId','Sequelize','ValidationError','The\x20inserted\x20key\x20already\x20exists.','user','get','role','UserProfileSection','CannedAnswers','userProfileId','autoAssociation','UserProfileResource','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','eml-format','rimraf','zip-dir','request-promise','bluebird','mustache','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../config/license/hardware','../../config/license/util','sendStatus','end','json','undefined','limit','count','offset','status','set','Content-Range','reject','save','update','then','destroy','stack','name','send','index','map','CannedAnswer','fieldName','key','query','intersection','model','fields','attributes','length','hasOwnProperty','nolimit','sort','where','filters','pick','filter','merge','options','include','findAll','catch','show','params','keys','rawAttributes','find','body','create','MailAccountId','SmsAccountId','OpenchannelAccountId'];(function(_0x24061a,_0x1c9f4d){var _0x82054e=function(_0x2ec346){while(--_0x2ec346){_0x24061a['push'](_0x24061a['shift']());}};_0x82054e(++_0x1c9f4d);}(_0x971d,0x110));var _0xd971=function(_0x3435e7,_0xf8e628){_0x3435e7=_0x3435e7-0x0;var _0x26cdd7=_0x971d[_0x3435e7];return _0x26cdd7;};'use strict';var emlformat=require(_0xd971('0x0'));var rimraf=require(_0xd971('0x1'));var zipdir=require(_0xd971('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xd971('0x3'));var moment=require('moment');var BPromise=require(_0xd971('0x4'));var Mustache=require(_0xd971('0x5'));var util=require('util');var path=require('path');var sox=require(_0xd971('0x6'));var csv=require(_0xd971('0x7'));var ejs=require(_0xd971('0x8'));var fs=require('fs');var fs_extra=require(_0xd971('0x9'));var _=require(_0xd971('0xa'));var squel=require(_0xd971('0xb'));var crypto=require(_0xd971('0xc'));var jsforce=require(_0xd971('0xd'));var deskjs=require(_0xd971('0xe'));var toCsv=require(_0xd971('0x7'));var querystring=require(_0xd971('0xf'));var Papa=require(_0xd971('0x10'));var Redis=require(_0xd971('0x11'));var authService=require(_0xd971('0x12'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xd971('0x13'));var logger=require('../../config/logger')('api');var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0xd971('0x14'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x2c6492,_0x4daa64){_0x4daa64=_0x4daa64||0xcc;return function(_0x537178){if(_0x537178){return _0x2c6492[_0xd971('0x15')](_0x4daa64);}return _0x2c6492['status'](_0x4daa64)[_0xd971('0x16')]();};}function respondWithResult(_0x4fbaaa,_0x31387a){_0x31387a=_0x31387a||0xc8;return function(_0x3ef19f){if(_0x3ef19f){return _0x4fbaaa['status'](_0x31387a)[_0xd971('0x17')](_0x3ef19f);}};}function respondWithFilteredResult(_0x5bfa18,_0x18658e){return function(_0x3977d4){if(_0x3977d4){var _0x13df11=typeof _0x18658e['offset']===_0xd971('0x18')&&typeof _0x18658e[_0xd971('0x19')]===_0xd971('0x18');var _0x308f65=_0x3977d4[_0xd971('0x1a')];var _0x1e70b7=_0x13df11?0x0:_0x18658e[_0xd971('0x1b')];var _0x1fba0c=_0x13df11?_0x3977d4[_0xd971('0x1a')]:_0x18658e[_0xd971('0x1b')]+_0x18658e[_0xd971('0x19')];var _0x3d6477;if(_0x1fba0c>=_0x308f65){_0x1fba0c=_0x308f65;_0x3d6477=0xc8;}else{_0x3d6477=0xce;}_0x5bfa18[_0xd971('0x1c')](_0x3d6477);return _0x5bfa18[_0xd971('0x1d')](_0xd971('0x1e'),_0x1e70b7+'-'+_0x1fba0c+'/'+_0x308f65)[_0xd971('0x17')](_0x3977d4);}return null;};}function patchUpdates(_0x2a1aef){return function(_0x540c5f){try{jsonpatch['apply'](_0x540c5f,_0x2a1aef,!![]);}catch(_0x5aa8cd){return BPromise[_0xd971('0x1f')](_0x5aa8cd);}return _0x540c5f[_0xd971('0x20')]();};}function saveUpdates(_0x5589a8,_0x1396ea){return function(_0x32f96a){if(_0x32f96a){return _0x32f96a[_0xd971('0x21')](_0x5589a8)[_0xd971('0x22')](function(_0x511be0){return _0x511be0;});}return null;};}function removeEntity(_0x152461,_0x2e017c){return function(_0x2e7212){if(_0x2e7212){return _0x2e7212[_0xd971('0x23')]()[_0xd971('0x22')](function(){var _0x176b9c=_0x2e7212['get']({'plain':!![]});var _0x19abf1='CannedAnswers';return db['UserProfileResource'][_0xd971('0x23')]({'where':{'type':_0x19abf1,'resourceId':_0x176b9c['id']}})[_0xd971('0x22')](function(){return _0x2e7212;});})[_0xd971('0x22')](function(){_0x152461[_0xd971('0x1c')](0xcc)[_0xd971('0x16')]();});}};}function handleEntityNotFound(_0x1f23c2,_0x3e3989){return function(_0x280f48){if(!_0x280f48){_0x1f23c2[_0xd971('0x15')](0x194);}return _0x280f48;};}function handleError(_0x55d736,_0xf07e13){_0xf07e13=_0xf07e13||0x1f4;return function(_0x29b5c5){logger['error'](_0x29b5c5[_0xd971('0x24')]);if(_0x29b5c5[_0xd971('0x25')]){delete _0x29b5c5[_0xd971('0x25')];}_0x55d736[_0xd971('0x1c')](_0xf07e13)[_0xd971('0x26')](_0x29b5c5);};}exports[_0xd971('0x27')]=function(_0x9e177,_0x4f9bf7){var _0x178969={},_0xd7cf20={},_0xdc9164={'count':0x0,'rows':[]};var _0x1c16af=_[_0xd971('0x28')](db[_0xd971('0x29')]['rawAttributes'],function(_0xecf43){return{'name':_0xecf43[_0xd971('0x2a')],'type':_0xecf43['type'][_0xd971('0x2b')]};});_0xd7cf20['model']=_['map'](_0x1c16af,_0xd971('0x25'));_0xd7cf20[_0xd971('0x2c')]=_['keys'](_0x9e177[_0xd971('0x2c')]);_0xd7cf20['filters']=_[_0xd971('0x2d')](_0xd7cf20['model'],_0xd7cf20[_0xd971('0x2c')]);_0x178969['attributes']=_['intersection'](_0xd7cf20[_0xd971('0x2e')],qs['fields'](_0x9e177[_0xd971('0x2c')][_0xd971('0x2f')]));_0x178969[_0xd971('0x30')]=_0x178969['attributes'][_0xd971('0x31')]?_0x178969[_0xd971('0x30')]:_0xd7cf20['model'];if(!_0x9e177[_0xd971('0x2c')][_0xd971('0x32')](_0xd971('0x33'))){_0x178969[_0xd971('0x19')]=qs[_0xd971('0x19')](_0x9e177[_0xd971('0x2c')][_0xd971('0x19')]);_0x178969['offset']=qs[_0xd971('0x1b')](_0x9e177[_0xd971('0x2c')][_0xd971('0x1b')]);}_0x178969['order']=qs[_0xd971('0x34')](_0x9e177[_0xd971('0x2c')][_0xd971('0x34')]);_0x178969[_0xd971('0x35')]=qs[_0xd971('0x36')](_[_0xd971('0x37')](_0x9e177[_0xd971('0x2c')],_0xd7cf20[_0xd971('0x36')]),_0x1c16af);if(_0x9e177[_0xd971('0x2c')][_0xd971('0x38')]){_0x178969[_0xd971('0x35')]=_[_0xd971('0x39')](_0x178969[_0xd971('0x35')],{'$or':[{'key':{'$like':'%'+_0x9e177[_0xd971('0x2c')]['filter']+'%'}},{'value':{'$like':'%'+_0x9e177['query'][_0xd971('0x38')]+'%'}}]});}_0x178969=_[_0xd971('0x39')]({},_0x178969,_0x9e177[_0xd971('0x3a')]);var _0x56e683={'where':_0x178969[_0xd971('0x35')]};return db[_0xd971('0x29')][_0xd971('0x1a')](_0x56e683)['then'](function(_0x599381){_0xdc9164[_0xd971('0x1a')]=_0x599381;if(_0x9e177[_0xd971('0x2c')]['includeAll']){_0x178969[_0xd971('0x3b')]=[{'all':!![]}];}return db[_0xd971('0x29')][_0xd971('0x3c')](_0x178969);})[_0xd971('0x22')](function(_0x5d4629){_0xdc9164['rows']=_0x5d4629;return _0xdc9164;})[_0xd971('0x22')](respondWithFilteredResult(_0x4f9bf7,_0x178969))[_0xd971('0x3d')](handleError(_0x4f9bf7,null));};exports[_0xd971('0x3e')]=function(_0x44b8a8,_0xf3f841){var _0x335455={'raw':!![],'where':{'id':_0x44b8a8[_0xd971('0x3f')]['id']}},_0x1a5d81={};_0x1a5d81[_0xd971('0x2e')]=_[_0xd971('0x40')](db[_0xd971('0x29')][_0xd971('0x41')]);_0x1a5d81[_0xd971('0x2c')]=_[_0xd971('0x40')](_0x44b8a8['query']);_0x1a5d81[_0xd971('0x36')]=_[_0xd971('0x2d')](_0x1a5d81[_0xd971('0x2e')],_0x1a5d81[_0xd971('0x2c')]);_0x335455[_0xd971('0x30')]=_['intersection'](_0x1a5d81[_0xd971('0x2e')],qs['fields'](_0x44b8a8['query'][_0xd971('0x2f')]));_0x335455['attributes']=_0x335455[_0xd971('0x30')][_0xd971('0x31')]?_0x335455['attributes']:_0x1a5d81[_0xd971('0x2e')];if(_0x44b8a8[_0xd971('0x2c')]['includeAll']){_0x335455['include']=[{'all':!![]}];}_0x335455=_[_0xd971('0x39')]({},_0x335455,_0x44b8a8['options']);return db[_0xd971('0x29')][_0xd971('0x42')](_0x335455)[_0xd971('0x22')](handleEntityNotFound(_0xf3f841,null))[_0xd971('0x22')](respondWithResult(_0xf3f841,null))[_0xd971('0x3d')](handleError(_0xf3f841,null));};exports[_0xd971('0x21')]=function(_0x517d86,_0x1f5910){if(_0x517d86[_0xd971('0x43')]['id']){delete _0x517d86[_0xd971('0x43')]['id'];}return db['CannedAnswer']['find']({'where':{'id':_0x517d86[_0xd971('0x3f')]['id']}})[_0xd971('0x22')](handleEntityNotFound(_0x1f5910,null))['then'](saveUpdates(_0x517d86[_0xd971('0x43')],null))[_0xd971('0x22')](respondWithResult(_0x1f5910,null))[_0xd971('0x3d')](handleError(_0x1f5910,null));};exports[_0xd971('0x23')]=function(_0x56415b,_0xb3d11){return db['CannedAnswer'][_0xd971('0x42')]({'where':{'id':_0x56415b['params']['id']}})[_0xd971('0x22')](handleEntityNotFound(_0xb3d11,null))['then'](removeEntity(_0xb3d11,null))[_0xd971('0x3d')](handleError(_0xb3d11,null));};exports[_0xd971('0x44')]=function(_0x54c9c8,_0x5ca696){var _0x4ad8e4={'key':_0x54c9c8[_0xd971('0x43')]['key']};if(_0x54c9c8[_0xd971('0x43')][_0xd971('0x45')]){_0x4ad8e4[_0xd971('0x45')]=_0x54c9c8[_0xd971('0x43')][_0xd971('0x45')];}else if(_0x54c9c8[_0xd971('0x43')][_0xd971('0x46')]){_0x4ad8e4[_0xd971('0x46')]=_0x54c9c8['body'][_0xd971('0x46')];}else if(_0x54c9c8['body'][_0xd971('0x47')]){_0x4ad8e4[_0xd971('0x47')]=_0x54c9c8['body']['OpenchannelAccountId'];}else if(_0x54c9c8[_0xd971('0x43')][_0xd971('0x48')]){_0x4ad8e4[_0xd971('0x48')]=_0x54c9c8[_0xd971('0x43')][_0xd971('0x48')];}return db[_0xd971('0x29')]['find']({'where':_0x4ad8e4})[_0xd971('0x22')](function(_0x1561fa){if(_0x1561fa){throw new db[(_0xd971('0x49'))][(_0xd971('0x4a'))](_0xd971('0x4b'));}return db['CannedAnswer'][_0xd971('0x44')](_0x54c9c8['body']);})['then'](function(_0x2c6fe0){var _0x1401ff=_0x54c9c8[_0xd971('0x4c')][_0xd971('0x4d')]({'plain':!![]});if(!_0x1401ff)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x1401ff[_0xd971('0x4e')]===_0xd971('0x4c')){var _0x577602=_0x2c6fe0[_0xd971('0x4d')]({'plain':!![]});return db[_0xd971('0x4f')][_0xd971('0x42')]({'where':{'name':_0xd971('0x50'),'userProfileId':_0x1401ff[_0xd971('0x51')]},'raw':!![]})[_0xd971('0x22')](function(_0x180a8f){if(_0x180a8f&&_0x180a8f[_0xd971('0x52')]===0x0){return db[_0xd971('0x53')]['create']({'name':_0x577602[_0xd971('0x25')],'resourceId':_0x577602['id'],'type':_0x180a8f[_0xd971('0x25')],'sectionId':_0x180a8f['id']},{})['then'](function(){return _0x2c6fe0;});}else{return _0x2c6fe0;}})[_0xd971('0x3d')](function(_0x1cddf4){logger[_0xd971('0x54')](_0xd971('0x55'),_0x1cddf4);throw _0x1cddf4;});}return _0x2c6fe0;})['then'](respondWithResult(_0x5ca696,0xc9))[_0xd971('0x3d')](handleError(_0x5ca696,null));};
\ No newline at end of file
+var _0x78f0=['map','keys','query','filters','intersection','attributes','fields','length','nolimit','order','sort','where','pick','filter','merge','include','CannedAnswer','findAll','show','options','find','catch','body','params','MailAccountId','SmsAccountId','OpenchannelAccountId','ChatWebsiteId','ValidationError','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','eml-format','fast-json-patch','request-promise','moment','bluebird','path','sox','to-csv','ejs','squel','crypto','jsforce','desk.js','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','limit','undefined','count','offset','set','Content-Range','apply','save','update','then','get','CannedAnswers','UserProfileResource','destroy','error','name','index','rawAttributes','type','key','model'];(function(_0x2605dc,_0x50cf7e){var _0x4568c9=function(_0x447f7c){while(--_0x447f7c){_0x2605dc['push'](_0x2605dc['shift']());}};_0x4568c9(++_0x50cf7e);}(_0x78f0,0x75));var _0x078f=function(_0x170b3e,_0x46abbf){_0x170b3e=_0x170b3e-0x0;var _0xff2428=_0x78f0[_0x170b3e];return _0xff2428;};'use strict';var emlformat=require(_0x078f('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0x078f('0x1'));var rp=require(_0x078f('0x2'));var moment=require(_0x078f('0x3'));var BPromise=require(_0x078f('0x4'));var Mustache=require('mustache');var util=require('util');var path=require(_0x078f('0x5'));var sox=require(_0x078f('0x6'));var csv=require(_0x078f('0x7'));var ejs=require(_0x078f('0x8'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0x078f('0x9'));var crypto=require(_0x078f('0xa'));var jsforce=require(_0x078f('0xb'));var deskjs=require(_0x078f('0xc'));var toCsv=require(_0x078f('0x7'));var querystring=require('querystring');var Papa=require(_0x078f('0xd'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x078f('0xe'));var as=require(_0x078f('0xf'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x078f('0x10'));var utils=require('../../config/utils');var config=require(_0x078f('0x11'));var licenseUtil=require(_0x078f('0x12'));var db=require(_0x078f('0x13'))['db'];function respondWithStatusCode(_0x34d250,_0x8c2cb5){_0x8c2cb5=_0x8c2cb5||0xcc;return function(_0x505cad){if(_0x505cad){return _0x34d250[_0x078f('0x14')](_0x8c2cb5);}return _0x34d250[_0x078f('0x15')](_0x8c2cb5)[_0x078f('0x16')]();};}function respondWithResult(_0x35e44d,_0x2dabf4){_0x2dabf4=_0x2dabf4||0xc8;return function(_0x2a5d84){if(_0x2a5d84){return _0x35e44d['status'](_0x2dabf4)[_0x078f('0x17')](_0x2a5d84);}};}function respondWithFilteredResult(_0x3b86d5,_0x4647b0){return function(_0x45ab09){if(_0x45ab09){var _0x1e8ecb=typeof _0x4647b0['offset']==='undefined'&&typeof _0x4647b0[_0x078f('0x18')]===_0x078f('0x19');var _0x4c44b8=_0x45ab09[_0x078f('0x1a')];var _0x4fca98=_0x1e8ecb?0x0:_0x4647b0[_0x078f('0x1b')];var _0xe0bb18=_0x1e8ecb?_0x45ab09['count']:_0x4647b0[_0x078f('0x1b')]+_0x4647b0['limit'];var _0x4f1eb0;if(_0xe0bb18>=_0x4c44b8){_0xe0bb18=_0x4c44b8;_0x4f1eb0=0xc8;}else{_0x4f1eb0=0xce;}_0x3b86d5[_0x078f('0x15')](_0x4f1eb0);return _0x3b86d5[_0x078f('0x1c')](_0x078f('0x1d'),_0x4fca98+'-'+_0xe0bb18+'/'+_0x4c44b8)[_0x078f('0x17')](_0x45ab09);}return null;};}function patchUpdates(_0xcbe3be){return function(_0x133047){try{jsonpatch[_0x078f('0x1e')](_0x133047,_0xcbe3be,!![]);}catch(_0x4f1452){return BPromise['reject'](_0x4f1452);}return _0x133047[_0x078f('0x1f')]();};}function saveUpdates(_0x2865e7,_0x3951d9){return function(_0x13c9b4){if(_0x13c9b4){return _0x13c9b4[_0x078f('0x20')](_0x2865e7)[_0x078f('0x21')](function(_0x1877d9){return _0x1877d9;});}return null;};}function removeEntity(_0x3af948,_0xfeefbb){return function(_0x10a87c){if(_0x10a87c){return _0x10a87c['destroy']()['then'](function(){var _0x51dea1=_0x10a87c[_0x078f('0x22')]({'plain':!![]});var _0x214dbd=_0x078f('0x23');return db[_0x078f('0x24')][_0x078f('0x25')]({'where':{'type':_0x214dbd,'resourceId':_0x51dea1['id']}})['then'](function(){return _0x10a87c;});})[_0x078f('0x21')](function(){_0x3af948[_0x078f('0x15')](0xcc)[_0x078f('0x16')]();});}};}function handleEntityNotFound(_0x162007,_0x4c4956){return function(_0x513f5f){if(!_0x513f5f){_0x162007[_0x078f('0x14')](0x194);}return _0x513f5f;};}function handleError(_0x3fa572,_0x564b92){_0x564b92=_0x564b92||0x1f4;return function(_0xa16216){logger[_0x078f('0x26')](_0xa16216['stack']);if(_0xa16216[_0x078f('0x27')]){delete _0xa16216[_0x078f('0x27')];}_0x3fa572['status'](_0x564b92)['send'](_0xa16216);};}exports[_0x078f('0x28')]=function(_0xe30a88,_0x5952ea){var _0x103f7f={},_0x292f60={},_0x40c028={'count':0x0,'rows':[]};var _0x5b4596=_['map'](db['CannedAnswer'][_0x078f('0x29')],function(_0x53b18e){return{'name':_0x53b18e['fieldName'],'type':_0x53b18e[_0x078f('0x2a')][_0x078f('0x2b')]};});_0x292f60[_0x078f('0x2c')]=_[_0x078f('0x2d')](_0x5b4596,_0x078f('0x27'));_0x292f60['query']=_[_0x078f('0x2e')](_0xe30a88[_0x078f('0x2f')]);_0x292f60[_0x078f('0x30')]=_[_0x078f('0x31')](_0x292f60[_0x078f('0x2c')],_0x292f60[_0x078f('0x2f')]);_0x103f7f[_0x078f('0x32')]=_[_0x078f('0x31')](_0x292f60[_0x078f('0x2c')],qs['fields'](_0xe30a88[_0x078f('0x2f')][_0x078f('0x33')]));_0x103f7f[_0x078f('0x32')]=_0x103f7f[_0x078f('0x32')][_0x078f('0x34')]?_0x103f7f[_0x078f('0x32')]:_0x292f60[_0x078f('0x2c')];if(!_0xe30a88['query']['hasOwnProperty'](_0x078f('0x35'))){_0x103f7f[_0x078f('0x18')]=qs['limit'](_0xe30a88[_0x078f('0x2f')][_0x078f('0x18')]);_0x103f7f[_0x078f('0x1b')]=qs[_0x078f('0x1b')](_0xe30a88['query']['offset']);}_0x103f7f[_0x078f('0x36')]=qs[_0x078f('0x37')](_0xe30a88[_0x078f('0x2f')][_0x078f('0x37')]);_0x103f7f[_0x078f('0x38')]=qs[_0x078f('0x30')](_[_0x078f('0x39')](_0xe30a88['query'],_0x292f60[_0x078f('0x30')]),_0x5b4596);if(_0xe30a88[_0x078f('0x2f')][_0x078f('0x3a')]){_0x103f7f[_0x078f('0x38')]=_[_0x078f('0x3b')](_0x103f7f[_0x078f('0x38')],{'$or':[{'key':{'$like':'%'+_0xe30a88[_0x078f('0x2f')]['filter']+'%'}},{'value':{'$like':'%'+_0xe30a88['query'][_0x078f('0x3a')]+'%'}}]});}_0x103f7f=_[_0x078f('0x3b')]({},_0x103f7f,_0xe30a88['options']);var _0x2d154d={'where':_0x103f7f['where']};return db['CannedAnswer'][_0x078f('0x1a')](_0x2d154d)[_0x078f('0x21')](function(_0x4b8ff1){_0x40c028[_0x078f('0x1a')]=_0x4b8ff1;if(_0xe30a88[_0x078f('0x2f')]['includeAll']){_0x103f7f[_0x078f('0x3c')]=[{'all':!![]}];}return db[_0x078f('0x3d')][_0x078f('0x3e')](_0x103f7f);})[_0x078f('0x21')](function(_0x44973f){_0x40c028['rows']=_0x44973f;return _0x40c028;})[_0x078f('0x21')](respondWithFilteredResult(_0x5952ea,_0x103f7f))['catch'](handleError(_0x5952ea,null));};exports[_0x078f('0x3f')]=function(_0x5bc926,_0xd92888){var _0x26a1f8={'raw':!![],'where':{'id':_0x5bc926['params']['id']}},_0xf2b449={};_0xf2b449[_0x078f('0x2c')]=_[_0x078f('0x2e')](db[_0x078f('0x3d')][_0x078f('0x29')]);_0xf2b449['query']=_[_0x078f('0x2e')](_0x5bc926[_0x078f('0x2f')]);_0xf2b449[_0x078f('0x30')]=_[_0x078f('0x31')](_0xf2b449[_0x078f('0x2c')],_0xf2b449['query']);_0x26a1f8[_0x078f('0x32')]=_[_0x078f('0x31')](_0xf2b449[_0x078f('0x2c')],qs[_0x078f('0x33')](_0x5bc926['query'][_0x078f('0x33')]));_0x26a1f8[_0x078f('0x32')]=_0x26a1f8[_0x078f('0x32')]['length']?_0x26a1f8['attributes']:_0xf2b449['model'];if(_0x5bc926[_0x078f('0x2f')]['includeAll']){_0x26a1f8[_0x078f('0x3c')]=[{'all':!![]}];}_0x26a1f8=_[_0x078f('0x3b')]({},_0x26a1f8,_0x5bc926[_0x078f('0x40')]);return db[_0x078f('0x3d')][_0x078f('0x41')](_0x26a1f8)[_0x078f('0x21')](handleEntityNotFound(_0xd92888,null))['then'](respondWithResult(_0xd92888,null))[_0x078f('0x42')](handleError(_0xd92888,null));};exports[_0x078f('0x20')]=function(_0x38c205,_0x169434){if(_0x38c205[_0x078f('0x43')]['id']){delete _0x38c205[_0x078f('0x43')]['id'];}return db[_0x078f('0x3d')]['find']({'where':{'id':_0x38c205[_0x078f('0x44')]['id']}})[_0x078f('0x21')](handleEntityNotFound(_0x169434,null))[_0x078f('0x21')](saveUpdates(_0x38c205[_0x078f('0x43')],null))[_0x078f('0x21')](respondWithResult(_0x169434,null))[_0x078f('0x42')](handleError(_0x169434,null));};exports['destroy']=function(_0x53f2a8,_0xa159a2){return db[_0x078f('0x3d')][_0x078f('0x41')]({'where':{'id':_0x53f2a8[_0x078f('0x44')]['id']}})['then'](handleEntityNotFound(_0xa159a2,null))['then'](removeEntity(_0xa159a2,null))['catch'](handleError(_0xa159a2,null));};exports['create']=function(_0x247757,_0x1fa66a){var _0x364301={'key':_0x247757['body'][_0x078f('0x2b')]};if(_0x247757[_0x078f('0x43')]['MailAccountId']){_0x364301[_0x078f('0x45')]=_0x247757[_0x078f('0x43')]['MailAccountId'];}else if(_0x247757['body'][_0x078f('0x46')]){_0x364301[_0x078f('0x46')]=_0x247757[_0x078f('0x43')]['SmsAccountId'];}else if(_0x247757[_0x078f('0x43')][_0x078f('0x47')]){_0x364301['OpenchannelAccountId']=_0x247757[_0x078f('0x43')][_0x078f('0x47')];}else if(_0x247757[_0x078f('0x43')][_0x078f('0x48')]){_0x364301[_0x078f('0x48')]=_0x247757['body'][_0x078f('0x48')];}return db[_0x078f('0x3d')][_0x078f('0x41')]({'where':_0x364301})[_0x078f('0x21')](function(_0x23a14e){if(_0x23a14e){throw new db['Sequelize'][(_0x078f('0x49'))]('The\x20inserted\x20key\x20already\x20exists.');}return db[_0x078f('0x3d')][_0x078f('0x4a')](_0x247757[_0x078f('0x43')]);})[_0x078f('0x21')](function(_0x918295){var _0x4eb85a=_0x247757[_0x078f('0x4b')]['get']({'plain':!![]});if(!_0x4eb85a)throw new Error(_0x078f('0x4c'));if(_0x4eb85a[_0x078f('0x4d')]===_0x078f('0x4b')){var _0x3ad67c=_0x918295[_0x078f('0x22')]({'plain':!![]});return db[_0x078f('0x4e')][_0x078f('0x41')]({'where':{'name':_0x078f('0x23'),'userProfileId':_0x4eb85a[_0x078f('0x4f')]},'raw':!![]})[_0x078f('0x21')](function(_0x1b3605){if(_0x1b3605&&_0x1b3605[_0x078f('0x50')]===0x0){return db[_0x078f('0x24')][_0x078f('0x4a')]({'name':_0x3ad67c['name'],'resourceId':_0x3ad67c['id'],'type':_0x1b3605[_0x078f('0x27')],'sectionId':_0x1b3605['id']},{})[_0x078f('0x21')](function(){return _0x918295;});}else{return _0x918295;}})['catch'](function(_0xddf7d1){logger['error']('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0xddf7d1);throw _0xddf7d1;});}return _0x918295;})[_0x078f('0x21')](respondWithResult(_0x1fa66a,0xc9))[_0x078f('0x42')](handleError(_0x1fa66a,null));};
\ No newline at end of file