Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / cannedAnswer / cannedAnswer.controller.js
index 38c7510..c426712 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xc26d=['request-promise','bluebird','util','path','lodash','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../mysqldb','sendStatus','status','end','json','undefined','limit','count','apply','save','then','destroy','get','CannedAnswers','error','stack','name','index','CannedAnswer','rawAttributes','type','key','model','map','query','keys','intersection','fields','attributes','length','hasOwnProperty','nolimit','offset','sort','pick','filters','filter','where','merge','options','findAll','catch','show','params','includeAll','include','find','update','body','MailAccountId','SmsAccountId','OpenchannelAccountId','ChatWebsiteId','ValidationError','The\x20inserted\x20key\x20already\x20exists.','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','autoAssociation','UserProfileResource','create','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','eml-format','rimraf','zip-dir','fast-json-patch'];(function(_0xc239fc,_0x24f786){var _0x21dc25=function(_0x3d6f15){while(--_0x3d6f15){_0xc239fc['push'](_0xc239fc['shift']());}};_0x21dc25(++_0x24f786);}(_0xc26d,0x148));var _0xdc26=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xc26d[_0x3dd15e];return _0x231fd0;};'use strict';var emlformat=require(_0xdc26('0x0'));var rimraf=require(_0xdc26('0x1'));var zipdir=require(_0xdc26('0x2'));var jsonpatch=require(_0xdc26('0x3'));var rp=require(_0xdc26('0x4'));var moment=require('moment');var BPromise=require(_0xdc26('0x5'));var Mustache=require('mustache');var util=require(_0xdc26('0x6'));var path=require(_0xdc26('0x7'));var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xdc26('0x8'));var squel=require(_0xdc26('0x9'));var crypto=require('crypto');var jsforce=require(_0xdc26('0xa'));var deskjs=require(_0xdc26('0xb'));var toCsv=require('to-csv');var querystring=require(_0xdc26('0xc'));var Papa=require(_0xdc26('0xd'));var Redis=require(_0xdc26('0xe'));var authService=require(_0xdc26('0xf'));var qs=require('../../components/parsers/qs');var as=require(_0xdc26('0x10'));var hardwareService=require(_0xdc26('0x11'));var logger=require(_0xdc26('0x12'))(_0xdc26('0x13'));var utils=require(_0xdc26('0x14'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0xdc26('0x15'))['db'];function respondWithStatusCode(_0x186e59,_0x504baa){_0x504baa=_0x504baa||0xcc;return function(_0xb7f6cd){if(_0xb7f6cd){return _0x186e59[_0xdc26('0x16')](_0x504baa);}return _0x186e59[_0xdc26('0x17')](_0x504baa)[_0xdc26('0x18')]();};}function respondWithResult(_0x3ba678,_0x54dbc4){_0x54dbc4=_0x54dbc4||0xc8;return function(_0x1b261e){if(_0x1b261e){return _0x3ba678['status'](_0x54dbc4)[_0xdc26('0x19')](_0x1b261e);}};}function respondWithFilteredResult(_0x155b7c,_0x314bb0){return function(_0x314132){if(_0x314132){var _0xe435b=typeof _0x314bb0['offset']===_0xdc26('0x1a')&&typeof _0x314bb0[_0xdc26('0x1b')]===_0xdc26('0x1a');var _0x15dacf=_0x314132[_0xdc26('0x1c')];var _0x1608c2=_0xe435b?0x0:_0x314bb0['offset'];var _0x55380a=_0xe435b?_0x314132[_0xdc26('0x1c')]:_0x314bb0['offset']+_0x314bb0[_0xdc26('0x1b')];var _0x412e0e;if(_0x55380a>=_0x15dacf){_0x55380a=_0x15dacf;_0x412e0e=0xc8;}else{_0x412e0e=0xce;}_0x155b7c[_0xdc26('0x17')](_0x412e0e);return _0x155b7c['set']('Content-Range',_0x1608c2+'-'+_0x55380a+'/'+_0x15dacf)['json'](_0x314132);}return null;};}function patchUpdates(_0x5d7b88){return function(_0x593ac7){try{jsonpatch[_0xdc26('0x1d')](_0x593ac7,_0x5d7b88,!![]);}catch(_0x57970b){return BPromise['reject'](_0x57970b);}return _0x593ac7[_0xdc26('0x1e')]();};}function saveUpdates(_0x15c6dc,_0x1f1eea){return function(_0x48a7a7){if(_0x48a7a7){return _0x48a7a7['update'](_0x15c6dc)[_0xdc26('0x1f')](function(_0xc6ec37){return _0xc6ec37;});}return null;};}function removeEntity(_0x228c33,_0x57a249){return function(_0x2aa29a){if(_0x2aa29a){return _0x2aa29a[_0xdc26('0x20')]()[_0xdc26('0x1f')](function(){var _0x533266=_0x2aa29a[_0xdc26('0x21')]({'plain':!![]});var _0x4cf8ee=_0xdc26('0x22');return db['UserProfileResource']['destroy']({'where':{'type':_0x4cf8ee,'resourceId':_0x533266['id']}})[_0xdc26('0x1f')](function(){return _0x2aa29a;});})['then'](function(){_0x228c33['status'](0xcc)[_0xdc26('0x18')]();});}};}function handleEntityNotFound(_0x28c104,_0x398fd2){return function(_0x1748d5){if(!_0x1748d5){_0x28c104[_0xdc26('0x16')](0x194);}return _0x1748d5;};}function handleError(_0x2e2b5f,_0x1423f0){_0x1423f0=_0x1423f0||0x1f4;return function(_0x298403){logger[_0xdc26('0x23')](_0x298403[_0xdc26('0x24')]);if(_0x298403['name']){delete _0x298403[_0xdc26('0x25')];}_0x2e2b5f[_0xdc26('0x17')](_0x1423f0)['send'](_0x298403);};}exports[_0xdc26('0x26')]=function(_0x2265d3,_0x82d21e){var _0x5d272d={},_0x5ab6e6={},_0x5d1cf6={'count':0x0,'rows':[]};var _0x516927=_['map'](db[_0xdc26('0x27')][_0xdc26('0x28')],function(_0x536717){return{'name':_0x536717['fieldName'],'type':_0x536717[_0xdc26('0x29')][_0xdc26('0x2a')]};});_0x5ab6e6[_0xdc26('0x2b')]=_[_0xdc26('0x2c')](_0x516927,_0xdc26('0x25'));_0x5ab6e6[_0xdc26('0x2d')]=_[_0xdc26('0x2e')](_0x2265d3[_0xdc26('0x2d')]);_0x5ab6e6['filters']=_[_0xdc26('0x2f')](_0x5ab6e6[_0xdc26('0x2b')],_0x5ab6e6[_0xdc26('0x2d')]);_0x5d272d['attributes']=_['intersection'](_0x5ab6e6['model'],qs[_0xdc26('0x30')](_0x2265d3[_0xdc26('0x2d')][_0xdc26('0x30')]));_0x5d272d[_0xdc26('0x31')]=_0x5d272d[_0xdc26('0x31')][_0xdc26('0x32')]?_0x5d272d[_0xdc26('0x31')]:_0x5ab6e6[_0xdc26('0x2b')];if(!_0x2265d3[_0xdc26('0x2d')][_0xdc26('0x33')](_0xdc26('0x34'))){_0x5d272d['limit']=qs[_0xdc26('0x1b')](_0x2265d3['query'][_0xdc26('0x1b')]);_0x5d272d[_0xdc26('0x35')]=qs[_0xdc26('0x35')](_0x2265d3['query']['offset']);}_0x5d272d['order']=qs[_0xdc26('0x36')](_0x2265d3['query'][_0xdc26('0x36')]);_0x5d272d['where']=qs['filters'](_[_0xdc26('0x37')](_0x2265d3[_0xdc26('0x2d')],_0x5ab6e6[_0xdc26('0x38')]),_0x516927);if(_0x2265d3[_0xdc26('0x2d')][_0xdc26('0x39')]){_0x5d272d[_0xdc26('0x3a')]=_[_0xdc26('0x3b')](_0x5d272d['where'],{'$or':[{'key':{'$like':'%'+_0x2265d3[_0xdc26('0x2d')][_0xdc26('0x39')]+'%'}},{'value':{'$like':'%'+_0x2265d3[_0xdc26('0x2d')][_0xdc26('0x39')]+'%'}}]});}_0x5d272d=_[_0xdc26('0x3b')]({},_0x5d272d,_0x2265d3[_0xdc26('0x3c')]);var _0x262a3f={'where':_0x5d272d[_0xdc26('0x3a')]};return db[_0xdc26('0x27')][_0xdc26('0x1c')](_0x262a3f)['then'](function(_0x249438){_0x5d1cf6[_0xdc26('0x1c')]=_0x249438;if(_0x2265d3[_0xdc26('0x2d')]['includeAll']){_0x5d272d['include']=[{'all':!![]}];}return db[_0xdc26('0x27')][_0xdc26('0x3d')](_0x5d272d);})[_0xdc26('0x1f')](function(_0x265432){_0x5d1cf6['rows']=_0x265432;return _0x5d1cf6;})[_0xdc26('0x1f')](respondWithFilteredResult(_0x82d21e,_0x5d272d))[_0xdc26('0x3e')](handleError(_0x82d21e,null));};exports[_0xdc26('0x3f')]=function(_0x507ec4,_0x4bfffe){var _0x55fdcb={'raw':!![],'where':{'id':_0x507ec4[_0xdc26('0x40')]['id']}},_0x5af5ee={};_0x5af5ee[_0xdc26('0x2b')]=_[_0xdc26('0x2e')](db['CannedAnswer'][_0xdc26('0x28')]);_0x5af5ee[_0xdc26('0x2d')]=_[_0xdc26('0x2e')](_0x507ec4[_0xdc26('0x2d')]);_0x5af5ee[_0xdc26('0x38')]=_[_0xdc26('0x2f')](_0x5af5ee['model'],_0x5af5ee[_0xdc26('0x2d')]);_0x55fdcb[_0xdc26('0x31')]=_['intersection'](_0x5af5ee[_0xdc26('0x2b')],qs['fields'](_0x507ec4[_0xdc26('0x2d')]['fields']));_0x55fdcb[_0xdc26('0x31')]=_0x55fdcb['attributes'][_0xdc26('0x32')]?_0x55fdcb[_0xdc26('0x31')]:_0x5af5ee[_0xdc26('0x2b')];if(_0x507ec4['query'][_0xdc26('0x41')]){_0x55fdcb[_0xdc26('0x42')]=[{'all':!![]}];}_0x55fdcb=_[_0xdc26('0x3b')]({},_0x55fdcb,_0x507ec4[_0xdc26('0x3c')]);return db['CannedAnswer'][_0xdc26('0x43')](_0x55fdcb)[_0xdc26('0x1f')](handleEntityNotFound(_0x4bfffe,null))['then'](respondWithResult(_0x4bfffe,null))[_0xdc26('0x3e')](handleError(_0x4bfffe,null));};exports[_0xdc26('0x44')]=function(_0x1b5bd9,_0xe79bc2){if(_0x1b5bd9[_0xdc26('0x45')]['id']){delete _0x1b5bd9[_0xdc26('0x45')]['id'];}return db['CannedAnswer'][_0xdc26('0x43')]({'where':{'id':_0x1b5bd9[_0xdc26('0x40')]['id']}})[_0xdc26('0x1f')](handleEntityNotFound(_0xe79bc2,null))[_0xdc26('0x1f')](saveUpdates(_0x1b5bd9[_0xdc26('0x45')],null))[_0xdc26('0x1f')](respondWithResult(_0xe79bc2,null))[_0xdc26('0x3e')](handleError(_0xe79bc2,null));};exports[_0xdc26('0x20')]=function(_0x3fd31b,_0x226a54){return db[_0xdc26('0x27')][_0xdc26('0x43')]({'where':{'id':_0x3fd31b[_0xdc26('0x40')]['id']}})[_0xdc26('0x1f')](handleEntityNotFound(_0x226a54,null))[_0xdc26('0x1f')](removeEntity(_0x226a54,null))[_0xdc26('0x3e')](handleError(_0x226a54,null));};exports['create']=function(_0xc26fc6,_0x2db7d3){var _0x3e5f33={'key':_0xc26fc6['body'][_0xdc26('0x2a')]};if(_0xc26fc6[_0xdc26('0x45')]['MailAccountId']){_0x3e5f33[_0xdc26('0x46')]=_0xc26fc6[_0xdc26('0x45')][_0xdc26('0x46')];}else if(_0xc26fc6[_0xdc26('0x45')]['SmsAccountId']){_0x3e5f33[_0xdc26('0x47')]=_0xc26fc6[_0xdc26('0x45')][_0xdc26('0x47')];}else if(_0xc26fc6[_0xdc26('0x45')][_0xdc26('0x48')]){_0x3e5f33[_0xdc26('0x48')]=_0xc26fc6[_0xdc26('0x45')]['OpenchannelAccountId'];}else if(_0xc26fc6[_0xdc26('0x45')][_0xdc26('0x49')]){_0x3e5f33[_0xdc26('0x49')]=_0xc26fc6[_0xdc26('0x45')][_0xdc26('0x49')];}return db[_0xdc26('0x27')][_0xdc26('0x43')]({'where':_0x3e5f33})[_0xdc26('0x1f')](function(_0xec2dff){if(_0xec2dff){throw new db['Sequelize'][(_0xdc26('0x4a'))](_0xdc26('0x4b'));}return db['CannedAnswer']['create'](_0xc26fc6[_0xdc26('0x45')]);})[_0xdc26('0x1f')](function(_0x4bd290){var _0xb6bc99=_0xc26fc6['user'][_0xdc26('0x21')]({'plain':!![]});if(!_0xb6bc99)throw new Error(_0xdc26('0x4c'));if(_0xb6bc99[_0xdc26('0x4d')]==='user'){var _0x1ef0cb=_0x4bd290[_0xdc26('0x21')]({'plain':!![]});return db[_0xdc26('0x4e')][_0xdc26('0x43')]({'where':{'name':_0xdc26('0x22'),'userProfileId':_0xb6bc99['userProfileId']},'raw':!![]})[_0xdc26('0x1f')](function(_0x353e0a){if(_0x353e0a&&_0x353e0a[_0xdc26('0x4f')]===0x0){return db[_0xdc26('0x50')][_0xdc26('0x51')]({'name':_0x1ef0cb[_0xdc26('0x25')],'resourceId':_0x1ef0cb['id'],'type':_0x353e0a['name'],'sectionId':_0x353e0a['id']},{})[_0xdc26('0x1f')](function(){return _0x4bd290;});}else{return _0x4bd290;}})[_0xdc26('0x3e')](function(_0x4a2ab5){logger[_0xdc26('0x23')](_0xdc26('0x52'),_0x4a2ab5);throw _0x4a2ab5;});}return _0x4bd290;})['then'](respondWithResult(_0x2db7d3,0xc9))[_0xdc26('0x3e')](handleError(_0x2db7d3,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