Built motion from commit 973e3e332e1c8e2f84c4b0cd2e5af794131724f5. Version 3.0.0...
[motion-next.git] / server / api / cannedAnswer / cannedAnswer.controller.js
index dede33c..45a48d5 100644 (file)
@@ -1 +1 @@
-const a47_0x2613=['count','json','create','OpenchannelAccountId','CannedAnswer','options','get','sequelize','undefined','length','type','user','../../config/logger','merge','destroy','body','order','fields','offset','map','rawAttributes','keys','name','model','sort','where','findAll','params','fieldName','Content-Range','filter','nolimit','status','MailAccountId','findOne','limit','filters','../../components/parsers/qs','autoAssociation','includeAll','send','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','The\x20inserted\x20key\x20already\x20exists.','then','error','userProfileId','catch','sendStatus','intersection','set','attributes','../../mysqldb','stack','CannedAnswers','VIRTUAL','ChatWebsiteId','SmsAccountId','query','update'];(function(_0x5e54e2,_0x2613d1){const _0x563be3=function(_0x131888){while(--_0x131888){_0x5e54e2['push'](_0x5e54e2['shift']());}};_0x563be3(++_0x2613d1);}(a47_0x2613,0x17b));const a47_0x563b=function(_0x5e54e2,_0x2613d1){_0x5e54e2=_0x5e54e2-0x0;let _0x563be3=a47_0x2613[_0x5e54e2];return _0x563be3;};const _0x292173=a47_0x563b;'use strict';const _=require('lodash'),qs=require(_0x292173('0xc')),logger=require(_0x292173('0x2e'))('api'),db=require(_0x292173('0x1a'))['db'],{Op,ValidationError}=require(_0x292173('0x29'));function respondWithResult(_0x131888,_0x2c8aae){return _0x2c8aae=_0x2c8aae||0xc8,function(_0x18790c){const _0x20ce17=a47_0x563b;if(_0x18790c)return _0x131888['status'](_0x2c8aae)[_0x20ce17('0x23')](_0x18790c);};}function respondWithFilteredResult(_0x291340,_0x3c9354){return function(_0x1adca5){const _0x1f489b=a47_0x563b;if(_0x1adca5){const _0x224f7c=_0x1adca5[_0x1f489b('0x22')],_0x420bec=_0x3c9354[_0x1f489b('0x34')];let _0x500a6f=_0x3c9354['offset']+_0x3c9354[_0x1f489b('0xa')],_0x5e3b1c;return _0x500a6f>=_0x224f7c?(_0x500a6f=_0x224f7c,_0x5e3b1c=0xc8):_0x5e3b1c=0xce,_0x291340[_0x1f489b('0x7')](_0x5e3b1c),_0x291340[_0x1f489b('0x18')](_0x1f489b('0x4'),_0x420bec+'-'+_0x500a6f+'/'+_0x224f7c)[_0x1f489b('0x23')](_0x1adca5);}return null;};}function saveUpdates(_0x123d26){return function(_0x5a1180){const _0x3004f8=a47_0x563b;if(_0x5a1180)return _0x5a1180[_0x3004f8('0x21')](_0x123d26)[_0x3004f8('0x12')](function(_0x13c10f){return _0x13c10f;});return null;};}function removeEntity(_0x750188){return function(_0xd13f4c){const _0x346803=a47_0x563b;if(_0xd13f4c)return _0xd13f4c['destroy']()[_0x346803('0x12')](function(){const _0x594337=_0x346803,_0x51bdb9=_0xd13f4c[_0x594337('0x28')]({'plain':!![]}),_0x59948f='CannedAnswers';return db['UserProfileResource'][_0x594337('0x30')]({'where':{'type':_0x59948f,'resourceId':_0x51bdb9['id']}})[_0x594337('0x12')](function(){return _0xd13f4c;});})['then'](function(){const _0x10d08e=_0x346803;_0x750188[_0x10d08e('0x7')](0xcc)['end']();});};}function handleEntityNotFound(_0x315f45){return function(_0x39552f){const _0x134f34=a47_0x563b;return!_0x39552f&&_0x315f45[_0x134f34('0x16')](0x194),_0x39552f;};}function handleError(_0x2bfde3,_0x437d59){return _0x437d59=_0x437d59||0x1f4,function(_0x718016){const _0x24a634=a47_0x563b;logger[_0x24a634('0x13')](_0x718016[_0x24a634('0x1b')]),_0x718016['name']&&delete _0x718016[_0x24a634('0x38')],_0x2bfde3[_0x24a634('0x7')](_0x437d59)[_0x24a634('0xf')](_0x718016);};}exports['index']=function(_0x76c4a2,_0x13a38c){const _0x2955cc=_0x292173;let _0x16cef2={};const _0x5b17dc={},_0x4acb36={'count':0x0,'rows':[]},_0xe8b4d6=_['map'](db['CannedAnswer']['rawAttributes'],function(_0x5ae76b){const _0x266ff5=a47_0x563b;return{'name':_0x5ae76b[_0x266ff5('0x3')],'type':_0x5ae76b[_0x266ff5('0x2c')]['key']};});_0x5b17dc[_0x2955cc('0x39')]=_[_0x2955cc('0x35')](_0xe8b4d6,_0x2955cc('0x38')),_0x5b17dc[_0x2955cc('0x20')]=_[_0x2955cc('0x37')](_0x76c4a2[_0x2955cc('0x20')]),_0x5b17dc['filters']=_['intersection'](_0x5b17dc['model'],_0x5b17dc[_0x2955cc('0x20')]),_0x16cef2['attributes']=_[_0x2955cc('0x17')](_0x5b17dc[_0x2955cc('0x39')],qs[_0x2955cc('0x33')](_0x76c4a2['query'][_0x2955cc('0x33')])),_0x16cef2['attributes']=_0x16cef2[_0x2955cc('0x19')][_0x2955cc('0x2b')]?_0x16cef2[_0x2955cc('0x19')]:_0x5b17dc['model'];typeof _0x76c4a2[_0x2955cc('0x20')][_0x2955cc('0x6')]===_0x2955cc('0x2a')&&(_0x16cef2[_0x2955cc('0xa')]=qs[_0x2955cc('0xa')](_0x76c4a2['query'][_0x2955cc('0xa')]),_0x16cef2['offset']=qs[_0x2955cc('0x34')](_0x76c4a2[_0x2955cc('0x20')]['offset']));_0x16cef2[_0x2955cc('0x32')]=qs[_0x2955cc('0x3a')](_0x76c4a2[_0x2955cc('0x20')][_0x2955cc('0x3a')]),_0x16cef2[_0x2955cc('0x0')]=qs[_0x2955cc('0xb')](_['pick'](_0x76c4a2[_0x2955cc('0x20')],_0x5b17dc[_0x2955cc('0xb')]),_0xe8b4d6);_0x76c4a2[_0x2955cc('0x20')]['filter']&&(_0x16cef2[_0x2955cc('0x0')]=_[_0x2955cc('0x2f')](_0x16cef2['where'],{[Op['or']]:_[_0x2955cc('0x35')](_0xe8b4d6,function(_0x27f8fb){const _0x4d9e3e=_0x2955cc;if(_0x27f8fb[_0x4d9e3e('0x2c')]!==_0x4d9e3e('0x1d')){const _0x64c163={};return _0x64c163[_0x27f8fb[_0x4d9e3e('0x38')]]={[Op['like']]:'%'+_0x76c4a2[_0x4d9e3e('0x20')][_0x4d9e3e('0x5')]+'%'},_0x64c163;}})}));_0x16cef2=_[_0x2955cc('0x2f')]({},_0x16cef2,_0x76c4a2['options']);const _0x5a7c29={'where':_0x16cef2[_0x2955cc('0x0')]};return db[_0x2955cc('0x26')][_0x2955cc('0x22')](_0x5a7c29)[_0x2955cc('0x12')](function(_0x4da50e){const _0x262510=_0x2955cc;return _0x4acb36[_0x262510('0x22')]=_0x4da50e,_0x76c4a2[_0x262510('0x20')][_0x262510('0xe')]&&(_0x16cef2['include']=[{'all':!![]}]),db[_0x262510('0x26')][_0x262510('0x1')](_0x16cef2);})[_0x2955cc('0x12')](function(_0x521a28){return _0x4acb36['rows']=_0x521a28,_0x4acb36;})[_0x2955cc('0x12')](respondWithFilteredResult(_0x13a38c,_0x16cef2))[_0x2955cc('0x15')](handleError(_0x13a38c,null));},exports['show']=function(_0x5540a7,_0x18bf32){const _0x3c157a=_0x292173;let _0x53e821={'raw':!![],'where':{'id':_0x5540a7[_0x3c157a('0x2')]['id']}};const _0x505fb2={};return _0x505fb2['model']=_[_0x3c157a('0x37')](db[_0x3c157a('0x26')][_0x3c157a('0x36')]),_0x505fb2[_0x3c157a('0x20')]=_['keys'](_0x5540a7['query']),_0x505fb2[_0x3c157a('0xb')]=_[_0x3c157a('0x17')](_0x505fb2['model'],_0x505fb2[_0x3c157a('0x20')]),_0x53e821[_0x3c157a('0x19')]=_[_0x3c157a('0x17')](_0x505fb2[_0x3c157a('0x39')],qs['fields'](_0x5540a7[_0x3c157a('0x20')]['fields'])),_0x53e821[_0x3c157a('0x19')]=_0x53e821[_0x3c157a('0x19')][_0x3c157a('0x2b')]?_0x53e821[_0x3c157a('0x19')]:_0x505fb2[_0x3c157a('0x39')],_0x5540a7[_0x3c157a('0x20')][_0x3c157a('0xe')]&&(_0x53e821['include']=[{'all':!![]}]),_0x53e821=_[_0x3c157a('0x2f')]({},_0x53e821,_0x5540a7[_0x3c157a('0x27')]),db['CannedAnswer'][_0x3c157a('0x9')](_0x53e821)['then'](handleEntityNotFound(_0x18bf32,null))[_0x3c157a('0x12')](respondWithResult(_0x18bf32,null))[_0x3c157a('0x15')](handleError(_0x18bf32,null));},exports[_0x292173('0x21')]=function(_0x2af1e6,_0x17b89a){const _0xc78de8=_0x292173;return _0x2af1e6[_0xc78de8('0x31')]['id']&&delete _0x2af1e6['body']['id'],db['CannedAnswer']['findOne']({'where':{'id':_0x2af1e6[_0xc78de8('0x2')]['id']}})[_0xc78de8('0x12')](handleEntityNotFound(_0x17b89a,null))['then'](saveUpdates(_0x2af1e6[_0xc78de8('0x31')],null))['then'](respondWithResult(_0x17b89a,null))[_0xc78de8('0x15')](handleError(_0x17b89a,null));},exports['destroy']=function(_0x4f3ae3,_0x1375e2){const _0x129c98=_0x292173;return db[_0x129c98('0x26')]['findOne']({'where':{'id':_0x4f3ae3['params']['id']}})['then'](handleEntityNotFound(_0x1375e2,null))['then'](removeEntity(_0x1375e2,null))['catch'](handleError(_0x1375e2,null));},exports[_0x292173('0x24')]=function(_0x1a1504,_0x2c2fc2){const _0x4cd663=_0x292173,_0x5d7b6b={'key':_0x1a1504[_0x4cd663('0x31')]['key']};if(_0x1a1504[_0x4cd663('0x31')][_0x4cd663('0x8')])_0x5d7b6b[_0x4cd663('0x8')]=_0x1a1504[_0x4cd663('0x31')][_0x4cd663('0x8')];else{if(_0x1a1504[_0x4cd663('0x31')][_0x4cd663('0x1f')])_0x5d7b6b[_0x4cd663('0x1f')]=_0x1a1504[_0x4cd663('0x31')][_0x4cd663('0x1f')];else{if(_0x1a1504[_0x4cd663('0x31')]['OpenchannelAccountId'])_0x5d7b6b[_0x4cd663('0x25')]=_0x1a1504[_0x4cd663('0x31')][_0x4cd663('0x25')];else _0x1a1504[_0x4cd663('0x31')][_0x4cd663('0x1e')]&&(_0x5d7b6b[_0x4cd663('0x1e')]=_0x1a1504[_0x4cd663('0x31')][_0x4cd663('0x1e')]);}}return db[_0x4cd663('0x26')][_0x4cd663('0x9')]({'where':_0x5d7b6b})['then'](function(_0x9106b4){const _0x761ed5=_0x4cd663;if(_0x9106b4)throw new ValidationError(_0x761ed5('0x11'));return db[_0x761ed5('0x26')][_0x761ed5('0x24')](_0x1a1504[_0x761ed5('0x31')]);})['then'](function(_0xa247a5){const _0x1a2fb8=_0x4cd663,_0x45cb55=_0x1a1504[_0x1a2fb8('0x2d')]['get']({'plain':!![]});if(!_0x45cb55)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x45cb55['role']===_0x1a2fb8('0x2d')){const _0x46f2a3=_0xa247a5[_0x1a2fb8('0x28')]({'plain':!![]});return db['UserProfileSection'][_0x1a2fb8('0x9')]({'where':{'name':_0x1a2fb8('0x1c'),'userProfileId':_0x45cb55[_0x1a2fb8('0x14')]},'raw':!![]})[_0x1a2fb8('0x12')](function(_0x1297f2){const _0x6ed25b=_0x1a2fb8;return _0x1297f2&&_0x1297f2[_0x6ed25b('0xd')]===0x0?db['UserProfileResource'][_0x6ed25b('0x24')]({'name':_0x46f2a3[_0x6ed25b('0x38')],'resourceId':_0x46f2a3['id'],'type':_0x1297f2['name'],'sectionId':_0x1297f2['id']},{})[_0x6ed25b('0x12')](function(){return _0xa247a5;}):_0xa247a5;})[_0x1a2fb8('0x15')](function(_0x5d93b3){const _0x34f823=_0x1a2fb8;logger[_0x34f823('0x13')](_0x34f823('0x10'),_0x5d93b3);throw _0x5d93b3;});}return _0xa247a5;})[_0x4cd663('0x12')](respondWithResult(_0x2c2fc2,0xc9))[_0x4cd663('0x15')](handleError(_0x2c2fc2,null));};
\ No newline at end of file
+const a47_0xb83a=['lodash','SmsAccountId','like','query','catch','limit','../../mysqldb','get','UserProfileResource','includeAll','attributes','VIRTUAL','type','options','length','count','pick','stack','keys','findAll','OpenchannelAccountId','undefined','set','user','role','CannedAnswer','MailAccountId','Content-Range','show','../../components/parsers/qs','UserProfileSection','fields','json','name','filters','merge','CannedAnswers','destroy','sort','status','sequelize','map','ChatWebsiteId','api','body','model','Unable\x20to\x20retrieve\x20the\x20current\x20user','create','order','rawAttributes','include','where','../../config/logger','error','offset','intersection','filter','send','findOne','then','autoAssociation','end','nolimit','params'];(function(_0x5b34c0,_0xb83adf){const _0x555366=function(_0x28e484){while(--_0x28e484){_0x5b34c0['push'](_0x5b34c0['shift']());}};_0x555366(++_0xb83adf);}(a47_0xb83a,0x93));const a47_0x5553=function(_0x5b34c0,_0xb83adf){_0x5b34c0=_0x5b34c0-0x0;let _0x555366=a47_0xb83a[_0x5b34c0];return _0x555366;};const _0x1fb9f4=a47_0x5553;'use strict';const _=require(_0x1fb9f4('0x2d')),qs=require(_0x1fb9f4('0xa')),logger=require(_0x1fb9f4('0x21'))(_0x1fb9f4('0x18')),db=require(_0x1fb9f4('0x33'))['db'],{Op,ValidationError}=require(_0x1fb9f4('0x15'));function respondWithResult(_0x28e484,_0x58ea1e){return _0x58ea1e=_0x58ea1e||0xc8,function(_0x746257){const _0x35df76=a47_0x5553;if(_0x746257)return _0x28e484[_0x35df76('0x14')](_0x58ea1e)[_0x35df76('0xd')](_0x746257);};}function respondWithFilteredResult(_0xdf8c6b,_0x15b605){return function(_0x1670f7){const _0x118df6=a47_0x5553;if(_0x1670f7){const _0x361118=_0x1670f7[_0x118df6('0x3c')],_0x1b2f0b=_0x15b605[_0x118df6('0x23')];let _0x493513=_0x15b605[_0x118df6('0x23')]+_0x15b605[_0x118df6('0x32')],_0x2af152;return _0x493513>=_0x361118?(_0x493513=_0x361118,_0x2af152=0xc8):_0x2af152=0xce,_0xdf8c6b[_0x118df6('0x14')](_0x2af152),_0xdf8c6b[_0x118df6('0x3')](_0x118df6('0x8'),_0x1b2f0b+'-'+_0x493513+'/'+_0x361118)[_0x118df6('0xd')](_0x1670f7);}return null;};}function saveUpdates(_0x2c3798){return function(_0x3613b7){const _0x2e41ea=a47_0x5553;if(_0x3613b7)return _0x3613b7['update'](_0x2c3798)[_0x2e41ea('0x28')](function(_0x402b1f){return _0x402b1f;});return null;};}function removeEntity(_0x5f46ad){return function(_0x127e5e){const _0x589965=a47_0x5553;if(_0x127e5e)return _0x127e5e[_0x589965('0x12')]()[_0x589965('0x28')](function(){const _0x474a12=_0x589965,_0x215b0d=_0x127e5e[_0x474a12('0x34')]({'plain':!![]}),_0x275cab=_0x474a12('0x11');return db[_0x474a12('0x35')][_0x474a12('0x12')]({'where':{'type':_0x275cab,'resourceId':_0x215b0d['id']}})['then'](function(){return _0x127e5e;});})[_0x589965('0x28')](function(){const _0x1c21b6=_0x589965;_0x5f46ad[_0x1c21b6('0x14')](0xcc)[_0x1c21b6('0x2a')]();});};}function handleEntityNotFound(_0x2bc8d0){return function(_0x4d3e01){return!_0x4d3e01&&_0x2bc8d0['sendStatus'](0x194),_0x4d3e01;};}function handleError(_0x5db265,_0x3be8cf){return _0x3be8cf=_0x3be8cf||0x1f4,function(_0x558c93){const _0x43ecd9=a47_0x5553;logger[_0x43ecd9('0x22')](_0x558c93[_0x43ecd9('0x3e')]),_0x558c93[_0x43ecd9('0xe')]&&delete _0x558c93[_0x43ecd9('0xe')],_0x5db265[_0x43ecd9('0x14')](_0x3be8cf)[_0x43ecd9('0x26')](_0x558c93);};}exports['index']=function(_0x5be238,_0x3eb494){const _0xc9fb26=_0x1fb9f4;let _0x53ca44={};const _0x4135cc={},_0x2cc2b3={'count':0x0,'rows':[]},_0x5d9a71=_['map'](db['CannedAnswer'][_0xc9fb26('0x1e')],function(_0x3dcdb9){const _0x38da03=_0xc9fb26;return{'name':_0x3dcdb9['fieldName'],'type':_0x3dcdb9[_0x38da03('0x39')]['key']};});_0x4135cc['model']=_[_0xc9fb26('0x16')](_0x5d9a71,_0xc9fb26('0xe')),_0x4135cc['query']=_[_0xc9fb26('0x3f')](_0x5be238[_0xc9fb26('0x30')]),_0x4135cc[_0xc9fb26('0xf')]=_[_0xc9fb26('0x24')](_0x4135cc['model'],_0x4135cc['query']),_0x53ca44[_0xc9fb26('0x37')]=_[_0xc9fb26('0x24')](_0x4135cc[_0xc9fb26('0x1a')],qs[_0xc9fb26('0xc')](_0x5be238['query'][_0xc9fb26('0xc')])),_0x53ca44['attributes']=_0x53ca44[_0xc9fb26('0x37')][_0xc9fb26('0x3b')]?_0x53ca44[_0xc9fb26('0x37')]:_0x4135cc['model'];typeof _0x5be238[_0xc9fb26('0x30')][_0xc9fb26('0x2b')]===_0xc9fb26('0x2')&&(_0x53ca44[_0xc9fb26('0x32')]=qs[_0xc9fb26('0x32')](_0x5be238[_0xc9fb26('0x30')][_0xc9fb26('0x32')]),_0x53ca44[_0xc9fb26('0x23')]=qs['offset'](_0x5be238['query'][_0xc9fb26('0x23')]));_0x53ca44[_0xc9fb26('0x1d')]=qs[_0xc9fb26('0x13')](_0x5be238[_0xc9fb26('0x30')]['sort']),_0x53ca44[_0xc9fb26('0x20')]=qs[_0xc9fb26('0xf')](_[_0xc9fb26('0x3d')](_0x5be238[_0xc9fb26('0x30')],_0x4135cc['filters']),_0x5d9a71);_0x5be238[_0xc9fb26('0x30')][_0xc9fb26('0x25')]&&(_0x53ca44[_0xc9fb26('0x20')]=_[_0xc9fb26('0x10')](_0x53ca44[_0xc9fb26('0x20')],{[Op['or']]:_[_0xc9fb26('0x16')](_0x5d9a71,function(_0x4a4f1d){const _0x334455=_0xc9fb26;if(_0x4a4f1d[_0x334455('0x39')]!==_0x334455('0x38')){const _0x37577e={};return _0x37577e[_0x4a4f1d[_0x334455('0xe')]]={[Op[_0x334455('0x2f')]]:'%'+_0x5be238[_0x334455('0x30')]['filter']+'%'},_0x37577e;}})}));_0x53ca44=_[_0xc9fb26('0x10')]({},_0x53ca44,_0x5be238[_0xc9fb26('0x3a')]);const _0x2c27e3={'where':_0x53ca44[_0xc9fb26('0x20')]};return db['CannedAnswer']['count'](_0x2c27e3)['then'](function(_0x4bc04b){const _0x1f1c5b=_0xc9fb26;return _0x2cc2b3[_0x1f1c5b('0x3c')]=_0x4bc04b,_0x5be238['query'][_0x1f1c5b('0x36')]&&(_0x53ca44[_0x1f1c5b('0x1f')]=[{'all':!![]}]),db[_0x1f1c5b('0x6')][_0x1f1c5b('0x0')](_0x53ca44);})['then'](function(_0x314b4a){return _0x2cc2b3['rows']=_0x314b4a,_0x2cc2b3;})['then'](respondWithFilteredResult(_0x3eb494,_0x53ca44))[_0xc9fb26('0x31')](handleError(_0x3eb494,null));},exports[_0x1fb9f4('0x9')]=function(_0x4483ed,_0x4c7c54){const _0x29018b=_0x1fb9f4;let _0x4fe663={'raw':!![],'where':{'id':_0x4483ed[_0x29018b('0x2c')]['id']}};const _0x4271b9={};return _0x4271b9[_0x29018b('0x1a')]=_['keys'](db[_0x29018b('0x6')][_0x29018b('0x1e')]),_0x4271b9[_0x29018b('0x30')]=_[_0x29018b('0x3f')](_0x4483ed[_0x29018b('0x30')]),_0x4271b9[_0x29018b('0xf')]=_[_0x29018b('0x24')](_0x4271b9[_0x29018b('0x1a')],_0x4271b9[_0x29018b('0x30')]),_0x4fe663[_0x29018b('0x37')]=_[_0x29018b('0x24')](_0x4271b9[_0x29018b('0x1a')],qs[_0x29018b('0xc')](_0x4483ed[_0x29018b('0x30')]['fields'])),_0x4fe663[_0x29018b('0x37')]=_0x4fe663[_0x29018b('0x37')][_0x29018b('0x3b')]?_0x4fe663[_0x29018b('0x37')]:_0x4271b9[_0x29018b('0x1a')],_0x4483ed[_0x29018b('0x30')][_0x29018b('0x36')]&&(_0x4fe663[_0x29018b('0x1f')]=[{'all':!![]}]),_0x4fe663=_[_0x29018b('0x10')]({},_0x4fe663,_0x4483ed[_0x29018b('0x3a')]),db[_0x29018b('0x6')]['findOne'](_0x4fe663)[_0x29018b('0x28')](handleEntityNotFound(_0x4c7c54,null))[_0x29018b('0x28')](respondWithResult(_0x4c7c54,null))[_0x29018b('0x31')](handleError(_0x4c7c54,null));},exports['update']=function(_0x5c3c7b,_0x2a7c07){const _0x4edb9c=_0x1fb9f4;return _0x5c3c7b[_0x4edb9c('0x19')]['id']&&delete _0x5c3c7b[_0x4edb9c('0x19')]['id'],db[_0x4edb9c('0x6')]['findOne']({'where':{'id':_0x5c3c7b[_0x4edb9c('0x2c')]['id']}})[_0x4edb9c('0x28')](handleEntityNotFound(_0x2a7c07,null))[_0x4edb9c('0x28')](saveUpdates(_0x5c3c7b['body'],null))[_0x4edb9c('0x28')](respondWithResult(_0x2a7c07,null))['catch'](handleError(_0x2a7c07,null));},exports[_0x1fb9f4('0x12')]=function(_0x1cdb03,_0x2fd931){const _0x4a9b0b=_0x1fb9f4;return db[_0x4a9b0b('0x6')]['findOne']({'where':{'id':_0x1cdb03[_0x4a9b0b('0x2c')]['id']}})[_0x4a9b0b('0x28')](handleEntityNotFound(_0x2fd931,null))[_0x4a9b0b('0x28')](removeEntity(_0x2fd931,null))[_0x4a9b0b('0x31')](handleError(_0x2fd931,null));},exports['create']=function(_0x459f0e,_0x5b91a4){const _0xbd21e0=_0x1fb9f4,_0x154a80={'key':_0x459f0e[_0xbd21e0('0x19')]['key']};if(_0x459f0e[_0xbd21e0('0x19')][_0xbd21e0('0x7')])_0x154a80[_0xbd21e0('0x7')]=_0x459f0e[_0xbd21e0('0x19')][_0xbd21e0('0x7')];else{if(_0x459f0e[_0xbd21e0('0x19')][_0xbd21e0('0x2e')])_0x154a80[_0xbd21e0('0x2e')]=_0x459f0e[_0xbd21e0('0x19')][_0xbd21e0('0x2e')];else{if(_0x459f0e[_0xbd21e0('0x19')][_0xbd21e0('0x1')])_0x154a80[_0xbd21e0('0x1')]=_0x459f0e[_0xbd21e0('0x19')][_0xbd21e0('0x1')];else _0x459f0e[_0xbd21e0('0x19')][_0xbd21e0('0x17')]&&(_0x154a80[_0xbd21e0('0x17')]=_0x459f0e['body'][_0xbd21e0('0x17')]);}}return db[_0xbd21e0('0x6')]['findOne']({'where':_0x154a80})[_0xbd21e0('0x28')](function(_0x400b2f){const _0xb62bea=_0xbd21e0;if(_0x400b2f)throw new ValidationError('The\x20inserted\x20key\x20already\x20exists.');return db[_0xb62bea('0x6')][_0xb62bea('0x1c')](_0x459f0e['body']);})[_0xbd21e0('0x28')](function(_0x524b93){const _0x2ac11b=_0xbd21e0,_0x181cc6=_0x459f0e[_0x2ac11b('0x4')]['get']({'plain':!![]});if(!_0x181cc6)throw new Error(_0x2ac11b('0x1b'));if(_0x181cc6[_0x2ac11b('0x5')]==='user'){const _0x5d1df2=_0x524b93[_0x2ac11b('0x34')]({'plain':!![]});return db[_0x2ac11b('0xb')][_0x2ac11b('0x27')]({'where':{'name':'CannedAnswers','userProfileId':_0x181cc6['userProfileId']},'raw':!![]})[_0x2ac11b('0x28')](function(_0x2f645e){const _0x87b168=_0x2ac11b;return _0x2f645e&&_0x2f645e[_0x87b168('0x29')]===0x0?db[_0x87b168('0x35')][_0x87b168('0x1c')]({'name':_0x5d1df2['name'],'resourceId':_0x5d1df2['id'],'type':_0x2f645e[_0x87b168('0xe')],'sectionId':_0x2f645e['id']},{})[_0x87b168('0x28')](function(){return _0x524b93;}):_0x524b93;})[_0x2ac11b('0x31')](function(_0x239e19){const _0x457cec=_0x2ac11b;logger[_0x457cec('0x22')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x239e19);throw _0x239e19;});}return _0x524b93;})[_0xbd21e0('0x28')](respondWithResult(_0x5b91a4,0xc9))[_0xbd21e0('0x31')](handleError(_0x5b91a4,null));};
\ No newline at end of file