d7f45999b9a6515fee73ead4bd3f3c6e0496040f
[motion2.git] / server / api / intDeskConfiguration / intDeskConfiguration.controller.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x378f=['Tag','getTags','setTags','eml-format','rimraf','request-promise','moment','bluebird','mustache','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','desk.js','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','sendStatus','status','json','offset','undefined','count','limit','apply','reject','save','update','then','end','error','stack','name','send','index','map','rawAttributes','fieldName','type','keys','filters','intersection','model','attributes','fields','length','query','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','DeskConfiguration','includeAll','findAll','catch','show','options','find','create','body','params','getFields','findOne','getSubjects','DeskField','getDescriptions'];(function(_0x3ebce0,_0x10bb8b){var _0x1458ae=function(_0xcbcdc1){while(--_0xcbcdc1){_0x3ebce0['push'](_0x3ebce0['shift']());}};_0x1458ae(++_0x10bb8b);}(_0x378f,0x1e3));var _0xf378=function(_0x214be1,_0x424ae0){_0x214be1=_0x214be1-0x0;var _0x4fa0c2=_0x378f[_0x214be1];return _0x4fa0c2;};'use strict';var emlformat=require(_0xf378('0x0'));var rimraf=require(_0xf378('0x1'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0xf378('0x2'));var moment=require(_0xf378('0x3'));var BPromise=require(_0xf378('0x4'));var Mustache=require(_0xf378('0x5'));var util=require('util');var path=require(_0xf378('0x6'));var sox=require(_0xf378('0x7'));var csv=require(_0xf378('0x8'));var ejs=require(_0xf378('0x9'));var fs=require('fs');var fs_extra=require(_0xf378('0xa'));var _=require(_0xf378('0xb'));var squel=require(_0xf378('0xc'));var crypto=require(_0xf378('0xd'));var jsforce=require('jsforce');var deskjs=require(_0xf378('0xe'));var toCsv=require(_0xf378('0x8'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0xf378('0xf'));var authService=require(_0xf378('0x10'));var qs=require(_0xf378('0x11'));var as=require(_0xf378('0x12'));var hardwareService=require(_0xf378('0x13'));var logger=require(_0xf378('0x14'))(_0xf378('0x15'));var utils=require(_0xf378('0x16'));var config=require('../../config/environment');var licenseUtil=require(_0xf378('0x17'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x108e40,_0xce6e08){_0xce6e08=_0xce6e08||0xcc;return function(_0x52445c){if(_0x52445c){return _0x108e40[_0xf378('0x18')](_0xce6e08);}return _0x108e40[_0xf378('0x19')](_0xce6e08)['end']();};}function respondWithResult(_0x1a88a5,_0x22f0c7){_0x22f0c7=_0x22f0c7||0xc8;return function(_0x3e2202){if(_0x3e2202){return _0x1a88a5['status'](_0x22f0c7)[_0xf378('0x1a')](_0x3e2202);}};}function respondWithFilteredResult(_0x2145f4,_0x68e684){return function(_0x120596){if(_0x120596){var _0x27a389=typeof _0x68e684[_0xf378('0x1b')]===_0xf378('0x1c')&&typeof _0x68e684['limit']==='undefined';var _0x10ae33=_0x120596[_0xf378('0x1d')];var _0x278ca1=_0x27a389?0x0:_0x68e684[_0xf378('0x1b')];var _0xcb0a9=_0x27a389?_0x120596['count']:_0x68e684[_0xf378('0x1b')]+_0x68e684[_0xf378('0x1e')];var _0x51a565;if(_0xcb0a9>=_0x10ae33){_0xcb0a9=_0x10ae33;_0x51a565=0xc8;}else{_0x51a565=0xce;}_0x2145f4[_0xf378('0x19')](_0x51a565);return _0x2145f4['set']('Content-Range',_0x278ca1+'-'+_0xcb0a9+'/'+_0x10ae33)['json'](_0x120596);}return null;};}function patchUpdates(_0x4a79cd){return function(_0x3cb08d){try{jsonpatch[_0xf378('0x1f')](_0x3cb08d,_0x4a79cd,!![]);}catch(_0x19b29e){return BPromise[_0xf378('0x20')](_0x19b29e);}return _0x3cb08d[_0xf378('0x21')]();};}function saveUpdates(_0x276c38,_0x38919c){return function(_0x30f71a){if(_0x30f71a){return _0x30f71a[_0xf378('0x22')](_0x276c38)[_0xf378('0x23')](function(_0x845f64){return _0x845f64;});}return null;};}function removeEntity(_0x2eda75,_0x121667){return function(_0x1682e6){if(_0x1682e6){return _0x1682e6['destroy']()['then'](function(){_0x2eda75[_0xf378('0x19')](0xcc)[_0xf378('0x24')]();});}};}function handleEntityNotFound(_0x389062,_0xb4f750){return function(_0x591771){if(!_0x591771){_0x389062['sendStatus'](0x194);}return _0x591771;};}function handleError(_0x5708ed,_0x1d5c29){_0x1d5c29=_0x1d5c29||0x1f4;return function(_0x2dacea){logger[_0xf378('0x25')](_0x2dacea[_0xf378('0x26')]);if(_0x2dacea[_0xf378('0x27')]){delete _0x2dacea['name'];}_0x5708ed[_0xf378('0x19')](_0x1d5c29)[_0xf378('0x28')](_0x2dacea);};}exports[_0xf378('0x29')]=function(_0x21fe7e,_0x34487f){var _0x7ef925={},_0x11dea2={},_0x276e1b={'count':0x0,'rows':[]};var _0x2978e9=_[_0xf378('0x2a')](db['DeskConfiguration'][_0xf378('0x2b')],function(_0x5972e9){return{'name':_0x5972e9[_0xf378('0x2c')],'type':_0x5972e9[_0xf378('0x2d')]['key']};});_0x11dea2['model']=_[_0xf378('0x2a')](_0x2978e9,_0xf378('0x27'));_0x11dea2['query']=_[_0xf378('0x2e')](_0x21fe7e['query']);_0x11dea2[_0xf378('0x2f')]=_[_0xf378('0x30')](_0x11dea2[_0xf378('0x31')],_0x11dea2['query']);_0x7ef925[_0xf378('0x32')]=_['intersection'](_0x11dea2[_0xf378('0x31')],qs[_0xf378('0x33')](_0x21fe7e['query'][_0xf378('0x33')]));_0x7ef925[_0xf378('0x32')]=_0x7ef925['attributes'][_0xf378('0x34')]?_0x7ef925[_0xf378('0x32')]:_0x11dea2['model'];if(!_0x21fe7e[_0xf378('0x35')][_0xf378('0x36')](_0xf378('0x37'))){_0x7ef925[_0xf378('0x1e')]=qs[_0xf378('0x1e')](_0x21fe7e[_0xf378('0x35')][_0xf378('0x1e')]);_0x7ef925[_0xf378('0x1b')]=qs[_0xf378('0x1b')](_0x21fe7e[_0xf378('0x35')]['offset']);}_0x7ef925[_0xf378('0x38')]=qs[_0xf378('0x39')](_0x21fe7e['query'][_0xf378('0x39')]);_0x7ef925['where']=qs['filters'](_[_0xf378('0x3a')](_0x21fe7e[_0xf378('0x35')],_0x11dea2[_0xf378('0x2f')]),_0x2978e9);if(_0x21fe7e[_0xf378('0x35')][_0xf378('0x3b')]){_0x7ef925[_0xf378('0x3c')]=_[_0xf378('0x3d')](_0x7ef925[_0xf378('0x3c')],{'$or':_[_0xf378('0x2a')](_0x2978e9,function(_0x3d387d){if(_0x3d387d['type']!=='VIRTUAL'){var _0x486ceb={};_0x486ceb[_0x3d387d[_0xf378('0x27')]]={'$like':'%'+_0x21fe7e[_0xf378('0x35')][_0xf378('0x3b')]+'%'};return _0x486ceb;}})});}_0x7ef925=_[_0xf378('0x3d')]({},_0x7ef925,_0x21fe7e['options']);var _0x445577={'where':_0x7ef925[_0xf378('0x3c')]};return db[_0xf378('0x3e')][_0xf378('0x1d')](_0x445577)[_0xf378('0x23')](function(_0x48a855){_0x276e1b['count']=_0x48a855;if(_0x21fe7e[_0xf378('0x35')][_0xf378('0x3f')]){_0x7ef925['include']=[{'all':!![]}];}return db[_0xf378('0x3e')][_0xf378('0x40')](_0x7ef925);})[_0xf378('0x23')](function(_0x4b6f55){_0x276e1b['rows']=_0x4b6f55;return _0x276e1b;})[_0xf378('0x23')](respondWithFilteredResult(_0x34487f,_0x7ef925))[_0xf378('0x41')](handleError(_0x34487f,null));};exports[_0xf378('0x42')]=function(_0x3f07de,_0x522879){var _0xce6ee={'raw':![],'where':{'id':_0x3f07de['params']['id']}},_0xfe63ef={};_0xfe63ef[_0xf378('0x31')]=_['keys'](db[_0xf378('0x3e')]['rawAttributes']);_0xfe63ef[_0xf378('0x35')]=_[_0xf378('0x2e')](_0x3f07de[_0xf378('0x35')]);_0xfe63ef[_0xf378('0x2f')]=_[_0xf378('0x30')](_0xfe63ef[_0xf378('0x31')],_0xfe63ef[_0xf378('0x35')]);_0xce6ee[_0xf378('0x32')]=_['intersection'](_0xfe63ef[_0xf378('0x31')],qs[_0xf378('0x33')](_0x3f07de[_0xf378('0x35')][_0xf378('0x33')]));_0xce6ee[_0xf378('0x32')]=_0xce6ee[_0xf378('0x32')][_0xf378('0x34')]?_0xce6ee[_0xf378('0x32')]:_0xfe63ef[_0xf378('0x31')];if(_0x3f07de[_0xf378('0x35')][_0xf378('0x3f')]){_0xce6ee['include']=[{'all':!![]}];}_0xce6ee=_['merge']({},_0xce6ee,_0x3f07de[_0xf378('0x43')]);return db['DeskConfiguration'][_0xf378('0x44')](_0xce6ee)['then'](handleEntityNotFound(_0x522879,null))['then'](respondWithResult(_0x522879,null))[_0xf378('0x41')](handleError(_0x522879,null));};exports[_0xf378('0x45')]=function(_0x3b06c3,_0x5d4691){return db[_0xf378('0x3e')][_0xf378('0x45')](_0x3b06c3['body'],{})[_0xf378('0x23')](respondWithResult(_0x5d4691,0xc9))[_0xf378('0x41')](handleError(_0x5d4691,null));};exports[_0xf378('0x22')]=function(_0x1f879f,_0x5290f8){if(_0x1f879f[_0xf378('0x46')]['id']){delete _0x1f879f[_0xf378('0x46')]['id'];}return db[_0xf378('0x3e')]['find']({'where':{'id':_0x1f879f[_0xf378('0x47')]['id']}})['then'](handleEntityNotFound(_0x5290f8,null))[_0xf378('0x23')](saveUpdates(_0x1f879f[_0xf378('0x46')],null))['then'](respondWithResult(_0x5290f8,null))['catch'](handleError(_0x5290f8,null));};exports['destroy']=function(_0x13360f,_0x4a611d){return db[_0xf378('0x3e')][_0xf378('0x44')]({'where':{'id':_0x13360f[_0xf378('0x47')]['id']}})['then'](handleEntityNotFound(_0x4a611d,null))['then'](removeEntity(_0x4a611d,null))[_0xf378('0x41')](handleError(_0x4a611d,null));};exports[_0xf378('0x48')]=function(_0x2ccce2,_0x556a77,_0x413301){var _0x5132d1={};var _0xd24ae7={};var _0x1b6b39;var _0x3f26;return db[_0xf378('0x3e')][_0xf378('0x49')]({'where':{'id':_0x2ccce2[_0xf378('0x47')]['id']}})['then'](handleEntityNotFound(_0x556a77,null))[_0xf378('0x23')](function(_0x924f0b){if(_0x924f0b){_0x1b6b39=_0x924f0b;_0xd24ae7[_0xf378('0x31')]=_[_0xf378('0x2e')](db['DeskField'][_0xf378('0x2b')]);_0xd24ae7[_0xf378('0x35')]=_[_0xf378('0x2e')](_0x2ccce2['query']);_0xd24ae7[_0xf378('0x2f')]=_[_0xf378('0x30')](_0xd24ae7[_0xf378('0x31')],_0xd24ae7['query']);_0x5132d1[_0xf378('0x32')]=_['intersection'](_0xd24ae7[_0xf378('0x31')],qs['fields'](_0x2ccce2[_0xf378('0x35')][_0xf378('0x33')]));_0x5132d1[_0xf378('0x32')]=_0x5132d1[_0xf378('0x32')][_0xf378('0x34')]?_0x5132d1[_0xf378('0x32')]:_0xd24ae7[_0xf378('0x31')];_0x5132d1['order']=qs[_0xf378('0x39')](_0x2ccce2['query'][_0xf378('0x39')]);_0x5132d1[_0xf378('0x3c')]=qs[_0xf378('0x2f')](_[_0xf378('0x3a')](_0x2ccce2[_0xf378('0x35')],_0xd24ae7['filters']));if(_0x2ccce2[_0xf378('0x35')][_0xf378('0x3b')]){_0x5132d1[_0xf378('0x3c')]=_['merge'](_0x5132d1['where'],{'$or':_['map'](_0x5132d1[_0xf378('0x32')],function(_0x1b27e0){var _0x5687c4={};_0x5687c4[_0x1b27e0]={'$like':'%'+_0x2ccce2[_0xf378('0x35')]['filter']+'%'};return _0x5687c4;})});}_0x5132d1=_[_0xf378('0x3d')]({},_0x5132d1,_0x2ccce2[_0xf378('0x43')]);return _0x1b6b39['getFields'](_0x5132d1);}})[_0xf378('0x23')](function(_0x87e416){if(_0x87e416){_0x3f26=_0x87e416['length'];if(!_0x2ccce2[_0xf378('0x35')]['hasOwnProperty'](_0xf378('0x37'))){_0x5132d1[_0xf378('0x1e')]=qs[_0xf378('0x1e')](_0x2ccce2[_0xf378('0x35')][_0xf378('0x1e')]);_0x5132d1[_0xf378('0x1b')]=qs['offset'](_0x2ccce2[_0xf378('0x35')]['offset']);}return _0x1b6b39[_0xf378('0x48')](_0x5132d1);}})[_0xf378('0x23')](function(_0x20666b){if(_0x20666b){return _0x20666b?{'count':_0x3f26,'rows':_0x20666b}:null;}})['then'](respondWithResult(_0x556a77,null))[_0xf378('0x41')](handleError(_0x556a77,null));};exports[_0xf378('0x4a')]=function(_0x41938c,_0x350ca4,_0xf85730){var _0x18af55={};var _0x185626={};var _0x23785d;var _0x4221e6;return db[_0xf378('0x3e')][_0xf378('0x49')]({'where':{'id':_0x41938c[_0xf378('0x47')]['id']}})[_0xf378('0x23')](handleEntityNotFound(_0x350ca4,null))['then'](function(_0x1c9cc2){if(_0x1c9cc2){_0x23785d=_0x1c9cc2;_0x185626[_0xf378('0x31')]=_[_0xf378('0x2e')](db[_0xf378('0x4b')][_0xf378('0x2b')]);_0x185626['query']=_[_0xf378('0x2e')](_0x41938c['query']);_0x185626[_0xf378('0x2f')]=_[_0xf378('0x30')](_0x185626[_0xf378('0x31')],_0x185626[_0xf378('0x35')]);_0x18af55['attributes']=_['intersection'](_0x185626[_0xf378('0x31')],qs['fields'](_0x41938c[_0xf378('0x35')]['fields']));_0x18af55['attributes']=_0x18af55[_0xf378('0x32')][_0xf378('0x34')]?_0x18af55[_0xf378('0x32')]:_0x185626[_0xf378('0x31')];_0x18af55[_0xf378('0x38')]=qs[_0xf378('0x39')](_0x41938c['query'][_0xf378('0x39')]);_0x18af55[_0xf378('0x3c')]=qs[_0xf378('0x2f')](_[_0xf378('0x3a')](_0x41938c[_0xf378('0x35')],_0x185626[_0xf378('0x2f')]));if(_0x41938c['query'][_0xf378('0x3b')]){_0x18af55[_0xf378('0x3c')]=_[_0xf378('0x3d')](_0x18af55[_0xf378('0x3c')],{'$or':_['map'](_0x18af55['attributes'],function(_0x59403b){var _0x2bd04b={};_0x2bd04b[_0x59403b]={'$like':'%'+_0x41938c[_0xf378('0x35')]['filter']+'%'};return _0x2bd04b;})});}_0x18af55=_[_0xf378('0x3d')]({},_0x18af55,_0x41938c[_0xf378('0x43')]);return _0x23785d[_0xf378('0x4a')](_0x18af55);}})[_0xf378('0x23')](function(_0x2f8fd3){if(_0x2f8fd3){_0x4221e6=_0x2f8fd3[_0xf378('0x34')];if(!_0x41938c[_0xf378('0x35')][_0xf378('0x36')](_0xf378('0x37'))){_0x18af55[_0xf378('0x1e')]=qs[_0xf378('0x1e')](_0x41938c['query'][_0xf378('0x1e')]);_0x18af55[_0xf378('0x1b')]=qs[_0xf378('0x1b')](_0x41938c[_0xf378('0x35')][_0xf378('0x1b')]);}return _0x23785d[_0xf378('0x4a')](_0x18af55);}})['then'](function(_0x43cacb){if(_0x43cacb){return _0x43cacb?{'count':_0x4221e6,'rows':_0x43cacb}:null;}})['then'](respondWithResult(_0x350ca4,null))[_0xf378('0x41')](handleError(_0x350ca4,null));};exports['getDescriptions']=function(_0x38989f,_0x535342,_0x572e68){var _0x3a551a={};var _0x343398={};var _0x439826;var _0x38cb49;return db[_0xf378('0x3e')][_0xf378('0x49')]({'where':{'id':_0x38989f[_0xf378('0x47')]['id']}})[_0xf378('0x23')](handleEntityNotFound(_0x535342,null))[_0xf378('0x23')](function(_0x2cc7f5){if(_0x2cc7f5){_0x439826=_0x2cc7f5;_0x343398['model']=_[_0xf378('0x2e')](db['DeskField'][_0xf378('0x2b')]);_0x343398[_0xf378('0x35')]=_[_0xf378('0x2e')](_0x38989f['query']);_0x343398[_0xf378('0x2f')]=_[_0xf378('0x30')](_0x343398['model'],_0x343398['query']);_0x3a551a[_0xf378('0x32')]=_[_0xf378('0x30')](_0x343398['model'],qs[_0xf378('0x33')](_0x38989f[_0xf378('0x35')][_0xf378('0x33')]));_0x3a551a[_0xf378('0x32')]=_0x3a551a[_0xf378('0x32')]['length']?_0x3a551a[_0xf378('0x32')]:_0x343398[_0xf378('0x31')];_0x3a551a[_0xf378('0x38')]=qs[_0xf378('0x39')](_0x38989f[_0xf378('0x35')][_0xf378('0x39')]);_0x3a551a[_0xf378('0x3c')]=qs[_0xf378('0x2f')](_[_0xf378('0x3a')](_0x38989f['query'],_0x343398[_0xf378('0x2f')]));if(_0x38989f[_0xf378('0x35')]['filter']){_0x3a551a[_0xf378('0x3c')]=_[_0xf378('0x3d')](_0x3a551a[_0xf378('0x3c')],{'$or':_[_0xf378('0x2a')](_0x3a551a[_0xf378('0x32')],function(_0x28202e){var _0x49334d={};_0x49334d[_0x28202e]={'$like':'%'+_0x38989f['query'][_0xf378('0x3b')]+'%'};return _0x49334d;})});}_0x3a551a=_[_0xf378('0x3d')]({},_0x3a551a,_0x38989f[_0xf378('0x43')]);return _0x439826[_0xf378('0x4c')](_0x3a551a);}})[_0xf378('0x23')](function(_0x1f0de8){if(_0x1f0de8){_0x38cb49=_0x1f0de8['length'];if(!_0x38989f[_0xf378('0x35')][_0xf378('0x36')]('nolimit')){_0x3a551a['limit']=qs[_0xf378('0x1e')](_0x38989f[_0xf378('0x35')][_0xf378('0x1e')]);_0x3a551a[_0xf378('0x1b')]=qs['offset'](_0x38989f['query']['offset']);}return _0x439826[_0xf378('0x4c')](_0x3a551a);}})[_0xf378('0x23')](function(_0x5be28b){if(_0x5be28b){return _0x5be28b?{'count':_0x38cb49,'rows':_0x5be28b}:null;}})['then'](respondWithResult(_0x535342,null))[_0xf378('0x41')](handleError(_0x535342,null));};exports['getTags']=function(_0x5974fd,_0x5e9f2a,_0x2f2161){var _0x5af4e4={};var _0x302357={};var _0x50abe2;var _0x270269;return db[_0xf378('0x3e')][_0xf378('0x49')]({'where':{'id':_0x5974fd[_0xf378('0x47')]['id']}})[_0xf378('0x23')](handleEntityNotFound(_0x5e9f2a,null))[_0xf378('0x23')](function(_0x52fb86){if(_0x52fb86){_0x50abe2=_0x52fb86;_0x302357[_0xf378('0x31')]=_[_0xf378('0x2e')](db[_0xf378('0x4d')]['rawAttributes']);_0x302357[_0xf378('0x35')]=_[_0xf378('0x2e')](_0x5974fd[_0xf378('0x35')]);_0x302357[_0xf378('0x2f')]=_['intersection'](_0x302357[_0xf378('0x31')],_0x302357['query']);_0x5af4e4['attributes']=_[_0xf378('0x30')](_0x302357[_0xf378('0x31')],qs[_0xf378('0x33')](_0x5974fd[_0xf378('0x35')][_0xf378('0x33')]));_0x5af4e4[_0xf378('0x32')]=_0x5af4e4[_0xf378('0x32')][_0xf378('0x34')]?_0x5af4e4[_0xf378('0x32')]:_0x302357[_0xf378('0x31')];_0x5af4e4[_0xf378('0x38')]=qs[_0xf378('0x39')](_0x5974fd[_0xf378('0x35')]['sort']);_0x5af4e4['where']=qs[_0xf378('0x2f')](_[_0xf378('0x3a')](_0x5974fd[_0xf378('0x35')],_0x302357[_0xf378('0x2f')]));if(_0x5974fd[_0xf378('0x35')][_0xf378('0x3b')]){_0x5af4e4['where']=_[_0xf378('0x3d')](_0x5af4e4['where'],{'$or':_[_0xf378('0x2a')](_0x5af4e4[_0xf378('0x32')],function(_0x107d69){var _0x5b243a={};_0x5b243a[_0x107d69]={'$like':'%'+_0x5974fd[_0xf378('0x35')]['filter']+'%'};return _0x5b243a;})});}_0x5af4e4=_['merge']({},_0x5af4e4,_0x5974fd[_0xf378('0x43')]);return _0x50abe2[_0xf378('0x4e')](_0x5af4e4);}})['then'](function(_0x24bd50){if(_0x24bd50){_0x270269=_0x24bd50[_0xf378('0x34')];if(!_0x5974fd['query'][_0xf378('0x36')](_0xf378('0x37'))){_0x5af4e4[_0xf378('0x1e')]=qs['limit'](_0x5974fd[_0xf378('0x35')][_0xf378('0x1e')]);_0x5af4e4[_0xf378('0x1b')]=qs[_0xf378('0x1b')](_0x5974fd[_0xf378('0x35')][_0xf378('0x1b')]);}return _0x50abe2[_0xf378('0x4e')](_0x5af4e4);}})[_0xf378('0x23')](function(_0x5703d4){if(_0x5703d4){return _0x5703d4?{'count':_0x270269,'rows':_0x5703d4}:null;}})[_0xf378('0x23')](respondWithResult(_0x5e9f2a,null))[_0xf378('0x41')](handleError(_0x5e9f2a,null));};exports['setTags']=function(_0x20e17c,_0xfb81a1,_0x3c3bd1){if(_0x20e17c[_0xf378('0x46')]['id']){delete _0x20e17c[_0xf378('0x46')]['id'];}return db[_0xf378('0x3e')][_0xf378('0x49')]({'where':{'id':_0x20e17c[_0xf378('0x47')]['id']}})[_0xf378('0x23')](handleEntityNotFound(_0xfb81a1,null))[_0xf378('0x23')](function(_0x4e934c){if(_0x4e934c){return _0x4e934c[_0xf378('0x4f')](_0x20e17c[_0xf378('0x46')]['ids']||[]);}return null;})[_0xf378('0x23')](respondWithResult(_0xfb81a1,null))[_0xf378('0x41')](handleError(_0xfb81a1,null));};