Built motion from commit a8c4dd89.|2.6.33
[motion2.git] / server / api / cannedAnswer / cannedAnswer.controller.js
index 6b979ac..849e275 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb0d4=['findAll','catch','show','params','includeAll','include','find','body','create','MailAccountId','SmsAccountId','OpenchannelAccountId','ChatWebsiteId','Sequelize','ValidationError','The\x20inserted\x20key\x20already\x20exists.','user','UserProfileSection','userProfileId','autoAssociation','eml-format','rimraf','zip-dir','fast-json-patch','bluebird','util','path','ejs','fs-extra','lodash','squel','jsforce','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','status','end','json','undefined','limit','offset','count','set','Content-Range','apply','update','then','destroy','get','CannedAnswers','UserProfileResource','sendStatus','error','name','index','CannedAnswer','rawAttributes','fieldName','type','key','model','map','query','keys','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filters','filter','merge','options'];(function(_0x36da2a,_0x139b77){var _0x457b21=function(_0x36eba8){while(--_0x36eba8){_0x36da2a['push'](_0x36da2a['shift']());}};_0x457b21(++_0x139b77);}(_0xb0d4,0x6b));var _0x4b0d=function(_0x43478c,_0x434288){_0x43478c=_0x43478c-0x0;var _0xc4e333=_0xb0d4[_0x43478c];return _0xc4e333;};'use strict';var emlformat=require(_0x4b0d('0x0'));var rimraf=require(_0x4b0d('0x1'));var zipdir=require(_0x4b0d('0x2'));var jsonpatch=require(_0x4b0d('0x3'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x4b0d('0x4'));var Mustache=require('mustache');var util=require(_0x4b0d('0x5'));var path=require(_0x4b0d('0x6'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0x4b0d('0x7'));var fs=require('fs');var fs_extra=require(_0x4b0d('0x8'));var _=require(_0x4b0d('0x9'));var squel=require(_0x4b0d('0xa'));var crypto=require('crypto');var jsforce=require(_0x4b0d('0xb'));var deskjs=require('desk.js');var toCsv=require(_0x4b0d('0xc'));var querystring=require(_0x4b0d('0xd'));var Papa=require(_0x4b0d('0xe'));var Redis=require(_0x4b0d('0xf'));var authService=require(_0x4b0d('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0x4b0d('0x11'));var hardwareService=require(_0x4b0d('0x12'));var logger=require(_0x4b0d('0x13'))(_0x4b0d('0x14'));var utils=require(_0x4b0d('0x15'));var config=require(_0x4b0d('0x16'));var licenseUtil=require(_0x4b0d('0x17'));var db=require(_0x4b0d('0x18'))['db'];function respondWithStatusCode(_0x2ddbd0,_0x42b6a9){_0x42b6a9=_0x42b6a9||0xcc;return function(_0x2d115e){if(_0x2d115e){return _0x2ddbd0['sendStatus'](_0x42b6a9);}return _0x2ddbd0[_0x4b0d('0x19')](_0x42b6a9)[_0x4b0d('0x1a')]();};}function respondWithResult(_0x30ebe0,_0x2a1176){_0x2a1176=_0x2a1176||0xc8;return function(_0x5f3d66){if(_0x5f3d66){return _0x30ebe0[_0x4b0d('0x19')](_0x2a1176)[_0x4b0d('0x1b')](_0x5f3d66);}};}function respondWithFilteredResult(_0x16e233,_0x588f3c){return function(_0x533958){if(_0x533958){var _0x9705e7=typeof _0x588f3c['offset']===_0x4b0d('0x1c')&&typeof _0x588f3c[_0x4b0d('0x1d')]===_0x4b0d('0x1c');var _0x3ceaa1=_0x533958['count'];var _0x1d62ec=_0x9705e7?0x0:_0x588f3c[_0x4b0d('0x1e')];var _0x58962f=_0x9705e7?_0x533958[_0x4b0d('0x1f')]:_0x588f3c[_0x4b0d('0x1e')]+_0x588f3c['limit'];var _0x3a8e74;if(_0x58962f>=_0x3ceaa1){_0x58962f=_0x3ceaa1;_0x3a8e74=0xc8;}else{_0x3a8e74=0xce;}_0x16e233[_0x4b0d('0x19')](_0x3a8e74);return _0x16e233[_0x4b0d('0x20')](_0x4b0d('0x21'),_0x1d62ec+'-'+_0x58962f+'/'+_0x3ceaa1)['json'](_0x533958);}return null;};}function patchUpdates(_0x137aca){return function(_0x181d00){try{jsonpatch[_0x4b0d('0x22')](_0x181d00,_0x137aca,!![]);}catch(_0x3f18bb){return BPromise['reject'](_0x3f18bb);}return _0x181d00['save']();};}function saveUpdates(_0xc28ed4,_0x396f8d){return function(_0x1dd897){if(_0x1dd897){return _0x1dd897[_0x4b0d('0x23')](_0xc28ed4)[_0x4b0d('0x24')](function(_0x3265b0){return _0x3265b0;});}return null;};}function removeEntity(_0x29d44e,_0x17257e){return function(_0x2ffa5f){if(_0x2ffa5f){return _0x2ffa5f[_0x4b0d('0x25')]()[_0x4b0d('0x24')](function(){var _0x9ca288=_0x2ffa5f[_0x4b0d('0x26')]({'plain':!![]});var _0x260324=_0x4b0d('0x27');return db[_0x4b0d('0x28')][_0x4b0d('0x25')]({'where':{'type':_0x260324,'resourceId':_0x9ca288['id']}})[_0x4b0d('0x24')](function(){return _0x2ffa5f;});})[_0x4b0d('0x24')](function(){_0x29d44e[_0x4b0d('0x19')](0xcc)[_0x4b0d('0x1a')]();});}};}function handleEntityNotFound(_0xa63daa,_0x4ae6bb){return function(_0x5886cb){if(!_0x5886cb){_0xa63daa[_0x4b0d('0x29')](0x194);}return _0x5886cb;};}function handleError(_0x49001c,_0x6ae2f4){_0x6ae2f4=_0x6ae2f4||0x1f4;return function(_0x3fde6b){logger[_0x4b0d('0x2a')](_0x3fde6b['stack']);if(_0x3fde6b[_0x4b0d('0x2b')]){delete _0x3fde6b[_0x4b0d('0x2b')];}_0x49001c['status'](_0x6ae2f4)['send'](_0x3fde6b);};}exports[_0x4b0d('0x2c')]=function(_0x288b21,_0x144da8){var _0x53973b={},_0x43aaa8={},_0x2bcf41={'count':0x0,'rows':[]};var _0x490d0c=_['map'](db[_0x4b0d('0x2d')][_0x4b0d('0x2e')],function(_0x12a7bc){return{'name':_0x12a7bc[_0x4b0d('0x2f')],'type':_0x12a7bc[_0x4b0d('0x30')][_0x4b0d('0x31')]};});_0x43aaa8[_0x4b0d('0x32')]=_[_0x4b0d('0x33')](_0x490d0c,_0x4b0d('0x2b'));_0x43aaa8[_0x4b0d('0x34')]=_[_0x4b0d('0x35')](_0x288b21[_0x4b0d('0x34')]);_0x43aaa8['filters']=_[_0x4b0d('0x36')](_0x43aaa8[_0x4b0d('0x32')],_0x43aaa8[_0x4b0d('0x34')]);_0x53973b[_0x4b0d('0x37')]=_['intersection'](_0x43aaa8[_0x4b0d('0x32')],qs['fields'](_0x288b21['query'][_0x4b0d('0x38')]));_0x53973b['attributes']=_0x53973b['attributes'][_0x4b0d('0x39')]?_0x53973b[_0x4b0d('0x37')]:_0x43aaa8[_0x4b0d('0x32')];if(!_0x288b21[_0x4b0d('0x34')][_0x4b0d('0x3a')](_0x4b0d('0x3b'))){_0x53973b[_0x4b0d('0x1d')]=qs[_0x4b0d('0x1d')](_0x288b21['query'][_0x4b0d('0x1d')]);_0x53973b[_0x4b0d('0x1e')]=qs['offset'](_0x288b21['query'][_0x4b0d('0x1e')]);}_0x53973b[_0x4b0d('0x3c')]=qs[_0x4b0d('0x3d')](_0x288b21[_0x4b0d('0x34')][_0x4b0d('0x3d')]);_0x53973b[_0x4b0d('0x3e')]=qs[_0x4b0d('0x3f')](_['pick'](_0x288b21['query'],_0x43aaa8[_0x4b0d('0x3f')]),_0x490d0c);if(_0x288b21[_0x4b0d('0x34')][_0x4b0d('0x40')]){_0x53973b['where']=_[_0x4b0d('0x41')](_0x53973b['where'],{'$or':[{'key':{'$like':'%'+_0x288b21[_0x4b0d('0x34')][_0x4b0d('0x40')]+'%'}},{'value':{'$like':'%'+_0x288b21[_0x4b0d('0x34')][_0x4b0d('0x40')]+'%'}}]});}_0x53973b=_[_0x4b0d('0x41')]({},_0x53973b,_0x288b21[_0x4b0d('0x42')]);var _0xf8ab6d={'where':_0x53973b[_0x4b0d('0x3e')]};return db['CannedAnswer']['count'](_0xf8ab6d)[_0x4b0d('0x24')](function(_0x19edba){_0x2bcf41[_0x4b0d('0x1f')]=_0x19edba;if(_0x288b21[_0x4b0d('0x34')]['includeAll']){_0x53973b['include']=[{'all':!![]}];}return db[_0x4b0d('0x2d')][_0x4b0d('0x43')](_0x53973b);})[_0x4b0d('0x24')](function(_0x555139){_0x2bcf41['rows']=_0x555139;return _0x2bcf41;})['then'](respondWithFilteredResult(_0x144da8,_0x53973b))[_0x4b0d('0x44')](handleError(_0x144da8,null));};exports[_0x4b0d('0x45')]=function(_0x398db3,_0x324f62){var _0x4777b4={'raw':!![],'where':{'id':_0x398db3[_0x4b0d('0x46')]['id']}},_0x135d91={};_0x135d91[_0x4b0d('0x32')]=_[_0x4b0d('0x35')](db[_0x4b0d('0x2d')][_0x4b0d('0x2e')]);_0x135d91[_0x4b0d('0x34')]=_['keys'](_0x398db3['query']);_0x135d91[_0x4b0d('0x3f')]=_['intersection'](_0x135d91[_0x4b0d('0x32')],_0x135d91['query']);_0x4777b4[_0x4b0d('0x37')]=_[_0x4b0d('0x36')](_0x135d91[_0x4b0d('0x32')],qs[_0x4b0d('0x38')](_0x398db3[_0x4b0d('0x34')][_0x4b0d('0x38')]));_0x4777b4[_0x4b0d('0x37')]=_0x4777b4[_0x4b0d('0x37')][_0x4b0d('0x39')]?_0x4777b4['attributes']:_0x135d91[_0x4b0d('0x32')];if(_0x398db3[_0x4b0d('0x34')][_0x4b0d('0x47')]){_0x4777b4[_0x4b0d('0x48')]=[{'all':!![]}];}_0x4777b4=_[_0x4b0d('0x41')]({},_0x4777b4,_0x398db3[_0x4b0d('0x42')]);return db[_0x4b0d('0x2d')][_0x4b0d('0x49')](_0x4777b4)['then'](handleEntityNotFound(_0x324f62,null))[_0x4b0d('0x24')](respondWithResult(_0x324f62,null))['catch'](handleError(_0x324f62,null));};exports[_0x4b0d('0x23')]=function(_0x4a6d5f,_0x233b8a){if(_0x4a6d5f[_0x4b0d('0x4a')]['id']){delete _0x4a6d5f['body']['id'];}return db[_0x4b0d('0x2d')]['find']({'where':{'id':_0x4a6d5f[_0x4b0d('0x46')]['id']}})[_0x4b0d('0x24')](handleEntityNotFound(_0x233b8a,null))['then'](saveUpdates(_0x4a6d5f[_0x4b0d('0x4a')],null))['then'](respondWithResult(_0x233b8a,null))['catch'](handleError(_0x233b8a,null));};exports[_0x4b0d('0x25')]=function(_0x4e0e63,_0x4c753e){return db[_0x4b0d('0x2d')]['find']({'where':{'id':_0x4e0e63[_0x4b0d('0x46')]['id']}})[_0x4b0d('0x24')](handleEntityNotFound(_0x4c753e,null))['then'](removeEntity(_0x4c753e,null))[_0x4b0d('0x44')](handleError(_0x4c753e,null));};exports[_0x4b0d('0x4b')]=function(_0x21b94b,_0x11ece5){var _0x3f2d5b={'key':_0x21b94b[_0x4b0d('0x4a')]['key']};if(_0x21b94b['body'][_0x4b0d('0x4c')]){_0x3f2d5b['MailAccountId']=_0x21b94b[_0x4b0d('0x4a')][_0x4b0d('0x4c')];}else if(_0x21b94b[_0x4b0d('0x4a')][_0x4b0d('0x4d')]){_0x3f2d5b[_0x4b0d('0x4d')]=_0x21b94b[_0x4b0d('0x4a')]['SmsAccountId'];}else if(_0x21b94b['body'][_0x4b0d('0x4e')]){_0x3f2d5b[_0x4b0d('0x4e')]=_0x21b94b[_0x4b0d('0x4a')]['OpenchannelAccountId'];}else if(_0x21b94b[_0x4b0d('0x4a')][_0x4b0d('0x4f')]){_0x3f2d5b[_0x4b0d('0x4f')]=_0x21b94b[_0x4b0d('0x4a')]['ChatWebsiteId'];}return db['CannedAnswer'][_0x4b0d('0x49')]({'where':_0x3f2d5b})[_0x4b0d('0x24')](function(_0x54cba3){if(_0x54cba3){throw new db[(_0x4b0d('0x50'))][(_0x4b0d('0x51'))](_0x4b0d('0x52'));}return db[_0x4b0d('0x2d')][_0x4b0d('0x4b')](_0x21b94b[_0x4b0d('0x4a')]);})[_0x4b0d('0x24')](function(_0x1ef938){var _0x5add18=_0x21b94b[_0x4b0d('0x53')][_0x4b0d('0x26')]({'plain':!![]});if(!_0x5add18)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x5add18['role']===_0x4b0d('0x53')){var _0x592674=_0x1ef938[_0x4b0d('0x26')]({'plain':!![]});return db[_0x4b0d('0x54')][_0x4b0d('0x49')]({'where':{'name':_0x4b0d('0x27'),'userProfileId':_0x5add18[_0x4b0d('0x55')]},'raw':!![]})[_0x4b0d('0x24')](function(_0x3681d8){if(_0x3681d8&&_0x3681d8[_0x4b0d('0x56')]===0x0){return db[_0x4b0d('0x28')][_0x4b0d('0x4b')]({'name':_0x592674[_0x4b0d('0x2b')],'resourceId':_0x592674['id'],'type':_0x3681d8[_0x4b0d('0x2b')],'sectionId':_0x3681d8['id']},{})[_0x4b0d('0x24')](function(){return _0x1ef938;});}else{return _0x1ef938;}})[_0x4b0d('0x44')](function(_0x79ab38){logger[_0x4b0d('0x2a')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x79ab38);throw _0x79ab38;});}return _0x1ef938;})['then'](respondWithResult(_0x11ece5,0xc9))[_0x4b0d('0x44')](handleError(_0x11ece5,null));};
\ No newline at end of file
+var _0x69f7=['eml-format','rimraf','zip-dir','fast-json-patch','moment','mustache','util','path','sox','ejs','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','end','status','undefined','limit','count','offset','set','Content-Range','apply','update','destroy','then','get','CannedAnswers','UserProfileResource','stack','name','send','index','map','CannedAnswer','rawAttributes','type','key','keys','query','model','attributes','intersection','fields','length','hasOwnProperty','order','sort','where','filters','filter','merge','includeAll','include','findAll','rows','catch','show','params','options','find','body','create','MailAccountId','SmsAccountId','OpenchannelAccountId','ChatWebsiteId','Sequelize','ValidationError','The\x20inserted\x20key\x20already\x20exists.','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','UserProfileSection','userProfileId','autoAssociation','error'];(function(_0x5272e0,_0x169ce5){var _0xa4fc96=function(_0x4f359a){while(--_0x4f359a){_0x5272e0['push'](_0x5272e0['shift']());}};_0xa4fc96(++_0x169ce5);}(_0x69f7,0x10b));var _0x769f=function(_0x2b5520,_0x2d77b4){_0x2b5520=_0x2b5520-0x0;var _0x5873db=_0x69f7[_0x2b5520];return _0x5873db;};'use strict';var emlformat=require(_0x769f('0x0'));var rimraf=require(_0x769f('0x1'));var zipdir=require(_0x769f('0x2'));var jsonpatch=require(_0x769f('0x3'));var rp=require('request-promise');var moment=require(_0x769f('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x769f('0x5'));var util=require(_0x769f('0x6'));var path=require(_0x769f('0x7'));var sox=require(_0x769f('0x8'));var csv=require('to-csv');var ejs=require(_0x769f('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0x769f('0xa'));var crypto=require(_0x769f('0xb'));var jsforce=require(_0x769f('0xc'));var deskjs=require(_0x769f('0xd'));var toCsv=require('to-csv');var querystring=require(_0x769f('0xe'));var Papa=require(_0x769f('0xf'));var Redis=require(_0x769f('0x10'));var authService=require('../../components/auth/service');var qs=require(_0x769f('0x11'));var as=require(_0x769f('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x769f('0x13'))(_0x769f('0x14'));var utils=require(_0x769f('0x15'));var config=require(_0x769f('0x16'));var licenseUtil=require(_0x769f('0x17'));var db=require(_0x769f('0x18'))['db'];function respondWithStatusCode(_0x31e7b8,_0x41c336){_0x41c336=_0x41c336||0xcc;return function(_0x4145cd){if(_0x4145cd){return _0x31e7b8[_0x769f('0x19')](_0x41c336);}return _0x31e7b8['status'](_0x41c336)[_0x769f('0x1a')]();};}function respondWithResult(_0x4a4f09,_0x5e4857){_0x5e4857=_0x5e4857||0xc8;return function(_0x12aa50){if(_0x12aa50){return _0x4a4f09[_0x769f('0x1b')](_0x5e4857)['json'](_0x12aa50);}};}function respondWithFilteredResult(_0x3d3279,_0x26ea7c){return function(_0x40074c){if(_0x40074c){var _0x45ba69=typeof _0x26ea7c['offset']===_0x769f('0x1c')&&typeof _0x26ea7c[_0x769f('0x1d')]==='undefined';var _0x2fc324=_0x40074c[_0x769f('0x1e')];var _0x49dacb=_0x45ba69?0x0:_0x26ea7c['offset'];var _0x47d7fd=_0x45ba69?_0x40074c[_0x769f('0x1e')]:_0x26ea7c[_0x769f('0x1f')]+_0x26ea7c[_0x769f('0x1d')];var _0x4a1b81;if(_0x47d7fd>=_0x2fc324){_0x47d7fd=_0x2fc324;_0x4a1b81=0xc8;}else{_0x4a1b81=0xce;}_0x3d3279['status'](_0x4a1b81);return _0x3d3279[_0x769f('0x20')](_0x769f('0x21'),_0x49dacb+'-'+_0x47d7fd+'/'+_0x2fc324)['json'](_0x40074c);}return null;};}function patchUpdates(_0x47e6a6){return function(_0x9ebcdd){try{jsonpatch[_0x769f('0x22')](_0x9ebcdd,_0x47e6a6,!![]);}catch(_0x74a59f){return BPromise['reject'](_0x74a59f);}return _0x9ebcdd['save']();};}function saveUpdates(_0x372dc7,_0x1d30eb){return function(_0x5f2197){if(_0x5f2197){return _0x5f2197[_0x769f('0x23')](_0x372dc7)['then'](function(_0x2bae5e){return _0x2bae5e;});}return null;};}function removeEntity(_0x427d26,_0x37592a){return function(_0x47774e){if(_0x47774e){return _0x47774e[_0x769f('0x24')]()[_0x769f('0x25')](function(){var _0x35a90d=_0x47774e[_0x769f('0x26')]({'plain':!![]});var _0x323f6c=_0x769f('0x27');return db[_0x769f('0x28')][_0x769f('0x24')]({'where':{'type':_0x323f6c,'resourceId':_0x35a90d['id']}})[_0x769f('0x25')](function(){return _0x47774e;});})[_0x769f('0x25')](function(){_0x427d26[_0x769f('0x1b')](0xcc)[_0x769f('0x1a')]();});}};}function handleEntityNotFound(_0x5c7b46,_0x3f056){return function(_0x33bb7c){if(!_0x33bb7c){_0x5c7b46[_0x769f('0x19')](0x194);}return _0x33bb7c;};}function handleError(_0x1610fa,_0x36ee61){_0x36ee61=_0x36ee61||0x1f4;return function(_0x35040a){logger['error'](_0x35040a[_0x769f('0x29')]);if(_0x35040a[_0x769f('0x2a')]){delete _0x35040a[_0x769f('0x2a')];}_0x1610fa[_0x769f('0x1b')](_0x36ee61)[_0x769f('0x2b')](_0x35040a);};}exports[_0x769f('0x2c')]=function(_0x5107d3,_0x5d831c){var _0x46fded={},_0x10dbaa={},_0x5c677b={'count':0x0,'rows':[]};var _0x3c1384=_[_0x769f('0x2d')](db[_0x769f('0x2e')][_0x769f('0x2f')],function(_0x35d7fb){return{'name':_0x35d7fb['fieldName'],'type':_0x35d7fb[_0x769f('0x30')][_0x769f('0x31')]};});_0x10dbaa['model']=_[_0x769f('0x2d')](_0x3c1384,_0x769f('0x2a'));_0x10dbaa['query']=_[_0x769f('0x32')](_0x5107d3[_0x769f('0x33')]);_0x10dbaa['filters']=_['intersection'](_0x10dbaa[_0x769f('0x34')],_0x10dbaa[_0x769f('0x33')]);_0x46fded[_0x769f('0x35')]=_[_0x769f('0x36')](_0x10dbaa[_0x769f('0x34')],qs[_0x769f('0x37')](_0x5107d3['query']['fields']));_0x46fded[_0x769f('0x35')]=_0x46fded['attributes'][_0x769f('0x38')]?_0x46fded[_0x769f('0x35')]:_0x10dbaa[_0x769f('0x34')];if(!_0x5107d3['query'][_0x769f('0x39')]('nolimit')){_0x46fded[_0x769f('0x1d')]=qs['limit'](_0x5107d3[_0x769f('0x33')][_0x769f('0x1d')]);_0x46fded['offset']=qs[_0x769f('0x1f')](_0x5107d3[_0x769f('0x33')][_0x769f('0x1f')]);}_0x46fded[_0x769f('0x3a')]=qs['sort'](_0x5107d3[_0x769f('0x33')][_0x769f('0x3b')]);_0x46fded[_0x769f('0x3c')]=qs[_0x769f('0x3d')](_['pick'](_0x5107d3[_0x769f('0x33')],_0x10dbaa[_0x769f('0x3d')]),_0x3c1384);if(_0x5107d3[_0x769f('0x33')][_0x769f('0x3e')]){_0x46fded[_0x769f('0x3c')]=_[_0x769f('0x3f')](_0x46fded['where'],{'$or':[{'key':{'$like':'%'+_0x5107d3[_0x769f('0x33')][_0x769f('0x3e')]+'%'}},{'value':{'$like':'%'+_0x5107d3[_0x769f('0x33')]['filter']+'%'}}]});}_0x46fded=_[_0x769f('0x3f')]({},_0x46fded,_0x5107d3['options']);var _0x5f6251={'where':_0x46fded[_0x769f('0x3c')]};return db[_0x769f('0x2e')]['count'](_0x5f6251)[_0x769f('0x25')](function(_0x3792ec){_0x5c677b[_0x769f('0x1e')]=_0x3792ec;if(_0x5107d3[_0x769f('0x33')][_0x769f('0x40')]){_0x46fded[_0x769f('0x41')]=[{'all':!![]}];}return db[_0x769f('0x2e')][_0x769f('0x42')](_0x46fded);})['then'](function(_0x4f8a5b){_0x5c677b[_0x769f('0x43')]=_0x4f8a5b;return _0x5c677b;})[_0x769f('0x25')](respondWithFilteredResult(_0x5d831c,_0x46fded))[_0x769f('0x44')](handleError(_0x5d831c,null));};exports[_0x769f('0x45')]=function(_0x593712,_0x5a7822){var _0x43af02={'raw':!![],'where':{'id':_0x593712[_0x769f('0x46')]['id']}},_0x57d17e={};_0x57d17e[_0x769f('0x34')]=_['keys'](db[_0x769f('0x2e')][_0x769f('0x2f')]);_0x57d17e['query']=_[_0x769f('0x32')](_0x593712['query']);_0x57d17e[_0x769f('0x3d')]=_[_0x769f('0x36')](_0x57d17e[_0x769f('0x34')],_0x57d17e[_0x769f('0x33')]);_0x43af02[_0x769f('0x35')]=_[_0x769f('0x36')](_0x57d17e[_0x769f('0x34')],qs[_0x769f('0x37')](_0x593712[_0x769f('0x33')][_0x769f('0x37')]));_0x43af02['attributes']=_0x43af02['attributes']['length']?_0x43af02[_0x769f('0x35')]:_0x57d17e[_0x769f('0x34')];if(_0x593712[_0x769f('0x33')][_0x769f('0x40')]){_0x43af02[_0x769f('0x41')]=[{'all':!![]}];}_0x43af02=_[_0x769f('0x3f')]({},_0x43af02,_0x593712[_0x769f('0x47')]);return db[_0x769f('0x2e')][_0x769f('0x48')](_0x43af02)[_0x769f('0x25')](handleEntityNotFound(_0x5a7822,null))['then'](respondWithResult(_0x5a7822,null))['catch'](handleError(_0x5a7822,null));};exports[_0x769f('0x23')]=function(_0x5e35f9,_0x4b3fe6){if(_0x5e35f9[_0x769f('0x49')]['id']){delete _0x5e35f9[_0x769f('0x49')]['id'];}return db[_0x769f('0x2e')][_0x769f('0x48')]({'where':{'id':_0x5e35f9[_0x769f('0x46')]['id']}})[_0x769f('0x25')](handleEntityNotFound(_0x4b3fe6,null))[_0x769f('0x25')](saveUpdates(_0x5e35f9[_0x769f('0x49')],null))[_0x769f('0x25')](respondWithResult(_0x4b3fe6,null))[_0x769f('0x44')](handleError(_0x4b3fe6,null));};exports[_0x769f('0x24')]=function(_0x171240,_0xf411f0){return db[_0x769f('0x2e')][_0x769f('0x48')]({'where':{'id':_0x171240[_0x769f('0x46')]['id']}})[_0x769f('0x25')](handleEntityNotFound(_0xf411f0,null))[_0x769f('0x25')](removeEntity(_0xf411f0,null))[_0x769f('0x44')](handleError(_0xf411f0,null));};exports[_0x769f('0x4a')]=function(_0x36cb80,_0xf80bba){var _0x53ab9a={'key':_0x36cb80[_0x769f('0x49')][_0x769f('0x31')]};if(_0x36cb80[_0x769f('0x49')][_0x769f('0x4b')]){_0x53ab9a['MailAccountId']=_0x36cb80[_0x769f('0x49')][_0x769f('0x4b')];}else if(_0x36cb80[_0x769f('0x49')][_0x769f('0x4c')]){_0x53ab9a[_0x769f('0x4c')]=_0x36cb80[_0x769f('0x49')][_0x769f('0x4c')];}else if(_0x36cb80[_0x769f('0x49')][_0x769f('0x4d')]){_0x53ab9a['OpenchannelAccountId']=_0x36cb80[_0x769f('0x49')]['OpenchannelAccountId'];}else if(_0x36cb80[_0x769f('0x49')]['ChatWebsiteId']){_0x53ab9a[_0x769f('0x4e')]=_0x36cb80[_0x769f('0x49')]['ChatWebsiteId'];}return db[_0x769f('0x2e')][_0x769f('0x48')]({'where':_0x53ab9a})[_0x769f('0x25')](function(_0x377176){if(_0x377176){throw new db[(_0x769f('0x4f'))][(_0x769f('0x50'))](_0x769f('0x51'));}return db[_0x769f('0x2e')][_0x769f('0x4a')](_0x36cb80[_0x769f('0x49')]);})[_0x769f('0x25')](function(_0x1b1023){var _0x476a96=_0x36cb80['user'][_0x769f('0x26')]({'plain':!![]});if(!_0x476a96)throw new Error(_0x769f('0x52'));if(_0x476a96[_0x769f('0x53')]===_0x769f('0x54')){var _0x5f2487=_0x1b1023['get']({'plain':!![]});return db[_0x769f('0x55')][_0x769f('0x48')]({'where':{'name':'CannedAnswers','userProfileId':_0x476a96[_0x769f('0x56')]},'raw':!![]})[_0x769f('0x25')](function(_0x6c3807){if(_0x6c3807&&_0x6c3807[_0x769f('0x57')]===0x0){return db[_0x769f('0x28')][_0x769f('0x4a')]({'name':_0x5f2487[_0x769f('0x2a')],'resourceId':_0x5f2487['id'],'type':_0x6c3807['name'],'sectionId':_0x6c3807['id']},{})[_0x769f('0x25')](function(){return _0x1b1023;});}else{return _0x1b1023;}})[_0x769f('0x44')](function(_0x36455c){logger[_0x769f('0x58')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x36455c);throw _0x36455c;});}return _0x1b1023;})['then'](respondWithResult(_0xf80bba,0xc9))[_0x769f('0x44')](handleError(_0xf80bba,null));};
\ No newline at end of file