Built motion from commit df3e9871f6bcc3432fec345b2f4facbd4dba8b5c. Version 3.0.0...
[motion-next.git] / server / api / cannedAnswer / cannedAnswer.controller.js
index 123607d..7b7beea 100644 (file)
@@ -1 +1 @@
-const a47_0x1280=['CannedAnswers','findAll','update','UserProfileResource','api','sequelize','name','stack','limit','length','sendStatus','pick','user','status','../../config/logger','nolimit','end','sort','key','count','attributes','error','include','rawAttributes','catch','type','ChatWebsiteId','then','userProfileId','merge','rows','get','fieldName','query','params','Content-Range','where','SmsAccountId','includeAll','filter','options','autoAssociation','model','index','MailAccountId','fields','findOne','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','body','map','order','json','create','offset','lodash','send','OpenchannelAccountId','../../components/parsers/qs','set','CannedAnswer','like','filters','undefined','intersection'];(function(_0x3f4919,_0x128001){const _0x3084c8=function(_0x2e726e){while(--_0x2e726e){_0x3f4919['push'](_0x3f4919['shift']());}};_0x3084c8(++_0x128001);}(a47_0x1280,0x1f3));const a47_0x3084=function(_0x3f4919,_0x128001){_0x3f4919=_0x3f4919-0x0;let _0x3084c8=a47_0x1280[_0x3f4919];return _0x3084c8;};const _0x498961=a47_0x3084;'use strict';const _=require(_0x498961('0xb')),qs=require(_0x498961('0xe')),logger=require(_0x498961('0x23'))(_0x498961('0x19')),db=require('../../mysqldb')['db'],{Op,ValidationError}=require(_0x498961('0x1a'));function respondWithResult(_0x2e726e,_0x416171){return _0x416171=_0x416171||0xc8,function(_0x3b3c96){const _0x3bbbf8=a47_0x3084;if(_0x3b3c96)return _0x2e726e[_0x3bbbf8('0x22')](_0x416171)[_0x3bbbf8('0x8')](_0x3b3c96);};}function respondWithFilteredResult(_0x31235f,_0x1ec072){return function(_0x685106){const _0x44fec5=a47_0x3084;if(_0x685106){const _0x410808=_0x685106[_0x44fec5('0x28')],_0x2eb6e4=_0x1ec072['offset'];let _0x158577=_0x1ec072[_0x44fec5('0xa')]+_0x1ec072[_0x44fec5('0x1d')],_0x41ef1f;return _0x158577>=_0x410808?(_0x158577=_0x410808,_0x41ef1f=0xc8):_0x41ef1f=0xce,_0x31235f[_0x44fec5('0x22')](_0x41ef1f),_0x31235f[_0x44fec5('0xf')](_0x44fec5('0x38'),_0x2eb6e4+'-'+_0x158577+'/'+_0x410808)[_0x44fec5('0x8')](_0x685106);}return null;};}function saveUpdates(_0x3cee82){return function(_0x36697c){const _0x49c464=a47_0x3084;if(_0x36697c)return _0x36697c[_0x49c464('0x17')](_0x3cee82)['then'](function(_0x13ac08){return _0x13ac08;});return null;};}function removeEntity(_0x507cce){return function(_0x2f3bed){const _0x2ec987=a47_0x3084;if(_0x2f3bed)return _0x2f3bed['destroy']()[_0x2ec987('0x30')](function(){const _0x31a7d2=_0x2ec987,_0x4a7d57=_0x2f3bed[_0x31a7d2('0x34')]({'plain':!![]}),_0x594e74='CannedAnswers';return db['UserProfileResource']['destroy']({'where':{'type':_0x594e74,'resourceId':_0x4a7d57['id']}})['then'](function(){return _0x2f3bed;});})['then'](function(){const _0x35ae86=_0x2ec987;_0x507cce['status'](0xcc)[_0x35ae86('0x25')]();});};}function handleEntityNotFound(_0x42d200){return function(_0x363b4c){const _0x56c6b1=a47_0x3084;return!_0x363b4c&&_0x42d200[_0x56c6b1('0x1f')](0x194),_0x363b4c;};}function handleError(_0x40c0e1,_0x279cd6){return _0x279cd6=_0x279cd6||0x1f4,function(_0x46e306){const _0x264ec4=a47_0x3084;logger[_0x264ec4('0x2a')](_0x46e306[_0x264ec4('0x1c')]),_0x46e306['name']&&delete _0x46e306[_0x264ec4('0x1b')],_0x40c0e1[_0x264ec4('0x22')](_0x279cd6)[_0x264ec4('0xc')](_0x46e306);};}exports[_0x498961('0x40')]=function(_0x40d643,_0x1a5c63){const _0x33f861=_0x498961;let _0x522580={};const _0x3ca637={},_0x4e3d7c={'count':0x0,'rows':[]},_0x480877=_[_0x33f861('0x6')](db[_0x33f861('0x10')][_0x33f861('0x2c')],function(_0x1d022f){const _0x11dbf6=_0x33f861;return{'name':_0x1d022f[_0x11dbf6('0x35')],'type':_0x1d022f['type'][_0x11dbf6('0x27')]};});_0x3ca637[_0x33f861('0x3f')]=_[_0x33f861('0x6')](_0x480877,_0x33f861('0x1b')),_0x3ca637[_0x33f861('0x36')]=_['keys'](_0x40d643[_0x33f861('0x36')]),_0x3ca637['filters']=_[_0x33f861('0x14')](_0x3ca637[_0x33f861('0x3f')],_0x3ca637['query']),_0x522580[_0x33f861('0x29')]=_['intersection'](_0x3ca637[_0x33f861('0x3f')],qs['fields'](_0x40d643[_0x33f861('0x36')][_0x33f861('0x1')])),_0x522580['attributes']=_0x522580[_0x33f861('0x29')][_0x33f861('0x1e')]?_0x522580[_0x33f861('0x29')]:_0x3ca637[_0x33f861('0x3f')];typeof _0x40d643['query'][_0x33f861('0x24')]===_0x33f861('0x13')&&(_0x522580[_0x33f861('0x1d')]=qs[_0x33f861('0x1d')](_0x40d643['query'][_0x33f861('0x1d')]),_0x522580[_0x33f861('0xa')]=qs['offset'](_0x40d643[_0x33f861('0x36')][_0x33f861('0xa')]));_0x522580[_0x33f861('0x7')]=qs[_0x33f861('0x26')](_0x40d643['query'][_0x33f861('0x26')]),_0x522580[_0x33f861('0x39')]=qs['filters'](_[_0x33f861('0x20')](_0x40d643['query'],_0x3ca637[_0x33f861('0x12')]),_0x480877);_0x40d643[_0x33f861('0x36')][_0x33f861('0x3c')]&&(_0x522580[_0x33f861('0x39')]=_['merge'](_0x522580['where'],{[Op['or']]:_[_0x33f861('0x6')](_0x480877,function(_0x5da040){const _0x780d92=_0x33f861;if(_0x5da040[_0x780d92('0x2e')]!=='VIRTUAL'){const _0x4d462a={};return _0x4d462a[_0x5da040[_0x780d92('0x1b')]]={[Op[_0x780d92('0x11')]]:'%'+_0x40d643[_0x780d92('0x36')][_0x780d92('0x3c')]+'%'},_0x4d462a;}})}));_0x522580=_[_0x33f861('0x32')]({},_0x522580,_0x40d643[_0x33f861('0x3d')]);const _0x79d38b={'where':_0x522580['where']};return db['CannedAnswer'][_0x33f861('0x28')](_0x79d38b)['then'](function(_0x12d2de){const _0x2fd05c=_0x33f861;return _0x4e3d7c[_0x2fd05c('0x28')]=_0x12d2de,_0x40d643[_0x2fd05c('0x36')][_0x2fd05c('0x3b')]&&(_0x522580['include']=[{'all':!![]}]),db[_0x2fd05c('0x10')][_0x2fd05c('0x16')](_0x522580);})['then'](function(_0x33c063){const _0x1e9b36=_0x33f861;return _0x4e3d7c[_0x1e9b36('0x33')]=_0x33c063,_0x4e3d7c;})[_0x33f861('0x30')](respondWithFilteredResult(_0x1a5c63,_0x522580))[_0x33f861('0x2d')](handleError(_0x1a5c63,null));},exports['show']=function(_0x1c8e57,_0x545558){const _0x1269d3=_0x498961;let _0x4f1169={'raw':!![],'where':{'id':_0x1c8e57[_0x1269d3('0x37')]['id']}};const _0x335317={};return _0x335317[_0x1269d3('0x3f')]=_['keys'](db[_0x1269d3('0x10')][_0x1269d3('0x2c')]),_0x335317[_0x1269d3('0x36')]=_['keys'](_0x1c8e57[_0x1269d3('0x36')]),_0x335317[_0x1269d3('0x12')]=_[_0x1269d3('0x14')](_0x335317[_0x1269d3('0x3f')],_0x335317[_0x1269d3('0x36')]),_0x4f1169['attributes']=_['intersection'](_0x335317[_0x1269d3('0x3f')],qs[_0x1269d3('0x1')](_0x1c8e57[_0x1269d3('0x36')]['fields'])),_0x4f1169[_0x1269d3('0x29')]=_0x4f1169[_0x1269d3('0x29')][_0x1269d3('0x1e')]?_0x4f1169[_0x1269d3('0x29')]:_0x335317['model'],_0x1c8e57['query'][_0x1269d3('0x3b')]&&(_0x4f1169[_0x1269d3('0x2b')]=[{'all':!![]}]),_0x4f1169=_[_0x1269d3('0x32')]({},_0x4f1169,_0x1c8e57[_0x1269d3('0x3d')]),db[_0x1269d3('0x10')]['findOne'](_0x4f1169)[_0x1269d3('0x30')](handleEntityNotFound(_0x545558,null))[_0x1269d3('0x30')](respondWithResult(_0x545558,null))[_0x1269d3('0x2d')](handleError(_0x545558,null));},exports[_0x498961('0x17')]=function(_0x39ffb3,_0x231f43){const _0x59ded2=_0x498961;return _0x39ffb3['body']['id']&&delete _0x39ffb3[_0x59ded2('0x5')]['id'],db['CannedAnswer'][_0x59ded2('0x2')]({'where':{'id':_0x39ffb3['params']['id']}})[_0x59ded2('0x30')](handleEntityNotFound(_0x231f43,null))[_0x59ded2('0x30')](saveUpdates(_0x39ffb3['body'],null))[_0x59ded2('0x30')](respondWithResult(_0x231f43,null))[_0x59ded2('0x2d')](handleError(_0x231f43,null));},exports['destroy']=function(_0x331b92,_0x1c5312){const _0x30510a=_0x498961;return db[_0x30510a('0x10')][_0x30510a('0x2')]({'where':{'id':_0x331b92[_0x30510a('0x37')]['id']}})[_0x30510a('0x30')](handleEntityNotFound(_0x1c5312,null))[_0x30510a('0x30')](removeEntity(_0x1c5312,null))[_0x30510a('0x2d')](handleError(_0x1c5312,null));},exports['create']=function(_0x4eda16,_0x3417bc){const _0x4a8f8c=_0x498961,_0x51b8cb={'key':_0x4eda16[_0x4a8f8c('0x5')][_0x4a8f8c('0x27')]};if(_0x4eda16[_0x4a8f8c('0x5')][_0x4a8f8c('0x0')])_0x51b8cb[_0x4a8f8c('0x0')]=_0x4eda16[_0x4a8f8c('0x5')][_0x4a8f8c('0x0')];else{if(_0x4eda16['body'][_0x4a8f8c('0x3a')])_0x51b8cb[_0x4a8f8c('0x3a')]=_0x4eda16[_0x4a8f8c('0x5')][_0x4a8f8c('0x3a')];else{if(_0x4eda16[_0x4a8f8c('0x5')]['OpenchannelAccountId'])_0x51b8cb[_0x4a8f8c('0xd')]=_0x4eda16[_0x4a8f8c('0x5')][_0x4a8f8c('0xd')];else _0x4eda16[_0x4a8f8c('0x5')]['ChatWebsiteId']&&(_0x51b8cb[_0x4a8f8c('0x2f')]=_0x4eda16[_0x4a8f8c('0x5')][_0x4a8f8c('0x2f')]);}}return db['CannedAnswer'][_0x4a8f8c('0x2')]({'where':_0x51b8cb})[_0x4a8f8c('0x30')](function(_0x30d78c){const _0x86ceec=_0x4a8f8c;if(_0x30d78c)throw new ValidationError('The\x20inserted\x20key\x20already\x20exists.');return db[_0x86ceec('0x10')][_0x86ceec('0x9')](_0x4eda16[_0x86ceec('0x5')]);})[_0x4a8f8c('0x30')](function(_0x132e0b){const _0x4bc7ab=_0x4a8f8c,_0x10fed5=_0x4eda16['user'][_0x4bc7ab('0x34')]({'plain':!![]});if(!_0x10fed5)throw new Error(_0x4bc7ab('0x3'));if(_0x10fed5['role']===_0x4bc7ab('0x21')){const _0x313e6e=_0x132e0b[_0x4bc7ab('0x34')]({'plain':!![]});return db[_0x4bc7ab('0x4')][_0x4bc7ab('0x2')]({'where':{'name':_0x4bc7ab('0x15'),'userProfileId':_0x10fed5[_0x4bc7ab('0x31')]},'raw':!![]})['then'](function(_0x39d522){const _0x27694d=_0x4bc7ab;return _0x39d522&&_0x39d522[_0x27694d('0x3e')]===0x0?db[_0x27694d('0x18')]['create']({'name':_0x313e6e[_0x27694d('0x1b')],'resourceId':_0x313e6e['id'],'type':_0x39d522['name'],'sectionId':_0x39d522['id']},{})['then'](function(){return _0x132e0b;}):_0x132e0b;})[_0x4bc7ab('0x2d')](function(_0x186022){logger['error']('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x186022);throw _0x186022;});}return _0x132e0b;})['then'](respondWithResult(_0x3417bc,0xc9))[_0x4a8f8c('0x2d')](handleError(_0x3417bc,null));};
\ No newline at end of file
+const a47_0x1483=['OpenchannelAccountId','rawAttributes','findAll','body','nolimit','CannedAnswers','user','key','sendStatus','offset','model','set','stack','status','UserProfileResource','index','name','../../components/parsers/qs','userProfileId','then','type','pick','undefined','json','CannedAnswer','map','MailAccountId','where','keys','SmsAccountId','update','destroy','sort','create','length','findOne','includeAll','fieldName','params','count','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','VIRTUAL','fields','query','api','merge','like','../../config/logger','include','limit','options','catch','send','intersection','error','UserProfileSection','filters','attributes','rows','ChatWebsiteId'];(function(_0x2ad763,_0x1483a3){const _0x3070e7=function(_0x274794){while(--_0x274794){_0x2ad763['push'](_0x2ad763['shift']());}};_0x3070e7(++_0x1483a3);}(a47_0x1483,0xfd));const a47_0x3070=function(_0x2ad763,_0x1483a3){_0x2ad763=_0x2ad763-0x0;let _0x3070e7=a47_0x1483[_0x2ad763];return _0x3070e7;};const _0x4d9275=a47_0x3070;'use strict';const _=require('lodash'),qs=require(_0x4d9275('0x8')),logger=require(_0x4d9275('0x27'))(_0x4d9275('0x24')),db=require('../../mysqldb')['db'],{Op,ValidationError}=require('sequelize');function respondWithResult(_0x274794,_0x55cc5a){return _0x55cc5a=_0x55cc5a||0xc8,function(_0xbfdf5){const _0x2613e2=a47_0x3070;if(_0xbfdf5)return _0x274794['status'](_0x55cc5a)[_0x2613e2('0xe')](_0xbfdf5);};}function respondWithFilteredResult(_0xe45aac,_0x24ddc8){return function(_0xffed26){const _0x83f2d9=a47_0x3070;if(_0xffed26){const _0x4e582f=_0xffed26['count'],_0x74caee=_0x24ddc8['offset'];let _0x4051f4=_0x24ddc8[_0x83f2d9('0x0')]+_0x24ddc8[_0x83f2d9('0x29')],_0x43c488;return _0x4051f4>=_0x4e582f?(_0x4051f4=_0x4e582f,_0x43c488=0xc8):_0x43c488=0xce,_0xe45aac[_0x83f2d9('0x4')](_0x43c488),_0xe45aac[_0x83f2d9('0x2')]('Content-Range',_0x74caee+'-'+_0x4051f4+'/'+_0x4e582f)[_0x83f2d9('0xe')](_0xffed26);}return null;};}function saveUpdates(_0x4a1530){return function(_0x527ad3){const _0x5ebf8d=a47_0x3070;if(_0x527ad3)return _0x527ad3[_0x5ebf8d('0x15')](_0x4a1530)[_0x5ebf8d('0xa')](function(_0x1c61a7){return _0x1c61a7;});return null;};}function removeEntity(_0x33403d){return function(_0x53f1aa){const _0x43803f=a47_0x3070;if(_0x53f1aa)return _0x53f1aa[_0x43803f('0x16')]()[_0x43803f('0xa')](function(){const _0x1f69fe=_0x43803f,_0x217196=_0x53f1aa[_0x1f69fe('0x1f')]({'plain':!![]}),_0x308c0e=_0x1f69fe('0x39');return db[_0x1f69fe('0x5')]['destroy']({'where':{'type':_0x308c0e,'resourceId':_0x217196['id']}})[_0x1f69fe('0xa')](function(){return _0x53f1aa;});})[_0x43803f('0xa')](function(){const _0x11c8b8=_0x43803f;_0x33403d[_0x11c8b8('0x4')](0xcc)['end']();});};}function handleEntityNotFound(_0x569258){return function(_0x37457a){const _0x349a0d=a47_0x3070;return!_0x37457a&&_0x569258[_0x349a0d('0x3c')](0x194),_0x37457a;};}function handleError(_0x336bee,_0x3bcabf){return _0x3bcabf=_0x3bcabf||0x1f4,function(_0x4dc412){const _0x12ac7c=a47_0x3070;logger[_0x12ac7c('0x2e')](_0x4dc412[_0x12ac7c('0x3')]),_0x4dc412[_0x12ac7c('0x7')]&&delete _0x4dc412['name'],_0x336bee[_0x12ac7c('0x4')](_0x3bcabf)[_0x12ac7c('0x2c')](_0x4dc412);};}exports[_0x4d9275('0x6')]=function(_0x7271b0,_0x469cb1){const _0xaad711=_0x4d9275;let _0x493fa6={};const _0x1299a4={},_0x488a8b={'count':0x0,'rows':[]},_0x159751=_['map'](db[_0xaad711('0xf')][_0xaad711('0x35')],function(_0x1e0722){const _0x2cfc97=_0xaad711;return{'name':_0x1e0722[_0x2cfc97('0x1c')],'type':_0x1e0722[_0x2cfc97('0xb')][_0x2cfc97('0x3b')]};});_0x1299a4[_0xaad711('0x1')]=_[_0xaad711('0x10')](_0x159751,_0xaad711('0x7')),_0x1299a4[_0xaad711('0x23')]=_['keys'](_0x7271b0[_0xaad711('0x23')]),_0x1299a4[_0xaad711('0x30')]=_[_0xaad711('0x2d')](_0x1299a4[_0xaad711('0x1')],_0x1299a4[_0xaad711('0x23')]),_0x493fa6[_0xaad711('0x31')]=_[_0xaad711('0x2d')](_0x1299a4[_0xaad711('0x1')],qs[_0xaad711('0x22')](_0x7271b0['query'][_0xaad711('0x22')])),_0x493fa6['attributes']=_0x493fa6['attributes'][_0xaad711('0x19')]?_0x493fa6[_0xaad711('0x31')]:_0x1299a4[_0xaad711('0x1')];typeof _0x7271b0[_0xaad711('0x23')][_0xaad711('0x38')]===_0xaad711('0xd')&&(_0x493fa6[_0xaad711('0x29')]=qs[_0xaad711('0x29')](_0x7271b0['query'][_0xaad711('0x29')]),_0x493fa6[_0xaad711('0x0')]=qs['offset'](_0x7271b0['query'][_0xaad711('0x0')]));_0x493fa6['order']=qs[_0xaad711('0x17')](_0x7271b0['query'][_0xaad711('0x17')]),_0x493fa6[_0xaad711('0x12')]=qs['filters'](_[_0xaad711('0xc')](_0x7271b0[_0xaad711('0x23')],_0x1299a4['filters']),_0x159751);_0x7271b0[_0xaad711('0x23')]['filter']&&(_0x493fa6[_0xaad711('0x12')]=_[_0xaad711('0x25')](_0x493fa6[_0xaad711('0x12')],{[Op['or']]:_['map'](_0x159751,function(_0x5d8ef0){const _0x318196=_0xaad711;if(_0x5d8ef0[_0x318196('0xb')]!==_0x318196('0x21')){const _0x105add={};return _0x105add[_0x5d8ef0[_0x318196('0x7')]]={[Op[_0x318196('0x26')]]:'%'+_0x7271b0[_0x318196('0x23')]['filter']+'%'},_0x105add;}})}));_0x493fa6=_[_0xaad711('0x25')]({},_0x493fa6,_0x7271b0['options']);const _0x47ddba={'where':_0x493fa6[_0xaad711('0x12')]};return db['CannedAnswer'][_0xaad711('0x1e')](_0x47ddba)[_0xaad711('0xa')](function(_0x2118ee){const _0x3bce4d=_0xaad711;return _0x488a8b[_0x3bce4d('0x1e')]=_0x2118ee,_0x7271b0['query'][_0x3bce4d('0x1b')]&&(_0x493fa6[_0x3bce4d('0x28')]=[{'all':!![]}]),db[_0x3bce4d('0xf')][_0x3bce4d('0x36')](_0x493fa6);})[_0xaad711('0xa')](function(_0xd67638){const _0x511448=_0xaad711;return _0x488a8b[_0x511448('0x32')]=_0xd67638,_0x488a8b;})[_0xaad711('0xa')](respondWithFilteredResult(_0x469cb1,_0x493fa6))[_0xaad711('0x2b')](handleError(_0x469cb1,null));},exports['show']=function(_0x4d014a,_0x2a995d){const _0x44d0d0=_0x4d9275;let _0x91117e={'raw':!![],'where':{'id':_0x4d014a[_0x44d0d0('0x1d')]['id']}};const _0x1d6668={};return _0x1d6668[_0x44d0d0('0x1')]=_[_0x44d0d0('0x13')](db[_0x44d0d0('0xf')][_0x44d0d0('0x35')]),_0x1d6668[_0x44d0d0('0x23')]=_[_0x44d0d0('0x13')](_0x4d014a['query']),_0x1d6668[_0x44d0d0('0x30')]=_[_0x44d0d0('0x2d')](_0x1d6668[_0x44d0d0('0x1')],_0x1d6668[_0x44d0d0('0x23')]),_0x91117e[_0x44d0d0('0x31')]=_[_0x44d0d0('0x2d')](_0x1d6668[_0x44d0d0('0x1')],qs[_0x44d0d0('0x22')](_0x4d014a[_0x44d0d0('0x23')][_0x44d0d0('0x22')])),_0x91117e[_0x44d0d0('0x31')]=_0x91117e[_0x44d0d0('0x31')][_0x44d0d0('0x19')]?_0x91117e[_0x44d0d0('0x31')]:_0x1d6668[_0x44d0d0('0x1')],_0x4d014a[_0x44d0d0('0x23')][_0x44d0d0('0x1b')]&&(_0x91117e[_0x44d0d0('0x28')]=[{'all':!![]}]),_0x91117e=_['merge']({},_0x91117e,_0x4d014a[_0x44d0d0('0x2a')]),db['CannedAnswer'][_0x44d0d0('0x1a')](_0x91117e)[_0x44d0d0('0xa')](handleEntityNotFound(_0x2a995d,null))['then'](respondWithResult(_0x2a995d,null))['catch'](handleError(_0x2a995d,null));},exports[_0x4d9275('0x15')]=function(_0x1e828b,_0xc9ade5){const _0x43504d=_0x4d9275;return _0x1e828b[_0x43504d('0x37')]['id']&&delete _0x1e828b['body']['id'],db['CannedAnswer'][_0x43504d('0x1a')]({'where':{'id':_0x1e828b['params']['id']}})[_0x43504d('0xa')](handleEntityNotFound(_0xc9ade5,null))[_0x43504d('0xa')](saveUpdates(_0x1e828b[_0x43504d('0x37')],null))[_0x43504d('0xa')](respondWithResult(_0xc9ade5,null))[_0x43504d('0x2b')](handleError(_0xc9ade5,null));},exports[_0x4d9275('0x16')]=function(_0x6073aa,_0x56a789){const _0xf472e2=_0x4d9275;return db[_0xf472e2('0xf')][_0xf472e2('0x1a')]({'where':{'id':_0x6073aa[_0xf472e2('0x1d')]['id']}})['then'](handleEntityNotFound(_0x56a789,null))['then'](removeEntity(_0x56a789,null))[_0xf472e2('0x2b')](handleError(_0x56a789,null));},exports['create']=function(_0x338241,_0x5aa087){const _0xa124a0=_0x4d9275,_0x8d967a={'key':_0x338241[_0xa124a0('0x37')][_0xa124a0('0x3b')]};if(_0x338241['body'][_0xa124a0('0x11')])_0x8d967a[_0xa124a0('0x11')]=_0x338241[_0xa124a0('0x37')][_0xa124a0('0x11')];else{if(_0x338241[_0xa124a0('0x37')][_0xa124a0('0x14')])_0x8d967a['SmsAccountId']=_0x338241['body']['SmsAccountId'];else{if(_0x338241[_0xa124a0('0x37')]['OpenchannelAccountId'])_0x8d967a[_0xa124a0('0x34')]=_0x338241[_0xa124a0('0x37')][_0xa124a0('0x34')];else _0x338241[_0xa124a0('0x37')]['ChatWebsiteId']&&(_0x8d967a[_0xa124a0('0x33')]=_0x338241[_0xa124a0('0x37')][_0xa124a0('0x33')]);}}return db['CannedAnswer'][_0xa124a0('0x1a')]({'where':_0x8d967a})[_0xa124a0('0xa')](function(_0x12a9bf){const _0x22cd64=_0xa124a0;if(_0x12a9bf)throw new ValidationError('The\x20inserted\x20key\x20already\x20exists.');return db['CannedAnswer'][_0x22cd64('0x18')](_0x338241[_0x22cd64('0x37')]);})[_0xa124a0('0xa')](function(_0x3e4b9f){const _0x562af8=_0xa124a0,_0x2f84d6=_0x338241[_0x562af8('0x3a')]['get']({'plain':!![]});if(!_0x2f84d6)throw new Error(_0x562af8('0x20'));if(_0x2f84d6['role']===_0x562af8('0x3a')){const _0x55400e=_0x3e4b9f['get']({'plain':!![]});return db[_0x562af8('0x2f')]['findOne']({'where':{'name':_0x562af8('0x39'),'userProfileId':_0x2f84d6[_0x562af8('0x9')]},'raw':!![]})[_0x562af8('0xa')](function(_0x48e72e){const _0x25692c=_0x562af8;return _0x48e72e&&_0x48e72e['autoAssociation']===0x0?db[_0x25692c('0x5')][_0x25692c('0x18')]({'name':_0x55400e['name'],'resourceId':_0x55400e['id'],'type':_0x48e72e[_0x25692c('0x7')],'sectionId':_0x48e72e['id']},{})[_0x25692c('0xa')](function(){return _0x3e4b9f;}):_0x3e4b9f;})[_0x562af8('0x2b')](function(_0x5514d7){const _0x27c95c=_0x562af8;logger[_0x27c95c('0x2e')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x5514d7);throw _0x5514d7;});}return _0x3e4b9f;})['then'](respondWithResult(_0x5aa087,0xc9))['catch'](handleError(_0x5aa087,null));};
\ No newline at end of file