Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / cannedAnswer / cannedAnswer.controller.js
index 28fcd46..c426712 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x9957=['limit','set','Content-Range','reject','save','then','destroy','get','CannedAnswers','UserProfileResource','stack','name','send','rawAttributes','fieldName','type','key','model','query','filters','intersection','attributes','hasOwnProperty','nolimit','order','sort','where','pick','merge','map','filter','options','CannedAnswer','count','include','catch','show','params','keys','length','includeAll','find','update','body','create','MailAccountId','SmsAccountId','OpenchannelAccountId','ChatWebsiteId','Sequelize','ValidationError','The\x20inserted\x20key\x20already\x20exists.','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','html-pdf','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','path','sox','to-csv','ejs','lodash','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../mysqldb','sendStatus','status','end','json','offset'];(function(_0x59a9e8,_0x2321c4){var _0x681024=function(_0x748cb5){while(--_0x748cb5){_0x59a9e8['push'](_0x59a9e8['shift']());}};_0x681024(++_0x2321c4);}(_0x9957,0x93));var _0x7995=function(_0x6c993a,_0x5ea3ab){_0x6c993a=_0x6c993a-0x0;var _0x27f547=_0x9957[_0x6c993a];return _0x27f547;};'use strict';var pdf=require(_0x7995('0x0'));var emlformat=require(_0x7995('0x1'));var rimraf=require(_0x7995('0x2'));var zipdir=require(_0x7995('0x3'));var jsonpatch=require('fast-json-patch');var rp=require(_0x7995('0x4'));var moment=require(_0x7995('0x5'));var BPromise=require(_0x7995('0x6'));var Mustache=require(_0x7995('0x7'));var util=require('util');var path=require(_0x7995('0x8'));var sox=require(_0x7995('0x9'));var csv=require(_0x7995('0xa'));var ejs=require(_0x7995('0xb'));var fs=require('fs');var _=require(_0x7995('0xc'));var squel=require(_0x7995('0xd'));var crypto=require('crypto');var jsforce=require(_0x7995('0xe'));var deskjs=require(_0x7995('0xf'));var toCsv=require('to-csv');var querystring=require(_0x7995('0x10'));var Papa=require(_0x7995('0x11'));var Redis=require(_0x7995('0x12'));var authService=require(_0x7995('0x13'));var qs=require(_0x7995('0x14'));var as=require(_0x7995('0x15'));var hardwareService=require(_0x7995('0x16'));var logger=require('../../config/logger')(_0x7995('0x17'));var utils=require(_0x7995('0x18'));var config=require('../../config/environment');var db=require(_0x7995('0x19'))['db'];function respondWithStatusCode(_0x2cb37a,_0x19a27e){_0x19a27e=_0x19a27e||0xcc;return function(_0x385f00){if(_0x385f00){return _0x2cb37a[_0x7995('0x1a')](_0x19a27e);}return _0x2cb37a[_0x7995('0x1b')](_0x19a27e)[_0x7995('0x1c')]();};}function respondWithResult(_0x4cc004,_0x58f5ad){_0x58f5ad=_0x58f5ad||0xc8;return function(_0x2b4e94){if(_0x2b4e94){return _0x4cc004[_0x7995('0x1b')](_0x58f5ad)[_0x7995('0x1d')](_0x2b4e94);}};}function respondWithFilteredResult(_0x321ae8,_0x3f1d3e){return function(_0x1a5310){if(_0x1a5310){var _0x2202ce=_0x1a5310['count'],_0x41cbf0=_0x3f1d3e[_0x7995('0x1e')],_0x5377e5=_0x3f1d3e[_0x7995('0x1e')]+_0x3f1d3e[_0x7995('0x1f')],_0x2eeacc;if(_0x5377e5>=_0x2202ce){_0x5377e5=_0x2202ce;_0x2eeacc=0xc8;}else{_0x2eeacc=0xce;}_0x321ae8[_0x7995('0x1b')](_0x2eeacc);return _0x321ae8[_0x7995('0x20')](_0x7995('0x21'),_0x41cbf0+'-'+_0x5377e5+'/'+_0x2202ce)['json'](_0x1a5310);}return null;};}function patchUpdates(_0x54c9ae){return function(_0x2536c8){try{jsonpatch['apply'](_0x2536c8,_0x54c9ae,!![]);}catch(_0x555f74){return BPromise[_0x7995('0x22')](_0x555f74);}return _0x2536c8[_0x7995('0x23')]();};}function saveUpdates(_0x4cbe10,_0x3a9b54){return function(_0x51f276){if(_0x51f276){return _0x51f276['update'](_0x4cbe10)[_0x7995('0x24')](function(_0x327b1f){return _0x327b1f;});}return null;};}function removeEntity(_0x350fd9,_0x1a8568){return function(_0x460924){if(_0x460924){return _0x460924[_0x7995('0x25')]()['then'](function(){var _0x32a09a=_0x460924[_0x7995('0x26')]({'plain':!![]});var _0x204507=_0x7995('0x27');return db[_0x7995('0x28')][_0x7995('0x25')]({'where':{'type':_0x204507,'resourceId':_0x32a09a['id']}})[_0x7995('0x24')](function(){return _0x460924;});})[_0x7995('0x24')](function(){_0x350fd9['status'](0xcc)[_0x7995('0x1c')]();});}};}function handleEntityNotFound(_0x34e70c,_0x401dc3){return function(_0x268ce7){if(!_0x268ce7){_0x34e70c[_0x7995('0x1a')](0x194);}return _0x268ce7;};}function handleError(_0x2a307e,_0x56691a){_0x56691a=_0x56691a||0x1f4;return function(_0x47625f){logger['error'](_0x47625f[_0x7995('0x29')]);if(_0x47625f[_0x7995('0x2a')]){delete _0x47625f[_0x7995('0x2a')];}_0x2a307e[_0x7995('0x1b')](_0x56691a)[_0x7995('0x2b')](_0x47625f);};}exports['index']=function(_0x9b2a15,_0x514445){var _0x456a28={},_0x3250e0={},_0x4253e5={'count':0x0,'rows':[]};var _0x574574=_['map'](db['CannedAnswer'][_0x7995('0x2c')],function(_0xe6b0b3){return{'name':_0xe6b0b3[_0x7995('0x2d')],'type':_0xe6b0b3[_0x7995('0x2e')][_0x7995('0x2f')]};});_0x3250e0[_0x7995('0x30')]=_['map'](_0x574574,'name');_0x3250e0[_0x7995('0x31')]=_['keys'](_0x9b2a15[_0x7995('0x31')]);_0x3250e0[_0x7995('0x32')]=_[_0x7995('0x33')](_0x3250e0[_0x7995('0x30')],_0x3250e0[_0x7995('0x31')]);_0x456a28['attributes']=_[_0x7995('0x33')](_0x3250e0[_0x7995('0x30')],qs['fields'](_0x9b2a15['query']['fields']));_0x456a28[_0x7995('0x34')]=_0x456a28[_0x7995('0x34')]['length']?_0x456a28[_0x7995('0x34')]:_0x3250e0['model'];if(!_0x9b2a15[_0x7995('0x31')][_0x7995('0x35')](_0x7995('0x36'))){_0x456a28['limit']=qs['limit'](_0x9b2a15[_0x7995('0x31')]['limit']);_0x456a28['offset']=qs[_0x7995('0x1e')](_0x9b2a15[_0x7995('0x31')]['offset']);}_0x456a28[_0x7995('0x37')]=qs[_0x7995('0x38')](_0x9b2a15[_0x7995('0x31')][_0x7995('0x38')]);_0x456a28[_0x7995('0x39')]=qs['filters'](_[_0x7995('0x3a')](_0x9b2a15[_0x7995('0x31')],_0x3250e0[_0x7995('0x32')]));if(_0x9b2a15[_0x7995('0x31')]['filter']){_0x456a28[_0x7995('0x39')]=_[_0x7995('0x3b')](_0x456a28[_0x7995('0x39')],{'$or':_[_0x7995('0x3c')](_0x574574,function(_0x1f5bee){if(_0x1f5bee[_0x7995('0x2e')]!=='VIRTUAL'){var _0x183a68={};_0x183a68[_0x1f5bee[_0x7995('0x2a')]]={'$like':'%'+_0x9b2a15[_0x7995('0x31')][_0x7995('0x3d')]+'%'};return _0x183a68;}})});}_0x456a28=_[_0x7995('0x3b')]({},_0x456a28,_0x9b2a15[_0x7995('0x3e')]);var _0x14d638={'where':_0x456a28[_0x7995('0x39')]};return db[_0x7995('0x3f')][_0x7995('0x40')](_0x14d638)[_0x7995('0x24')](function(_0x270d52){_0x4253e5[_0x7995('0x40')]=_0x270d52;if(_0x9b2a15['query']['includeAll']){_0x456a28[_0x7995('0x41')]=[{'all':!![]}];}return db[_0x7995('0x3f')]['findAll'](_0x456a28);})['then'](function(_0x3f8522){_0x4253e5['rows']=_0x3f8522;return _0x4253e5;})['then'](respondWithFilteredResult(_0x514445,_0x456a28))[_0x7995('0x42')](handleError(_0x514445,null));};exports[_0x7995('0x43')]=function(_0x35c8ff,_0x576b96){var _0x46ac4f={'raw':!![],'where':{'id':_0x35c8ff[_0x7995('0x44')]['id']}},_0x5e85b9={};_0x5e85b9['model']=_['keys'](db[_0x7995('0x3f')][_0x7995('0x2c')]);_0x5e85b9[_0x7995('0x31')]=_[_0x7995('0x45')](_0x35c8ff['query']);_0x5e85b9[_0x7995('0x32')]=_[_0x7995('0x33')](_0x5e85b9[_0x7995('0x30')],_0x5e85b9[_0x7995('0x31')]);_0x46ac4f['attributes']=_['intersection'](_0x5e85b9[_0x7995('0x30')],qs['fields'](_0x35c8ff[_0x7995('0x31')]['fields']));_0x46ac4f[_0x7995('0x34')]=_0x46ac4f['attributes'][_0x7995('0x46')]?_0x46ac4f[_0x7995('0x34')]:_0x5e85b9['model'];if(_0x35c8ff[_0x7995('0x31')][_0x7995('0x47')]){_0x46ac4f[_0x7995('0x41')]=[{'all':!![]}];}_0x46ac4f=_[_0x7995('0x3b')]({},_0x46ac4f,_0x35c8ff['options']);return db[_0x7995('0x3f')][_0x7995('0x48')](_0x46ac4f)[_0x7995('0x24')](handleEntityNotFound(_0x576b96,null))['then'](respondWithResult(_0x576b96,null))[_0x7995('0x42')](handleError(_0x576b96,null));};exports[_0x7995('0x49')]=function(_0x511567,_0x3d8ae3){if(_0x511567[_0x7995('0x4a')]['id']){delete _0x511567['body']['id'];}return db[_0x7995('0x3f')][_0x7995('0x48')]({'where':{'id':_0x511567['params']['id']}})[_0x7995('0x24')](handleEntityNotFound(_0x3d8ae3,null))['then'](saveUpdates(_0x511567[_0x7995('0x4a')],null))[_0x7995('0x24')](respondWithResult(_0x3d8ae3,null))[_0x7995('0x42')](handleError(_0x3d8ae3,null));};exports[_0x7995('0x25')]=function(_0xddf537,_0x14b537){return db[_0x7995('0x3f')]['find']({'where':{'id':_0xddf537[_0x7995('0x44')]['id']}})[_0x7995('0x24')](handleEntityNotFound(_0x14b537,null))[_0x7995('0x24')](removeEntity(_0x14b537,null))['catch'](handleError(_0x14b537,null));};exports[_0x7995('0x4b')]=function(_0x1fe77e,_0x12d4b8){var _0x47d1d8={'key':_0x1fe77e['body']['key']};if(_0x1fe77e[_0x7995('0x4a')][_0x7995('0x4c')]){_0x47d1d8['MailAccountId']=_0x1fe77e[_0x7995('0x4a')][_0x7995('0x4c')];}else if(_0x1fe77e[_0x7995('0x4a')][_0x7995('0x4d')]){_0x47d1d8[_0x7995('0x4d')]=_0x1fe77e['body'][_0x7995('0x4d')];}else if(_0x1fe77e['body'][_0x7995('0x4e')]){_0x47d1d8[_0x7995('0x4e')]=_0x1fe77e[_0x7995('0x4a')]['OpenchannelAccountId'];}else if(_0x1fe77e['body']['ChatWebsiteId']){_0x47d1d8['ChatWebsiteId']=_0x1fe77e[_0x7995('0x4a')][_0x7995('0x4f')];}return db[_0x7995('0x3f')][_0x7995('0x48')]({'where':_0x47d1d8})[_0x7995('0x24')](function(_0x357e60){if(_0x357e60){throw new db[(_0x7995('0x50'))][(_0x7995('0x51'))](_0x7995('0x52'));}return db[_0x7995('0x3f')][_0x7995('0x4b')](_0x1fe77e[_0x7995('0x4a')]);})[_0x7995('0x24')](function(_0x35bea3){var _0x1ea1dc=_0x1fe77e[_0x7995('0x53')][_0x7995('0x26')]({'plain':!![]});if(!_0x1ea1dc)throw new Error(_0x7995('0x54'));if(_0x1ea1dc[_0x7995('0x55')]==='user'){var _0x56a374=_0x35bea3[_0x7995('0x26')]({'plain':!![]});return db[_0x7995('0x56')][_0x7995('0x48')]({'where':{'name':'CannedAnswers','userProfileId':_0x1ea1dc['userProfileId']},'raw':!![]})[_0x7995('0x24')](function(_0x197b52){if(_0x197b52&&_0x197b52[_0x7995('0x57')]===0x0){return db[_0x7995('0x28')]['create']({'name':_0x56a374[_0x7995('0x2a')],'resourceId':_0x56a374['id'],'type':_0x197b52[_0x7995('0x2a')],'sectionId':_0x197b52['id']},{})[_0x7995('0x24')](function(){return _0x35bea3;});}else{return _0x35bea3;}})[_0x7995('0x42')](function(_0x502d43){logger['error'](_0x7995('0x58'),_0x502d43);throw _0x502d43;});}return _0x35bea3;})[_0x7995('0x24')](respondWithResult(_0x12d4b8,0xc9))[_0x7995('0x42')](handleError(_0x12d4b8,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