Built motion from commit (unavailable).|2.5.21
[motion2.git] / server / api / cmContact / cmContact.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 _0x4b1f=['CmHopperBlack','[CmContact][merge][destroy][CmHopperBlack],\x20%s','update','MailInteraction','MailMessage','SmsInteraction','FaxInteraction','FaxMessage','OpenchannelInteraction','OpenchannelMessage','CmHopperFinal','VoiceCallReport','FaxQueueReport','MailQueueReport','OpenchannelQueueReport','JscriptySessionReport','WhatsappMessage','create','describe','bulkCreate','each','duplicates','$or','findOrCreate','spread','color','$and','cf_%d','omit','pickBy','format','setFields','id\x20=\x20?','phone','rawAttributes','pick','options','getTags','setTags','ids','getHoppers','ContactId','rows','getHopperHistories','CmHopperHistory','includeAll','include','getHopperFinals','getJscriptySessions','No\x20ListId\x20specified','No\x20association\x20keys\x20specified!','binding_values','No\x20association\x20values\x20specified!','socket_timestamp','binding_keys','Incorrect\x20binding\x20parameters\x20passed!','zipObject','No\x20phone\x20column\x20specified','firstName','No\x20firstName\x20column\x20specified','root','server/files/tmp','filename','chmodSync','0777','child_process','CompanyId','pid','upload','createReadStream','file','path','meta','import','binding','fork','../../components/import/cm/csv2','stringify','start\x20child\x20process\x20correctly!','exit','getJourney','chat','sms','openchannel','voice','-createdAt','channel','toLowerCase','range','parse','isValid','Invalid\x20date\x20for\x20range\x20to\x20filter','Invalid\x20createdAt\x20filter','uniqueid','source','destination','callerid','starttime','endtime','duration','note','createdAt','userThirdDisposition','alias','DESC','findAndCountAll','startCase','Account','closed','disposition','secondDisposition','UserId','key','fullname','customerIp','deviceModel','ratingMessage','ratingValue','referer','externalUrl','Owner','flatten','sortBy','html-pdf','eml-format','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','to-csv','ejs','lodash','squel','crypto','querystring','ioredis','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','register','end','json','count','offset','limit','set','Content-Range','apply','save','then','destroy','status','error','name','send','index','keys','startsWith','cf_','push','CmCustomField','findOne','trimStart','all','length','fieldType','type','query','intersection','model','attributes','fields','hasOwnProperty','nolimit','order','sort','where','filters','select','field','from','cm_contacts','left_join','uc.CmContactId\x20=\x20c.id','cm_contact_has_tags','tools_tags','t.id\x20=\x20ct.TagId','c.deletedAt\x20IS\x20NULL','expr','parseSearch','search','conditions','find','Tag','value','split','map','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','union','User','and','uc.UserId\x20=\x20?','dateOfBirth','datetime','castTo','DATE','buildExpression','text','start','filter','isNil','Contact','isEmpty','forEach','ListId','c.ListId\x20IN\x20?','CONCAT_WS(\x27\x20\x27,\x20c.firstName,\x20c.lastName,\x20c.email)\x20LIKE\x20?','\x20=\x20?','tag','isArray','replace','getFullTextValue','isNumeric','c.phone\x20LIKE\x20?','c.mobile\x20LIKE\x20?','c.fax\x20LIKE\x20?','isEmail','c.email\x20LIKE\x20?','c.firstName\x20LIKE\x20?','c.lastName\x20LIKE\x20?','group','c.id','Sequelize','QueryTypes','clone','having','user','agent','some','getLists','c.ListId\x20IS\x20NULL','role','sequelize','toString','keyBy','merge','c.lastName','c.mobile','c.fax','c.ListId','c.createdAt','c.deletedAt','GROUP_CONCAT(DISTINCT\x20t.id)','TagIds','Tags','CmContact','params','tags','columnName','displayName','findAll','values','catch','body','get','mergeWith','join','info','[CmContact][merge]\x20to\x20%s\x20from\x20%s','CmHopper','[CmContact][merge][destroy][CmHopper],\x20%s'];(function(_0x584876,_0x54ae35){var _0x285483=function(_0x4fe9f4){while(--_0x4fe9f4){_0x584876['push'](_0x584876['shift']());}};_0x285483(++_0x54ae35);}(_0x4b1f,0x195));var _0xf4b1=function(_0x4b7895,_0x3c4f5d){_0x4b7895=_0x4b7895-0x0;var _0x264180=_0x4b1f[_0x4b7895];return _0x264180;};'use strict';var pdf=require(_0xf4b1('0x0'));var emlformat=require(_0xf4b1('0x1'));var rimraf=require('rimraf');var zipdir=require(_0xf4b1('0x2'));var jsonpatch=require(_0xf4b1('0x3'));var rp=require(_0xf4b1('0x4'));var moment=require('moment');var BPromise=require(_0xf4b1('0x5'));var Mustache=require(_0xf4b1('0x6'));var util=require(_0xf4b1('0x7'));var path=require('path');var sox=require('sox');var csv=require(_0xf4b1('0x8'));var ejs=require(_0xf4b1('0x9'));var fs=require('fs');var _=require(_0xf4b1('0xa'));var squel=require(_0xf4b1('0xb'));var crypto=require(_0xf4b1('0xc'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0xf4b1('0xd'));var Papa=require('papaparse');var Redis=require(_0xf4b1('0xe'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0xf4b1('0xf'));var hardwareService=require(_0xf4b1('0x10'));var logger=require(_0xf4b1('0x11'))(_0xf4b1('0x12'));var utils=require(_0xf4b1('0x13'));var config=require(_0xf4b1('0x14'));var licenseUtil=require(_0xf4b1('0x15'));var db=require(_0xf4b1('0x16'))['db'];config[_0xf4b1('0x17')]=_[_0xf4b1('0x18')](config[_0xf4b1('0x17')],{'host':_0xf4b1('0x19'),'port':0x18eb});var socket=require(_0xf4b1('0x1a'))(new Redis(config['redis']));require('./cmContact.socket')[_0xf4b1('0x1b')](socket);function respondWithStatusCode(_0x5cbc25,_0x598bec){_0x598bec=_0x598bec||0xcc;return function(_0x476a04){if(_0x476a04){return _0x5cbc25['sendStatus'](_0x598bec);}return _0x5cbc25['status'](_0x598bec)[_0xf4b1('0x1c')]();};}function respondWithResult(_0x4968f4,_0x5e7206){_0x5e7206=_0x5e7206||0xc8;return function(_0x554517){if(_0x554517){return _0x4968f4['status'](_0x5e7206)[_0xf4b1('0x1d')](_0x554517);}};}function respondWithFilteredResult(_0x3ee70a,_0x534fd8){return function(_0x3b378e){if(_0x3b378e){var _0x420f9e=_0x3b378e[_0xf4b1('0x1e')],_0x322b38=_0x534fd8['offset'],_0x465da2=_0x534fd8[_0xf4b1('0x1f')]+_0x534fd8[_0xf4b1('0x20')],_0x2658e8;if(_0x465da2>=_0x420f9e){_0x465da2=_0x420f9e;_0x2658e8=0xc8;}else{_0x2658e8=0xce;}_0x3ee70a['status'](_0x2658e8);return _0x3ee70a[_0xf4b1('0x21')](_0xf4b1('0x22'),_0x322b38+'-'+_0x465da2+'/'+_0x420f9e)['json'](_0x3b378e);}return null;};}function patchUpdates(_0x13892d){return function(_0x559a64){try{jsonpatch[_0xf4b1('0x23')](_0x559a64,_0x13892d,!![]);}catch(_0x466739){return BPromise['reject'](_0x466739);}return _0x559a64[_0xf4b1('0x24')]();};}function saveUpdates(_0x29b8c1,_0x23c867){return function(_0xccb44){if(_0xccb44){return _0xccb44['update'](_0x29b8c1)[_0xf4b1('0x25')](function(_0x474212){return _0x474212;});}return null;};}function removeEntity(_0x4b6c08,_0x732e84){return function(_0x502f0b){if(_0x502f0b){return _0x502f0b[_0xf4b1('0x26')]()['then'](function(){_0x4b6c08[_0xf4b1('0x27')](0xcc)[_0xf4b1('0x1c')]();});}};}function handleEntityNotFound(_0x2e803d,_0x5a0285){return function(_0x10bea4){if(!_0x10bea4){_0x2e803d['sendStatus'](0x194);}return _0x10bea4;};}function handleError(_0x2e3b90,_0x5619e3){_0x5619e3=_0x5619e3||0x1f4;return function(_0x29493b){logger[_0xf4b1('0x28')](_0x29493b['stack']);if(_0x29493b[_0xf4b1('0x29')]){delete _0x29493b[_0xf4b1('0x29')];}_0x2e3b90['status'](_0x5619e3)[_0xf4b1('0x2a')](_0x29493b);};}exports[_0xf4b1('0x2b')]=function(_0x3fe08e,_0x11ffb3){var _0x3046dc={},_0x36243e={},_0x2f830c={'count':0x0,'rows':[]};return db['CmContact']['describe']()[_0xf4b1('0x25')](function(_0xff9a65){var _0x1cbcff=[];for(var _0x29b9f9=0x0;_0x29b9f9<Object[_0xf4b1('0x2c')](_0xff9a65)['length'];_0x29b9f9++){var _0xb9492c=Object[_0xf4b1('0x2c')](_0xff9a65)[_0x29b9f9];if(_[_0xf4b1('0x2d')](_0xb9492c,_0xf4b1('0x2e'))){_0x1cbcff[_0xf4b1('0x2f')](db[_0xf4b1('0x30')][_0xf4b1('0x31')]({'where':{'id':_[_0xf4b1('0x32')](_0xb9492c,'cf_')},'raw':!![]}));}}return BPromise[_0xf4b1('0x33')](_0x1cbcff)['then'](function(_0x5b5fe5){for(var _0x48f672=0x0;_0x48f672<_0x5b5fe5[_0xf4b1('0x34')];_0x48f672++){if(_0x5b5fe5[_0x48f672]){var _0x423fe8=_0xf4b1('0x2e')+_0x5b5fe5[_0x48f672]['id'];var _0x3889b4=_0xff9a65[_0x423fe8];_0x3889b4[_0xf4b1('0x35')]=_0x5b5fe5[_0x48f672][_0xf4b1('0x36')];}}return _0xff9a65;});})[_0xf4b1('0x25')](function(_0x4572da){_0x36243e['model']=_[_0xf4b1('0x2c')](_0x4572da);_0x36243e['query']=_[_0xf4b1('0x2c')](_0x3fe08e[_0xf4b1('0x37')]);_0x36243e['filters']=_[_0xf4b1('0x38')](_0x36243e[_0xf4b1('0x39')],_0x36243e[_0xf4b1('0x37')]);_0x3046dc[_0xf4b1('0x3a')]=_[_0xf4b1('0x38')](_0x36243e['model'],qs[_0xf4b1('0x3b')](_0x3fe08e['query'][_0xf4b1('0x3b')]));_0x3046dc['attributes']=_0x3046dc[_0xf4b1('0x3a')][_0xf4b1('0x34')]?_0x3046dc[_0xf4b1('0x3a')]:_0x36243e['model'];if(!_0x3fe08e[_0xf4b1('0x37')][_0xf4b1('0x3c')](_0xf4b1('0x3d'))){_0x3046dc[_0xf4b1('0x20')]=qs[_0xf4b1('0x20')](_0x3fe08e[_0xf4b1('0x37')][_0xf4b1('0x20')]);_0x3046dc['offset']=qs[_0xf4b1('0x1f')](_0x3fe08e[_0xf4b1('0x37')][_0xf4b1('0x1f')]);}_0x3046dc[_0xf4b1('0x3e')]=qs[_0xf4b1('0x3f')](_0x3fe08e[_0xf4b1('0x37')]['sort']);_0x3046dc[_0xf4b1('0x40')]=qs[_0xf4b1('0x41')](_['pick'](_0x3fe08e['query'],_0x36243e[_0xf4b1('0x41')]),_0x4572da);var _0x19581c=[];var _0x439c9d=squel[_0xf4b1('0x42')]()[_0xf4b1('0x43')]('id')[_0xf4b1('0x43')](_0xf4b1('0x29'))[_0xf4b1('0x43')]('color')[_0xf4b1('0x44')]('tools_tags');var _0x4e8496=squel['select']()[_0xf4b1('0x44')](_0xf4b1('0x45'),'c')[_0xf4b1('0x46')]('cm_user_has_contacts','uc',_0xf4b1('0x47'))[_0xf4b1('0x46')](_0xf4b1('0x48'),'ct','ct.CmContactId\x20=\x20c.id')[_0xf4b1('0x46')](_0xf4b1('0x49'),'t',_0xf4b1('0x4a'))['where'](_0xf4b1('0x4b'));var _0x4fa2df=squel[_0xf4b1('0x4c')]();var _0x35d94c=[];var _0x306620=squel['expr']();var _0x16c00f;if(_0x3fe08e[_0xf4b1('0x37')]['search']){_0x16c00f=as[_0xf4b1('0x4d')](_0x3fe08e[_0xf4b1('0x37')][_0xf4b1('0x4e')]);var _0x240bd9=_0x16c00f['sqlOperator'];for(var _0x5a7b0a=0x0;_0x5a7b0a<_0x16c00f[_0xf4b1('0x4f')][_0xf4b1('0x34')];_0x5a7b0a++){var _0x4f90d3=_0x16c00f[_0xf4b1('0x4f')][_0x5a7b0a];var _0x4dfce5='c';var _0x202381=_(_0x4572da)['keys']()[_0xf4b1('0x50')](function(_0x332386){return _0x332386===_0x4f90d3['field'];});if(_0x202381)_0x202381=_0x4572da[_0x4f90d3[_0xf4b1('0x43')]];if(!_0x202381){if(_0x4f90d3[_0xf4b1('0x43')]===_0xf4b1('0x51')){var _0x2dc900=_0x4f90d3[_0xf4b1('0x52')][_0xf4b1('0x53')](',')[_0xf4b1('0x54')](function(_0x4fa2fd){return Number(_0x4fa2fd);});_0x2dc900['forEach'](function(_0x4a9761){_0x306620['or'](_0xf4b1('0x55'),'%,'+_0x4a9761+',%');});_0x35d94c=_[_0xf4b1('0x56')](_0x35d94c,_0x2dc900);}else if(_0x4f90d3['field']===_0xf4b1('0x57')){_0x4fa2df[_0xf4b1('0x58')](_0xf4b1('0x59'),_0x4f90d3[_0xf4b1('0x52')]);}}else{if(_0x4f90d3[_0xf4b1('0x43')]===_0xf4b1('0x5a')||_0x202381[_0xf4b1('0x35')]===_0xf4b1('0x5b'))_0x4f90d3[_0xf4b1('0x5c')]=_0xf4b1('0x5d');var _0x407ecf=as[_0xf4b1('0x5e')](_0x4dfce5,_0x202381[_0xf4b1('0x36')],_0x4f90d3);_0x4fa2df[_0x240bd9](_0x407ecf[_0xf4b1('0x5f')],_0x407ecf[_0xf4b1('0x52')][_0xf4b1('0x60')],_0x407ecf[_0xf4b1('0x52')][_0xf4b1('0x1c')]);}}}else{var _0x12711b=_(Object[_0xf4b1('0x2c')](_0x3fe08e[_0xf4b1('0x37')]))[_0xf4b1('0x54')](function(_0x38efcd){return _0x4572da[_0xf4b1('0x3c')](_0x38efcd)?_0x38efcd:undefined;})[_0xf4b1('0x61')](function(_0x263094){return!_[_0xf4b1('0x62')](_0x263094);})[_0xf4b1('0x52')]();if(_0x3fe08e['query'][_0xf4b1('0x63')])_0x12711b['push']('Contact');if(!_[_0xf4b1('0x64')](_0x12711b)){_0x12711b[_0xf4b1('0x65')](function(_0x589788){if(_0x589788===_0xf4b1('0x66')){_0x4e8496[_0xf4b1('0x40')](_0xf4b1('0x67'),[]['concat'](_0x3fe08e['query'][_0x589788]));}else if(_0x589788===_0xf4b1('0x63')){var _0x2eea26='%'+_0x3fe08e[_0xf4b1('0x37')][_0x589788]+'%';_0x4e8496[_0xf4b1('0x40')](_0xf4b1('0x68'),_0x2eea26);}else{_0x4e8496[_0xf4b1('0x40')]('c.'+_0x589788+_0xf4b1('0x69'),_0x3fe08e[_0xf4b1('0x37')][_0x589788]);}});}if(_0x3fe08e[_0xf4b1('0x37')][_0xf4b1('0x6a')]){_0x35d94c=_[_0xf4b1('0x6b')](_0x3fe08e[_0xf4b1('0x37')][_0xf4b1('0x6a')])?_0x3fe08e[_0xf4b1('0x37')]['tag']:new Array(_0x3fe08e[_0xf4b1('0x37')][_0xf4b1('0x6a')]);_0x35d94c[_0xf4b1('0x65')](function(_0x427126){_0x306620['or'](_0xf4b1('0x55'),'%,'+_0x427126+',%');});}if(_0x3fe08e[_0xf4b1('0x37')][_0xf4b1('0x61')]){var _0x302881=_0x3fe08e[_0xf4b1('0x37')]['filter'][_0xf4b1('0x6c')]('\x5c','\x5c\x5c')[_0xf4b1('0x6c')](/'/g,'\x27\x27');if(_0x302881[_0xf4b1('0x53')]('\x20')['length']>0x1){_0x4fa2df['or']('MATCH\x20(c.firstName,\x20c.lastName,\x20c.phone,\x20c.mobile,\x20c.fax,\x20c.email)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)',qs[_0xf4b1('0x6d')](_0x302881),null);}else{if(qs[_0xf4b1('0x6e')](_0x302881)){_0x4fa2df['or']('c.id\x20LIKE\x20?',_0x302881+'%');_0x4fa2df['or'](_0xf4b1('0x6f'),_0x302881+'%');_0x4fa2df['or'](_0xf4b1('0x70'),_0x302881+'%');_0x4fa2df['or'](_0xf4b1('0x71'),_0x302881+'%');}else if(qs[_0xf4b1('0x72')](_0x302881)){_0x4fa2df['or'](_0xf4b1('0x73'),_0x302881+'%');}else{_0x4fa2df['or'](_0xf4b1('0x74'),'%'+_0x302881+'%');_0x4fa2df['or'](_0xf4b1('0x75'),'%'+_0x302881+'%');_0x4fa2df['or'](_0xf4b1('0x73'),'%'+_0x302881+'%');}}}}_0x4e8496[_0xf4b1('0x40')](_0x4fa2df);_0x4e8496[_0xf4b1('0x76')](_0xf4b1('0x77'));var _0x525cd8={'type':db[_0xf4b1('0x78')][_0xf4b1('0x79')]['SELECT'],'raw':!![]};var _0x2211df=_0x4e8496[_0xf4b1('0x7a')]()[_0xf4b1('0x43')]('c.id');if(_0x3046dc[_0xf4b1('0x3e')]){_0x3046dc[_0xf4b1('0x3e')]['forEach'](function(_0x4d233d){_0x4e8496[_0xf4b1('0x3e')]('c.'+_0x4d233d[0x0],_0x4d233d[0x1]==='DESC'?![]:!![]);});}if(!_['isEmpty'](_0x35d94c)){_0x4e8496[_0xf4b1('0x7b')](_0x306620);_0x2211df[_0xf4b1('0x40')]('t.id\x20IN\x20?',_0x35d94c);}BPromise['resolve']()[_0xf4b1('0x25')](function(){if(!_0x16c00f)return;if(_0x3fe08e[_0xf4b1('0x7c')]['role']!==_0xf4b1('0x7d'))return;if(!_[_0xf4b1('0x7e')](_0x16c00f[_0xf4b1('0x4f')],[_0xf4b1('0x43'),_0xf4b1('0x57')])){return _0x3fe08e[_0xf4b1('0x7c')][_0xf4b1('0x7f')]({'attributes':['id'],'raw':!![]})['then'](function(_0x1a687d){if(_[_0xf4b1('0x64')](_0x1a687d)){_0x2211df[_0xf4b1('0x40')](_0xf4b1('0x80'));_0x4e8496[_0xf4b1('0x40')](_0xf4b1('0x80'));}else{_0x2211df[_0xf4b1('0x40')]('c.ListId\x20IN\x20?',_['map'](_0x1a687d,'id'));_0x4e8496[_0xf4b1('0x40')](_0xf4b1('0x67'),_['map'](_0x1a687d,'id'));}});}})[_0xf4b1('0x25')](function(){if(_0x3fe08e[_0xf4b1('0x7c')][_0xf4b1('0x81')]===_0xf4b1('0x7d')&&!_0x16c00f&&!_0x3fe08e['query'][_0xf4b1('0x66')])return[];return db[_0xf4b1('0x82')][_0xf4b1('0x37')](_0x2211df['toString'](),_0x525cd8);})[_0xf4b1('0x25')](function(_0x53e2c){_0x2f830c[_0xf4b1('0x1e')]=_0x53e2c[_0xf4b1('0x34')];if(_0x2f830c[_0xf4b1('0x1e')]===0x0)return[];return db['sequelize'][_0xf4b1('0x37')](_0x439c9d[_0xf4b1('0x83')](),_0x525cd8)[_0xf4b1('0x25')](function(_0x2e78cb){_0x19581c=_[_0xf4b1('0x84')](_0x2e78cb,'id');_0x525cd8=_[_0xf4b1('0x85')](_0x525cd8,{'model':db['CmContact'],'mapToModel':!![],'raw':!![],'nest':!![]});if(_0x3fe08e[_0xf4b1('0x37')]['fields']){_0x3046dc[_0xf4b1('0x3a')]['forEach'](function(_0x46b3df){_0x4e8496[_0xf4b1('0x43')]('c.'+_0x46b3df);});}else{_0x4e8496[_0xf4b1('0x43')](_0xf4b1('0x77'));_0x4e8496['field']('c.firstName');_0x4e8496['field'](_0xf4b1('0x86'));_0x4e8496['field']('c.phone');_0x4e8496[_0xf4b1('0x43')](_0xf4b1('0x87'));_0x4e8496['field'](_0xf4b1('0x88'));_0x4e8496[_0xf4b1('0x43')]('c.email');_0x4e8496[_0xf4b1('0x43')](_0xf4b1('0x89'));_0x4e8496['field'](_0xf4b1('0x8a'));_0x4e8496['field'](_0xf4b1('0x8b'));_0x4e8496['field']('c.CompanyId');_0x4e8496[_0xf4b1('0x43')](_0xf4b1('0x8c'),'TagIds');}if(_0x3046dc[_0xf4b1('0x20')])_0x4e8496[_0xf4b1('0x20')](_0x3046dc[_0xf4b1('0x20')]);if(_0x3046dc[_0xf4b1('0x1f')])_0x4e8496[_0xf4b1('0x1f')](_0x3046dc['offset']);return db[_0xf4b1('0x82')][_0xf4b1('0x37')](_0x4e8496[_0xf4b1('0x83')](),_0x525cd8);});})['then'](function(_0xaa93bf){_0xaa93bf[_0xf4b1('0x65')](function(_0x41bf68){if(_0x41bf68[_0xf4b1('0x8d')]){_0x41bf68['Tags']=[];_0x41bf68[_0xf4b1('0x8d')][_0xf4b1('0x53')](',')[_0xf4b1('0x65')](function(_0x331599){_0x41bf68[_0xf4b1('0x8e')][_0xf4b1('0x2f')](_0x19581c[_0x331599]);});}delete _0x41bf68['TagIds'];});_0x2f830c['rows']=_0xaa93bf;return _0x2f830c;})['then'](respondWithFilteredResult(_0x11ffb3,_0x3046dc));})['catch'](handleError(_0x11ffb3,null));};exports[_0xf4b1('0x26')]=function(_0x32ab64,_0x5186ae){return db[_0xf4b1('0x8f')][_0xf4b1('0x50')]({'where':{'id':_0x32ab64[_0xf4b1('0x90')]['id']}})['then'](handleEntityNotFound(_0x5186ae,null))[_0xf4b1('0x25')](removeEntity(_0x5186ae,null))['catch'](handleError(_0x5186ae,null));};exports['describe']=function(_0x591d51,_0x196ed7){return db[_0xf4b1('0x8f')]['describe']()['then'](function(_0x1b871c){delete _0x1b871c[_0xf4b1('0x91')];for(var _0xee9e13=0x0;_0xee9e13<Object[_0xf4b1('0x2c')](_0x1b871c)[_0xf4b1('0x34')];_0xee9e13++){var _0x1a3280=Object[_0xf4b1('0x2c')](_0x1b871c)[_0xee9e13];if(!_[_0xf4b1('0x2d')](_0x1a3280,_0xf4b1('0x2e'))){_0x1b871c[_0x1a3280][_0xf4b1('0x92')]=_0x1a3280;_0x1b871c[_0x1a3280][_0xf4b1('0x93')]=_0x1a3280;}}return _0x1b871c;})[_0xf4b1('0x25')](function(_0x322422){var _0x16e3ff={'where':{'$or':[{'ListId':_0x591d51['query']['id']},{'ListId':null}]},'raw':!![]};return db[_0xf4b1('0x30')][_0xf4b1('0x94')](_0x16e3ff)[_0xf4b1('0x25')](function(_0x2788ad){for(var _0x171a4a=0x0;_0x171a4a<_0x2788ad['length'];_0x171a4a++){var _0x3da44b=_0xf4b1('0x2e')+_0x2788ad[_0x171a4a]['id'];_0x322422[_0x3da44b][_0xf4b1('0x92')]=_0x3da44b;_0x322422[_0x3da44b][_0xf4b1('0x93')]=_0x2788ad[_0x171a4a]['alias'];_0x322422[_0x3da44b]['custom']={'type':_0x2788ad[_0x171a4a][_0xf4b1('0x36')],'values':_0x2788ad[_0x171a4a][_0xf4b1('0x95')]};}Object[_0xf4b1('0x2c')](_0x322422)[_0xf4b1('0x65')](function(_0x5d8776){if(!_0x322422[_0x5d8776][_0xf4b1('0x3c')](_0xf4b1('0x92'))){delete _0x322422[_0x5d8776];}});return _0x322422;});})[_0xf4b1('0x25')](respondWithResult(_0x196ed7,null))[_0xf4b1('0x96')](handleError(_0x196ed7,null));};exports['merge']=function(_0x503f3f,_0x13d74f){var _0x1d2afb;var _0x313200;var _0x501612;if(_0x503f3f[_0xf4b1('0x97')]['id']){delete _0x503f3f[_0xf4b1('0x97')]['id'];}return db[_0xf4b1('0x8f')][_0xf4b1('0x94')]({'where':{'id':[_0x503f3f['body']['to'],_0x503f3f[_0xf4b1('0x97')][_0xf4b1('0x44')]]}})[_0xf4b1('0x25')](function(_0x31b397){if(_0x31b397){if(_0x31b397[_0xf4b1('0x34')]!==0x2){return null;}_0x31b397[0x0]=_0x31b397[0x0][_0xf4b1('0x98')]({'plain':!![]});_0x31b397[0x1]=_0x31b397[0x1]['get']({'plain':!![]});delete _0x31b397[0x0]['id'];delete _0x31b397[0x1]['id'];return _[_0xf4b1('0x99')](_0x31b397[0x0],_0x31b397[0x1],function(_0xddbd28,_0xd8b0f2){if(Array[_0xf4b1('0x6b')](_0xd8b0f2)&&!_0xd8b0f2[_0xf4b1('0x34')]){return _0xddbd28;}else if(!_0xd8b0f2){return _0xddbd28;}});}})['then'](handleEntityNotFound(_0x13d74f,null))[_0xf4b1('0x25')](function(_0x53c20a){if(_0x53c20a){if(_0x53c20a[_0xf4b1('0x91')]&&_[_0xf4b1('0x6b')](_0x53c20a[_0xf4b1('0x91')])){_0x53c20a[_0xf4b1('0x91')]=_0x53c20a[_0xf4b1('0x91')][_0xf4b1('0x9a')]();}logger[_0xf4b1('0x9b')](_0xf4b1('0x9c'),_0x503f3f[_0xf4b1('0x97')]['to'],_0x503f3f['body'][_0xf4b1('0x44')]);return db[_0xf4b1('0x9d')]['destroy']({'where':{'ContactId':[_0x503f3f[_0xf4b1('0x97')]['to'],_0x503f3f[_0xf4b1('0x97')][_0xf4b1('0x44')]]}})[_0xf4b1('0x25')](function(_0x44e9f8){logger[_0xf4b1('0x9b')](_0xf4b1('0x9e'),_0x44e9f8);return db[_0xf4b1('0x9f')][_0xf4b1('0x26')]({'where':{'ContactId':[_0x503f3f[_0xf4b1('0x97')]['to'],_0x503f3f[_0xf4b1('0x97')][_0xf4b1('0x44')]]}})[_0xf4b1('0x25')](function(_0x55fda5){logger[_0xf4b1('0x9b')](_0xf4b1('0xa0'),_0x55fda5);return db[_0xf4b1('0x8f')]['create'](_0x53c20a);});});}})[_0xf4b1('0x25')](function(_0x26584c){if(_0x26584c){_0x1d2afb=_0x26584c;_0x313200={'ContactId':_0x1d2afb['id']};_0x501612={'where':{'ContactId':[_0x503f3f[_0xf4b1('0x97')]['to'],_0x503f3f['body'][_0xf4b1('0x44')]]}};return db['ChatInteraction'][_0xf4b1('0xa1')](_0x313200,_0x501612);}})[_0xf4b1('0x25')](function(){if(_0x1d2afb){return db['ChatMessage'][_0xf4b1('0xa1')](_0x313200,_0x501612);}})[_0xf4b1('0x25')](function(){if(_0x1d2afb){return db['ChatOfflineMessage'][_0xf4b1('0xa1')](_0x313200,_0x501612);}})['then'](function(){if(_0x1d2afb){return db[_0xf4b1('0xa2')][_0xf4b1('0xa1')](_0x313200,_0x501612);}})[_0xf4b1('0x25')](function(){if(_0x1d2afb){return db[_0xf4b1('0xa3')][_0xf4b1('0xa1')](_0x313200,_0x501612);}})[_0xf4b1('0x25')](function(){if(_0x1d2afb){return db['MailInteraction']['update'](_0x313200,_0x501612);}})['then'](function(){if(_0x1d2afb){return db[_0xf4b1('0xa3')]['update'](_0x313200,_0x501612);}})['then'](function(){if(_0x1d2afb){return db[_0xf4b1('0xa4')][_0xf4b1('0xa1')](_0x313200,_0x501612);}})['then'](function(){if(_0x1d2afb){return db['SmsMessage']['update'](_0x313200,_0x501612);}})[_0xf4b1('0x25')](function(){if(_0x1d2afb){return db[_0xf4b1('0xa5')][_0xf4b1('0xa1')](_0x313200,_0x501612);}})[_0xf4b1('0x25')](function(){if(_0x1d2afb){return db[_0xf4b1('0xa6')][_0xf4b1('0xa1')](_0x313200,_0x501612);}})[_0xf4b1('0x25')](function(){if(_0x1d2afb){return db[_0xf4b1('0xa7')][_0xf4b1('0xa1')](_0x313200,_0x501612);}})[_0xf4b1('0x25')](function(){if(_0x1d2afb){return db[_0xf4b1('0xa8')][_0xf4b1('0xa1')](_0x313200,_0x501612);}})['then'](function(){if(_0x1d2afb){return db[_0xf4b1('0xa9')][_0xf4b1('0xa1')](_0x313200,_0x501612);}})[_0xf4b1('0x25')](function(){if(_0x1d2afb){return db['CmHopperHistory'][_0xf4b1('0xa1')](_0x313200,_0x501612);}})[_0xf4b1('0x25')](function(){if(_0x1d2afb){return db['ReportAgentPreview'][_0xf4b1('0xa1')](_0x313200,_0x501612);}})['then'](function(){if(_0x1d2afb){return db[_0xf4b1('0xaa')][_0xf4b1('0xa1')](_0x313200,_0x501612);}})['then'](function(){if(_0x1d2afb){return db['ChatQueueReport']['update'](_0x313200,_0x501612);}})[_0xf4b1('0x25')](function(){if(_0x1d2afb){return db[_0xf4b1('0xab')][_0xf4b1('0xa1')](_0x313200,_0x501612);}})[_0xf4b1('0x25')](function(){if(_0x1d2afb){return db[_0xf4b1('0xac')][_0xf4b1('0xa1')](_0x313200,_0x501612);}})[_0xf4b1('0x25')](function(){if(_0x1d2afb){return db[_0xf4b1('0xad')][_0xf4b1('0xa1')](_0x313200,_0x501612);}})['then'](function(){if(_0x1d2afb){return db['SmsQueueReport']['update'](_0x313200,_0x501612);}})[_0xf4b1('0x25')](function(){if(_0x1d2afb){return db[_0xf4b1('0xae')]['update'](_0x313200,_0x501612);}})['then'](function(){if(_0x1d2afb){return db['WhatsappInteraction'][_0xf4b1('0xa1')](_0x313200,_0x501612);}})[_0xf4b1('0x25')](function(){if(_0x1d2afb){return db[_0xf4b1('0xaf')][_0xf4b1('0xa1')](_0x313200,_0x501612);}})[_0xf4b1('0x25')](function(){if(_0x1d2afb){return db['WhatsappQueueReport'][_0xf4b1('0xa1')](_0x313200,_0x501612);}})['then'](function(){if(_0x1d2afb){return db['CmContact']['destroy']({'where':{'id':[_0x503f3f[_0xf4b1('0x97')]['to'],_0x503f3f[_0xf4b1('0x97')][_0xf4b1('0x44')]]}});}})['then'](function(){if(_0x1d2afb){return _0x1d2afb;}})[_0xf4b1('0x25')](respondWithResult(_0x13d74f,null))['catch'](handleError(_0x13d74f,null));};exports[_0xf4b1('0xb0')]=function(_0x5af7e5,_0x467f0b){return db[_0xf4b1('0x8f')][_0xf4b1('0xb1')]()[_0xf4b1('0x25')](function(_0x310ed9){if(_0x5af7e5[_0xf4b1('0x97')][_0xf4b1('0x91')]&&_[_0xf4b1('0x6b')](_0x5af7e5[_0xf4b1('0x97')][_0xf4b1('0x91')])){if(_0x5af7e5['body']['tags']['length']){_0x5af7e5['body']['tags']=_0x5af7e5[_0xf4b1('0x97')][_0xf4b1('0x91')]['join'](';')+';';}else{_0x5af7e5['body']['tags']=null;}}else{_0x5af7e5[_0xf4b1('0x97')][_0xf4b1('0x91')]=null;}return db[_0xf4b1('0x8f')][_0xf4b1('0xb0')](_0x5af7e5[_0xf4b1('0x97')],{'fields':_[_0xf4b1('0x2c')](_0x310ed9),'raw':!![]});})[_0xf4b1('0x25')](respondWithResult(_0x467f0b,0xc9))[_0xf4b1('0x96')](handleError(_0x467f0b,null));};exports[_0xf4b1('0xb2')]=function(_0x52e9ba,_0x4b6ccb){var _0x14e776=[];var _0x3aaaec=0x0;var _0x1695dd=0x0;var _0x4eb463=0x0;return db[_0xf4b1('0x8f')][_0xf4b1('0xb1')]()[_0xf4b1('0x25')](function(_0x49de6f){return BPromise[_0xf4b1('0xb3')](_0x52e9ba[_0xf4b1('0x97')],function(_0x3dfec6){var _0x593cfc={'where':{'$or':[]},'defaults':_0x3dfec6,'fields':_[_0xf4b1('0x2c')](_0x49de6f),'raw':!![]};if(_0x3dfec6[_0xf4b1('0xb4')]){for(var _0x5b7437=0x0;_0x5b7437<_0x3dfec6[_0xf4b1('0xb4')][_0xf4b1('0x34')];_0x5b7437++){var _0x33c905={};_0x33c905[_0x3dfec6['duplicates'][_0x5b7437]]=_0x3dfec6[_0x3dfec6[_0xf4b1('0xb4')][_0x5b7437]];_0x593cfc[_0xf4b1('0x40')][_0xf4b1('0xb5')]['push'](_0x33c905);}_0x593cfc[_0xf4b1('0x40')][_0xf4b1('0x66')]=_0x3dfec6['ListId'];}return db['CmContact'][_0xf4b1('0xb6')](_0x593cfc)[_0xf4b1('0xb7')](function(_0x2e8e95,_0x3e1eba){if(_0x3e1eba){_0x3aaaec++;}else{_0x4eb463++;}})['catch'](function(_0x14f7dc){console[_0xf4b1('0x28')](_0x14f7dc);_0x1695dd++;});});})[_0xf4b1('0x25')](function(_0x241b80){if(_0x241b80){return{'success':_0x3aaaec,'failure':_0x1695dd,'duplicates':_0x4eb463};}})[_0xf4b1('0x25')](respondWithResult(_0x4b6ccb,0xc9))['catch'](handleError(_0x4b6ccb,null));};exports['show']=function(_0x217c9b,_0x26eac0,_0x24dc4e){var _0x3135cc;return db[_0xf4b1('0x8f')][_0xf4b1('0xb1')]()[_0xf4b1('0x25')](function(_0xfb55a5){return db[_0xf4b1('0x8f')][_0xf4b1('0x50')]({'where':{'id':_0x217c9b['params']['id']},'include':[{'model':db['Tag'],'as':'Tags','attributes':['id',_0xf4b1('0x29'),_0xf4b1('0xb8')],'required':_0x217c9b[_0xf4b1('0x37')][_0xf4b1('0x6a')]?!![]:![]}],'attributes':_['keys'](_0xfb55a5)});})[_0xf4b1('0x25')](function(_0x1bcb28){_0x3135cc=_0x1bcb28['get']({'plain':!![]});var _0x22f9d1={'where':{'$and':[{'ListId':{'$ne':null}}]}};if(_0x1bcb28&&_0x1bcb28[_0xf4b1('0x66')]){if(_0x1bcb28[_0xf4b1('0x66')]){_0x22f9d1[_0xf4b1('0x40')][_0xf4b1('0xb9')][_0xf4b1('0x2f')]({'ListId':{'$ne':_0x1bcb28[_0xf4b1('0x66')]}});}}return db['CmCustomField'][_0xf4b1('0x94')](_0x22f9d1);})['then'](function(_0x1529c0){return _['omit'](_0x3135cc,_[_0xf4b1('0x54')](_0x1529c0,function(_0x1fc0a1){return util['format'](_0xf4b1('0xba'),_0x1fc0a1['id']);}));})[_0xf4b1('0x25')](handleEntityNotFound(_0x26eac0,null))[_0xf4b1('0x25')](respondWithResult(_0x26eac0,null))['catch'](handleError(_0x26eac0,null));};exports[_0xf4b1('0xa1')]=function(_0x24e411,_0x20c1c6){var _0x56a6e4;if(_0x24e411[_0xf4b1('0x97')]['id']){delete _0x24e411[_0xf4b1('0x97')]['id'];}return db[_0xf4b1('0x8f')]['find']({'where':{'id':_0x24e411['params']['id']}})[_0xf4b1('0x25')](handleEntityNotFound(_0x20c1c6,null))['then'](saveUpdates(_0x24e411[_0xf4b1('0x97')],null))[_0xf4b1('0x25')](function(_0x59a287){_0x56a6e4=_0x59a287;var _0x127a0e={'where':{'$and':[{'ListId':{'$ne':null}}]}};if(_0x59a287&&_0x59a287[_0xf4b1('0x66')]){if(_0x59a287['ListId']){_0x127a0e[_0xf4b1('0x40')][_0xf4b1('0xb9')][_0xf4b1('0x2f')]({'ListId':{'$ne':_0x59a287[_0xf4b1('0x66')]}});}}return db[_0xf4b1('0x30')][_0xf4b1('0x94')](_0x127a0e);})[_0xf4b1('0x25')](function(_0x474d41){if(_0x474d41){return _[_0xf4b1('0xbb')](_[_0xf4b1('0xbc')](_0x24e411['body'],function(_0x24aef2,_0x3f71af){return _['startsWith'](_0x3f71af,_0xf4b1('0x2e'));}),_[_0xf4b1('0x54')](_0x474d41,function(_0x13d101){return util[_0xf4b1('0xbd')](_0xf4b1('0xba'),_0x13d101['id']);}));}})[_0xf4b1('0x25')](function(_0x2c9e13){if(_0x2c9e13&&!_[_0xf4b1('0x64')](_0x2c9e13)){var _0x2fe30c=squel['update']()['table'](_0xf4b1('0x45'))[_0xf4b1('0xbe')](_0x2c9e13)[_0xf4b1('0x40')](_0xf4b1('0xbf'),_0x24e411[_0xf4b1('0x90')]['id'])['toParam']();return db['sequelize']['query'](_0x2fe30c[_0xf4b1('0x5f')],{'replacements':_0x2fe30c[_0xf4b1('0x95')]});}})['then'](function(){if(_0x24e411[_0xf4b1('0x97')][_0xf4b1('0xc0')]&&_0x56a6e4){return db[_0xf4b1('0x9d')][_0xf4b1('0xa1')]({'phone':_0x24e411[_0xf4b1('0x97')][_0xf4b1('0xc0')]},{'where':{'ContactId':_0x56a6e4['id']}});}})[_0xf4b1('0x25')](function(){return _0x56a6e4;})['then'](respondWithResult(_0x20c1c6,null))[_0xf4b1('0x96')](handleError(_0x20c1c6,null));};exports['getTags']=function(_0x2cd1c2,_0x2d0c24,_0x5de0bf){var _0x53af5c={};var _0x28ea80={};var _0x18877c;var _0x3a1ea5;return db[_0xf4b1('0x8f')][_0xf4b1('0x31')]({'where':{'id':_0x2cd1c2['params']['id']}})[_0xf4b1('0x25')](handleEntityNotFound(_0x2d0c24,null))['then'](function(_0x1b18f5){if(_0x1b18f5){_0x18877c=_0x1b18f5;_0x28ea80[_0xf4b1('0x39')]=_[_0xf4b1('0x2c')](db[_0xf4b1('0x51')][_0xf4b1('0xc1')]);_0x28ea80['query']=_[_0xf4b1('0x2c')](_0x2cd1c2[_0xf4b1('0x37')]);_0x28ea80[_0xf4b1('0x41')]=_[_0xf4b1('0x38')](_0x28ea80['model'],_0x28ea80[_0xf4b1('0x37')]);_0x53af5c['attributes']=_[_0xf4b1('0x38')](_0x28ea80['model'],qs['fields'](_0x2cd1c2[_0xf4b1('0x37')][_0xf4b1('0x3b')]));_0x53af5c[_0xf4b1('0x3a')]=_0x53af5c[_0xf4b1('0x3a')][_0xf4b1('0x34')]?_0x53af5c[_0xf4b1('0x3a')]:_0x28ea80['model'];_0x53af5c[_0xf4b1('0x3e')]=qs[_0xf4b1('0x3f')](_0x2cd1c2[_0xf4b1('0x37')][_0xf4b1('0x3f')]);_0x53af5c['where']=qs[_0xf4b1('0x41')](_[_0xf4b1('0xc2')](_0x2cd1c2[_0xf4b1('0x37')],_0x28ea80[_0xf4b1('0x41')]));if(_0x2cd1c2['query'][_0xf4b1('0x61')]){_0x53af5c[_0xf4b1('0x40')]=_['merge'](_0x53af5c[_0xf4b1('0x40')],{'$or':_[_0xf4b1('0x54')](_0x53af5c[_0xf4b1('0x3a')],function(_0x1e0fb0){var _0xa3d696={};_0xa3d696[_0x1e0fb0]={'$like':'%'+_0x2cd1c2['query'][_0xf4b1('0x61')]+'%'};return _0xa3d696;})});}_0x53af5c=_[_0xf4b1('0x85')]({},_0x53af5c,_0x2cd1c2[_0xf4b1('0xc3')]);return _0x18877c[_0xf4b1('0xc4')](_0x53af5c);}})[_0xf4b1('0x25')](function(_0x56043c){if(_0x56043c){_0x3a1ea5=_0x56043c[_0xf4b1('0x34')];if(!_0x2cd1c2[_0xf4b1('0x37')][_0xf4b1('0x3c')](_0xf4b1('0x3d'))){_0x53af5c['limit']=qs[_0xf4b1('0x20')](_0x2cd1c2['query'][_0xf4b1('0x20')]);_0x53af5c[_0xf4b1('0x1f')]=qs[_0xf4b1('0x1f')](_0x2cd1c2['query']['offset']);}return _0x18877c[_0xf4b1('0xc4')](_0x53af5c);}})['then'](function(_0x4971d3){if(_0x4971d3){return _0x4971d3?{'count':_0x3a1ea5,'rows':_0x4971d3}:null;}})[_0xf4b1('0x25')](respondWithResult(_0x2d0c24,null))[_0xf4b1('0x96')](handleError(_0x2d0c24,null));};exports[_0xf4b1('0xc5')]=function(_0x148569,_0x39d8fe,_0x2e7c4b){if(_0x148569[_0xf4b1('0x97')]['id']){delete _0x148569[_0xf4b1('0x97')]['id'];}return db[_0xf4b1('0x8f')][_0xf4b1('0x31')]({'where':{'id':_0x148569[_0xf4b1('0x90')]['id']}})[_0xf4b1('0x25')](handleEntityNotFound(_0x39d8fe,null))[_0xf4b1('0x25')](function(_0x7fa0c1){if(_0x7fa0c1){return _0x7fa0c1['setTags'](_0x148569[_0xf4b1('0x97')][_0xf4b1('0xc6')]||[]);}return null;})[_0xf4b1('0x25')](respondWithResult(_0x39d8fe,null))['catch'](handleError(_0x39d8fe,null));};exports[_0xf4b1('0xc7')]=function(_0x3e0877,_0x2c1995,_0x15ea2f){var _0x509fb2={'raw':![],'where':{}};var _0x3fbdaa={};var _0xdb25c8={'count':0x0,'rows':[]};return db[_0xf4b1('0x8f')]['findOne']({'where':{'id':_0x3e0877[_0xf4b1('0x90')]['id']}})[_0xf4b1('0x25')](handleEntityNotFound(_0x2c1995,null))[_0xf4b1('0x25')](function(_0x3acde7){if(_0x3acde7){_0x3fbdaa[_0xf4b1('0x39')]=_['keys'](db['CmHopper'][_0xf4b1('0xc1')]);_0x3fbdaa[_0xf4b1('0x37')]=_[_0xf4b1('0x2c')](_0x3e0877['query']);_0x3fbdaa['filters']=_[_0xf4b1('0x38')](_0x3fbdaa['model'],_0x3fbdaa[_0xf4b1('0x37')]);_0x509fb2[_0xf4b1('0x3a')]=_[_0xf4b1('0x38')](_0x3fbdaa[_0xf4b1('0x39')],qs[_0xf4b1('0x3b')](_0x3e0877[_0xf4b1('0x37')][_0xf4b1('0x3b')]));_0x509fb2[_0xf4b1('0x3a')]=_0x509fb2[_0xf4b1('0x3a')][_0xf4b1('0x34')]?_0x509fb2['attributes']:_0x3fbdaa[_0xf4b1('0x39')];if(!_0x3e0877[_0xf4b1('0x37')][_0xf4b1('0x3c')](_0xf4b1('0x3d'))){_0x509fb2[_0xf4b1('0x20')]=qs['limit'](_0x3e0877[_0xf4b1('0x37')][_0xf4b1('0x20')]);_0x509fb2[_0xf4b1('0x1f')]=qs[_0xf4b1('0x1f')](_0x3e0877[_0xf4b1('0x37')][_0xf4b1('0x1f')]);}_0x509fb2[_0xf4b1('0x3e')]=qs[_0xf4b1('0x3f')](_0x3e0877[_0xf4b1('0x37')]['sort']);_0x509fb2[_0xf4b1('0x40')]=qs[_0xf4b1('0x41')](_[_0xf4b1('0xc2')](_0x3e0877[_0xf4b1('0x37')],_0x3fbdaa[_0xf4b1('0x41')]));_0x509fb2[_0xf4b1('0x40')][_0xf4b1('0xc8')]=_0x3acde7['id'];if(_0x3e0877['query'][_0xf4b1('0x61')]){_0x509fb2['where']=_[_0xf4b1('0x85')](_0x509fb2[_0xf4b1('0x40')],{'$or':_[_0xf4b1('0x54')](_0x509fb2[_0xf4b1('0x3a')],function(_0x4db8d0){var _0x5b7b11={};_0x5b7b11[_0x4db8d0]={'$like':'%'+_0x3e0877[_0xf4b1('0x37')][_0xf4b1('0x61')]+'%'};return _0x5b7b11;})});}_0x509fb2=_['merge']({},_0x509fb2,_0x3e0877['options']);return db[_0xf4b1('0x9d')][_0xf4b1('0x1e')]({'where':_0x509fb2[_0xf4b1('0x40')]})[_0xf4b1('0x25')](function(_0x345e3f){_0xdb25c8['count']=_0x345e3f;if(_0x3e0877[_0xf4b1('0x37')]['includeAll']){_0x509fb2['include']=[{'all':!![]}];}return db[_0xf4b1('0x9d')][_0xf4b1('0x94')](_0x509fb2);})[_0xf4b1('0x25')](function(_0x16977d){_0xdb25c8[_0xf4b1('0xc9')]=_0x16977d;return _0xdb25c8;});}})[_0xf4b1('0x25')](respondWithFilteredResult(_0x2c1995,_0x509fb2))['catch'](handleError(_0x2c1995,null));};exports[_0xf4b1('0xca')]=function(_0x49a5a1,_0x1f7e06,_0x664f07){var _0x482cc7={'raw':!![],'where':{}};var _0x1a0227={};var _0x2a37c4={'count':0x0,'rows':[]};return db[_0xf4b1('0x8f')][_0xf4b1('0x31')]({'where':{'id':_0x49a5a1['params']['id']}})['then'](handleEntityNotFound(_0x1f7e06,null))[_0xf4b1('0x25')](function(_0x24973c){if(_0x24973c){_0x1a0227['model']=_[_0xf4b1('0x2c')](db[_0xf4b1('0xcb')][_0xf4b1('0xc1')]);_0x1a0227[_0xf4b1('0x37')]=_['keys'](_0x49a5a1[_0xf4b1('0x37')]);_0x1a0227[_0xf4b1('0x41')]=_['intersection'](_0x1a0227[_0xf4b1('0x39')],_0x1a0227[_0xf4b1('0x37')]);_0x482cc7[_0xf4b1('0x3a')]=_[_0xf4b1('0x38')](_0x1a0227['model'],qs[_0xf4b1('0x3b')](_0x49a5a1[_0xf4b1('0x37')][_0xf4b1('0x3b')]));_0x482cc7[_0xf4b1('0x3a')]=_0x482cc7['attributes']['length']?_0x482cc7[_0xf4b1('0x3a')]:_0x1a0227[_0xf4b1('0x39')];if(!_0x49a5a1[_0xf4b1('0x37')][_0xf4b1('0x3c')]('nolimit')){_0x482cc7['limit']=qs['limit'](_0x49a5a1[_0xf4b1('0x37')][_0xf4b1('0x20')]);_0x482cc7['offset']=qs[_0xf4b1('0x1f')](_0x49a5a1[_0xf4b1('0x37')][_0xf4b1('0x1f')]);}_0x482cc7[_0xf4b1('0x3e')]=qs[_0xf4b1('0x3f')](_0x49a5a1[_0xf4b1('0x37')][_0xf4b1('0x3f')]);_0x482cc7[_0xf4b1('0x40')]=qs[_0xf4b1('0x41')](_[_0xf4b1('0xc2')](_0x49a5a1[_0xf4b1('0x37')],_0x1a0227[_0xf4b1('0x41')]));_0x482cc7[_0xf4b1('0x40')][_0xf4b1('0xc8')]=_0x24973c['id'];if(_0x49a5a1[_0xf4b1('0x37')]['filter']){_0x482cc7[_0xf4b1('0x40')]=_[_0xf4b1('0x85')](_0x482cc7[_0xf4b1('0x40')],{'$or':_[_0xf4b1('0x54')](_0x482cc7['attributes'],function(_0x4bb24){var _0x418611={};_0x418611[_0x4bb24]={'$like':'%'+_0x49a5a1[_0xf4b1('0x37')][_0xf4b1('0x61')]+'%'};return _0x418611;})});}_0x482cc7=_[_0xf4b1('0x85')]({},_0x482cc7,_0x49a5a1[_0xf4b1('0xc3')]);return db[_0xf4b1('0xcb')][_0xf4b1('0x1e')]({'where':_0x482cc7[_0xf4b1('0x40')]})[_0xf4b1('0x25')](function(_0x29dc73){_0x2a37c4['count']=_0x29dc73;if(_0x49a5a1[_0xf4b1('0x37')][_0xf4b1('0xcc')]){_0x482cc7[_0xf4b1('0xcd')]=[{'all':!![]}];}return db[_0xf4b1('0xcb')][_0xf4b1('0x94')](_0x482cc7);})[_0xf4b1('0x25')](function(_0x1ccc58){_0x2a37c4['rows']=_0x1ccc58;return _0x2a37c4;});}})['then'](respondWithFilteredResult(_0x1f7e06,_0x482cc7))['catch'](handleError(_0x1f7e06,null));};exports[_0xf4b1('0xce')]=function(_0x41560e,_0x4e0791,_0x319f4c){var _0x46abd0={'raw':!![],'where':{}};var _0x10cc37={};var _0x58999c={'count':0x0,'rows':[]};return db[_0xf4b1('0x8f')][_0xf4b1('0x31')]({'where':{'id':_0x41560e[_0xf4b1('0x90')]['id']}})[_0xf4b1('0x25')](handleEntityNotFound(_0x4e0791,null))[_0xf4b1('0x25')](function(_0x31cff2){if(_0x31cff2){_0x10cc37['model']=_[_0xf4b1('0x2c')](db[_0xf4b1('0xa9')]['rawAttributes']);_0x10cc37[_0xf4b1('0x37')]=_[_0xf4b1('0x2c')](_0x41560e[_0xf4b1('0x37')]);_0x10cc37['filters']=_[_0xf4b1('0x38')](_0x10cc37[_0xf4b1('0x39')],_0x10cc37[_0xf4b1('0x37')]);_0x46abd0[_0xf4b1('0x3a')]=_[_0xf4b1('0x38')](_0x10cc37[_0xf4b1('0x39')],qs[_0xf4b1('0x3b')](_0x41560e[_0xf4b1('0x37')][_0xf4b1('0x3b')]));_0x46abd0[_0xf4b1('0x3a')]=_0x46abd0['attributes'][_0xf4b1('0x34')]?_0x46abd0[_0xf4b1('0x3a')]:_0x10cc37[_0xf4b1('0x39')];if(!_0x41560e[_0xf4b1('0x37')][_0xf4b1('0x3c')](_0xf4b1('0x3d'))){_0x46abd0['limit']=qs[_0xf4b1('0x20')](_0x41560e['query']['limit']);_0x46abd0[_0xf4b1('0x1f')]=qs[_0xf4b1('0x1f')](_0x41560e[_0xf4b1('0x37')][_0xf4b1('0x1f')]);}_0x46abd0[_0xf4b1('0x3e')]=qs['sort'](_0x41560e[_0xf4b1('0x37')][_0xf4b1('0x3f')]);_0x46abd0[_0xf4b1('0x40')]=qs['filters'](_['pick'](_0x41560e['query'],_0x10cc37['filters']));_0x46abd0['where'][_0xf4b1('0xc8')]=_0x31cff2['id'];if(_0x41560e[_0xf4b1('0x37')]['filter']){_0x46abd0[_0xf4b1('0x40')]=_[_0xf4b1('0x85')](_0x46abd0[_0xf4b1('0x40')],{'$or':_[_0xf4b1('0x54')](_0x46abd0[_0xf4b1('0x3a')],function(_0x38db9b){var _0x33fdc6={};_0x33fdc6[_0x38db9b]={'$like':'%'+_0x41560e[_0xf4b1('0x37')]['filter']+'%'};return _0x33fdc6;})});}_0x46abd0=_[_0xf4b1('0x85')]({},_0x46abd0,_0x41560e[_0xf4b1('0xc3')]);return db['CmHopperFinal'][_0xf4b1('0x1e')]({'where':_0x46abd0['where']})['then'](function(_0x3fc3b0){_0x58999c[_0xf4b1('0x1e')]=_0x3fc3b0;if(_0x41560e['query'][_0xf4b1('0xcc')]){_0x46abd0[_0xf4b1('0xcd')]=[{'all':!![]}];}return db['CmHopperFinal']['findAll'](_0x46abd0);})[_0xf4b1('0x25')](function(_0x3d0af9){_0x58999c['rows']=_0x3d0af9;return _0x58999c;});}})[_0xf4b1('0x25')](respondWithFilteredResult(_0x4e0791,_0x46abd0))[_0xf4b1('0x96')](handleError(_0x4e0791,null));};exports[_0xf4b1('0xcf')]=function(_0x3ed864,_0x2a40f8,_0x581af8){var _0x51d127={'raw':!![],'where':{}};var _0x118948={};var _0xe385d0={'count':0x0,'rows':[]};return db[_0xf4b1('0x8f')][_0xf4b1('0x31')]({'where':{'id':_0x3ed864['params']['id']}})[_0xf4b1('0x25')](handleEntityNotFound(_0x2a40f8,null))[_0xf4b1('0x25')](function(_0x7951b8){if(_0x7951b8){_0x118948[_0xf4b1('0x39')]=_[_0xf4b1('0x2c')](db[_0xf4b1('0xae')][_0xf4b1('0xc1')]);_0x118948[_0xf4b1('0x37')]=_['keys'](_0x3ed864[_0xf4b1('0x37')]);_0x118948[_0xf4b1('0x41')]=_['intersection'](_0x118948[_0xf4b1('0x39')],_0x118948[_0xf4b1('0x37')]);_0x51d127[_0xf4b1('0x3a')]=_[_0xf4b1('0x38')](_0x118948[_0xf4b1('0x39')],qs[_0xf4b1('0x3b')](_0x3ed864[_0xf4b1('0x37')][_0xf4b1('0x3b')]));_0x51d127[_0xf4b1('0x3a')]=_0x51d127['attributes'][_0xf4b1('0x34')]?_0x51d127[_0xf4b1('0x3a')]:_0x118948[_0xf4b1('0x39')];if(!_0x3ed864[_0xf4b1('0x37')][_0xf4b1('0x3c')]('nolimit')){_0x51d127[_0xf4b1('0x20')]=qs[_0xf4b1('0x20')](_0x3ed864[_0xf4b1('0x37')][_0xf4b1('0x20')]);_0x51d127[_0xf4b1('0x1f')]=qs[_0xf4b1('0x1f')](_0x3ed864[_0xf4b1('0x37')]['offset']);}_0x51d127[_0xf4b1('0x3e')]=qs['sort'](_0x3ed864[_0xf4b1('0x37')][_0xf4b1('0x3f')]);_0x51d127[_0xf4b1('0x40')]=qs[_0xf4b1('0x41')](_['pick'](_0x3ed864[_0xf4b1('0x37')],_0x118948['filters']));_0x51d127[_0xf4b1('0x40')]['ContactId']=_0x7951b8['id'];if(_0x3ed864['query'][_0xf4b1('0x61')]){_0x51d127[_0xf4b1('0x40')]=_[_0xf4b1('0x85')](_0x51d127['where'],{'$or':_['map'](_0x51d127[_0xf4b1('0x3a')],function(_0x2a7e7c){var _0x1736bb={};_0x1736bb[_0x2a7e7c]={'$like':'%'+_0x3ed864[_0xf4b1('0x37')][_0xf4b1('0x61')]+'%'};return _0x1736bb;})});}_0x51d127=_[_0xf4b1('0x85')]({},_0x51d127,_0x3ed864['options']);return db['JscriptySessionReport'][_0xf4b1('0x1e')]({'where':_0x51d127[_0xf4b1('0x40')]})[_0xf4b1('0x25')](function(_0x21fc97){_0xe385d0[_0xf4b1('0x1e')]=_0x21fc97;if(_0x3ed864[_0xf4b1('0x37')]['includeAll']){_0x51d127['include']=[{'all':!![]}];}return db['JscriptySessionReport']['findAll'](_0x51d127);})['then'](function(_0x566408){_0xe385d0['rows']=_0x566408;return _0xe385d0;});}})[_0xf4b1('0x25')](respondWithFilteredResult(_0x2a40f8,_0x51d127))[_0xf4b1('0x96')](handleError(_0x2a40f8,null));};exports['uploadCsv']=function(_0x2401c0,_0x275b2b,_0x28f2be){try{if(!_0x2401c0['body'][_0xf4b1('0x66')]){throw new Error(_0xf4b1('0xd0'));}if(!_0x2401c0[_0xf4b1('0x97')]['binding_keys']){throw new Error(_0xf4b1('0xd1'));}if(!_0x2401c0[_0xf4b1('0x97')][_0xf4b1('0xd2')]){throw new Error(_0xf4b1('0xd3'));}if(!_0x2401c0['body'][_0xf4b1('0xd4')]){throw new Error('Unable\x20to\x20synchronize\x20socket,\x20no\x20timestamp\x20passed');}var _0x520de5=_0x2401c0['body'][_0xf4b1('0xd5')]['split'](',');var _0x15ccb8=_0x2401c0[_0xf4b1('0x97')]['binding_values'][_0xf4b1('0x53')](',');if(!_0x520de5[_0xf4b1('0x34')]||!_0x15ccb8[_0xf4b1('0x34')]||_0x520de5['length']!==_0x15ccb8[_0xf4b1('0x34')]){throw new Error(_0xf4b1('0xd6'));}_0x2401c0[_0xf4b1('0x97')][_0xf4b1('0x3b')]=_[_0xf4b1('0xd7')](_0x520de5,_0x15ccb8);if(!_0x2401c0[_0xf4b1('0x97')][_0xf4b1('0x3b')][_0xf4b1('0xc0')]){throw new Error(_0xf4b1('0xd8'));}if(!_0x2401c0[_0xf4b1('0x97')][_0xf4b1('0x3b')][_0xf4b1('0xd9')]){throw new Error(_0xf4b1('0xda'));}var _0x21a08e=path['join'](config[_0xf4b1('0xdb')],_0xf4b1('0xdc'),_0x2401c0['file'][_0xf4b1('0xdd')]);fs[_0xf4b1('0xde')](_0x21a08e,parseInt(_0xf4b1('0xdf'),0x8));var _0x41300f=require(_0xf4b1('0xe0'))['fork'](path[_0xf4b1('0x9a')](__dirname,'../../components/import/cm/csv'),[_0x21a08e,_0x2401c0[_0xf4b1('0x97')][_0xf4b1('0xd5')],_0x2401c0['body']['binding_values'],_0x2401c0['body'][_0xf4b1('0x66')],_0x2401c0[_0xf4b1('0x97')][_0xf4b1('0xe1')],_0x2401c0[_0xf4b1('0x97')][_0xf4b1('0xb4')],_0x2401c0[_0xf4b1('0x97')][_0xf4b1('0xd4')]]);return _0x275b2b[_0xf4b1('0x27')](0xc8)[_0xf4b1('0x1d')]({'message':'File\x20uploaded\x20correctly!','pid':_0x41300f[_0xf4b1('0xe2')]});}catch(_0x52d3ab){return _0x275b2b[_0xf4b1('0x27')](0x1f4)['send'](_0x52d3ab);}};exports[_0xf4b1('0xe3')]=function(_0x3aaeff,_0x536fa8,_0x32e138){var _0x5ecd7b=fs[_0xf4b1('0xe4')](_0x3aaeff[_0xf4b1('0xe5')][_0xf4b1('0xe6')]);Papa['parse'](_0x5ecd7b,{'header':!![],'skipEmptyLines':!![],'preview':0x1,'complete':function(_0x18593f){return _0x536fa8[_0xf4b1('0x27')](0xc8)['json']({'file':_0x3aaeff[_0xf4b1('0xe5')],'fields':_0x18593f[_0xf4b1('0xe7')]['fields']});}});};exports[_0xf4b1('0xe8')]=function(_0x3f08a2,_0x399a48,_0x1e3d1b){return db[_0xf4b1('0x57')][_0xf4b1('0x94')]({'raw':!![],'attributes':['id'],'where':{'role':_0xf4b1('0x7d')}})['then'](function(_0x464b6b){var _0x1205b3=![];if(!_0x3f08a2[_0xf4b1('0x97')]['ListId']){throw new Error(_0xf4b1('0xd0'));}if(!_0x3f08a2[_0xf4b1('0x97')][_0xf4b1('0xe9')][_0xf4b1('0xc0')]){throw new Error(_0xf4b1('0xd8'));}if(!_0x3f08a2[_0xf4b1('0x97')][_0xf4b1('0xe9')][_0xf4b1('0xd9')]){throw new Error(_0xf4b1('0xda'));}if(!_0x3f08a2[_0xf4b1('0x97')][_0xf4b1('0xd4')]){throw new Error('Unable\x20to\x20synchronize\x20socket,\x20no\x20timestamp\x20passed');}var _0x3b204b=require(_0xf4b1('0xe0'))[_0xf4b1('0xea')](path[_0xf4b1('0x9a')](__dirname,_0xf4b1('0xeb')),[_0x3f08a2[_0xf4b1('0x90')]['id'],JSON[_0xf4b1('0xec')](_0x3f08a2[_0xf4b1('0x97')]),JSON[_0xf4b1('0xec')](_0x464b6b)]);_0x3b204b['on']('message',function(_0x222bf9){_0x1205b3=!![];return _0x399a48[_0xf4b1('0x27')](0xc8)['json']({'message':_0xf4b1('0xed'),'pid':_0x3b204b[_0xf4b1('0xe2')]});});_0x3b204b['on'](_0xf4b1('0xee'),function(_0x102114){if(_0x102114&&!_0x1205b3){return _0x399a48['status'](0x1f4)[_0xf4b1('0x1d')]({'message':'error\x20child\x20process','pid':_0x3b204b[_0xf4b1('0xe2')]});}});})[_0xf4b1('0x96')](handleError(_0x399a48,null));};exports[_0xf4b1('0xef')]=function(_0xf7288b,_0x32e50f){var _0xd77306=['mail',_0xf4b1('0xf0'),_0xf4b1('0xf1'),_0xf4b1('0xf2'),'fax','whatsapp',_0xf4b1('0xf3')];var _0x3b1afe={'offset':0x0,'order':qs[_0xf4b1('0x3f')](_0xf4b1('0xf4'))},_0x4b2093={'count':0x0,'rows':[]};Promise['resolve']()[_0xf4b1('0x25')](function(){if(_0xf7288b[_0xf4b1('0x37')][_0xf4b1('0xf5')]){if(!_['includes'](_0xd77306,_0xf7288b[_0xf4b1('0x37')]['channel']['toLowerCase']())){throw new Error('Invalid\x20channel');}_0xd77306=[_0xf7288b[_0xf4b1('0x37')][_0xf4b1('0xf5')][_0xf4b1('0xf6')]()];}if(_0xf7288b[_0xf4b1('0x37')][_0xf4b1('0xf7')]){try{var _0x470282=JSON[_0xf4b1('0xf8')](_0xf7288b[_0xf4b1('0x37')][_0xf4b1('0xf7')]);if(!moment(_0x470282[_0xf4b1('0x44')])['isValid']()){throw new Error('Invalid\x20date\x20for\x20range\x20from\x20filter');}if(!moment(_0x470282['to'])[_0xf4b1('0xf9')]()){throw new Error(_0xf4b1('0xfa'));}}catch(_0x1f6b0d){throw new Error(_0xf4b1('0xfb'));}}if(!_0xf7288b['query'][_0xf4b1('0x3c')](_0xf4b1('0x3d'))){_0x3b1afe['limit']=qs[_0xf4b1('0x20')](_0xf7288b[_0xf4b1('0x37')][_0xf4b1('0x20')]||0xa);_0x3b1afe['offset']=qs[_0xf4b1('0x1f')](_0xf7288b[_0xf4b1('0x37')][_0xf4b1('0x1f')]);}var _0x59fde7=_0xd77306[_0xf4b1('0x54')](function(_0x1f8f6e){if(_0x1f8f6e===_0xf4b1('0xf3')){var _0x3a2b1c={'attributes':['id',_0xf4b1('0xfc'),_0xf4b1('0x36'),_0xf4b1('0xfd'),_0xf4b1('0xfe'),_0xf4b1('0xff'),_0xf4b1('0x100'),_0xf4b1('0x101'),_0xf4b1('0x102'),_0xf4b1('0x103'),_0xf4b1('0x104'),'userDisposition','userSecondDisposition',_0xf4b1('0x105')],'where':{'ContactId':_0xf7288b[_0xf4b1('0x90')]['id']},'include':[{'model':db[_0xf4b1('0x57')],'as':_0xf4b1('0x57'),'attributes':['id',_0xf4b1('0x29'),'fullname',_0xf4b1('0x106')]}],'order':[[_0xf4b1('0x104'),_0xf4b1('0x107')]]};if(_0xf7288b[_0xf4b1('0x37')][_0xf4b1('0xf7')]){_0x3a2b1c[_0xf4b1('0x40')][_0xf4b1('0x104')]={'$gte':_0x470282['from'],'$lte':_0x470282['to']};}return db[_0xf4b1('0xaa')][_0xf4b1('0x108')](_0x3a2b1c)['then'](function(_0x421489){_0x4b2093[_0xf4b1('0x1e')]+=_0x421489['count'];return _[_0xf4b1('0x54')](_0x421489[_0xf4b1('0xc9')],function(_0x1f37c0){var _0x51f2ac=_0x1f37c0[_0xf4b1('0x98')]({'plain':!![]});_0x51f2ac[_0xf4b1('0xf5')]=_0x1f8f6e;if(_0x51f2ac['User']){_0x51f2ac[_0xf4b1('0x57')]={'id':_0x51f2ac[_0xf4b1('0x57')]['id'],'name':_0x51f2ac[_0xf4b1('0x57')][_0xf4b1('0x29')],'fullname':_0x51f2ac[_0xf4b1('0x57')]['fullname'],'alias':_0x51f2ac[_0xf4b1('0x57')]['alias']};}return _0x51f2ac;});});}else{var _0xf42e8d=_[_0xf4b1('0x109')](_0x1f8f6e)+(_0x1f8f6e===_0xf4b1('0xf0')?'Website':_0xf4b1('0x10a'));var _0x32d462={'attributes':['id',_0xf4b1('0x10b'),'closedAt','createdAt',_0xf4b1('0x103'),_0xf4b1('0x10c'),_0xf4b1('0x10d'),'thirdDisposition',_0xf4b1('0x10e'),_0xf42e8d+'Id'],'where':{'ContactId':_0xf7288b[_0xf4b1('0x90')]['id']},'include':[{'model':db[_0xf42e8d],'as':_0xf4b1('0x10a'),'attributes':['id',_0xf4b1('0x29'),_0xf4b1('0x10f')]},{'model':db['User'],'as':'Owner','attributes':['id',_0xf4b1('0x29'),_0xf4b1('0x110')]},{'model':db['Tag'],'as':_0xf4b1('0x8e'),'attributes':['id',_0xf4b1('0x29'),'color'],'through':{'attributes':[]}}],'order':[[_0xf4b1('0x104'),_0xf4b1('0x107')]]};if(_0xf7288b[_0xf4b1('0x37')][_0xf4b1('0xf7')]){_0x32d462[_0xf4b1('0x40')][_0xf4b1('0x104')]={'$gte':_0x470282[_0xf4b1('0x44')],'$lte':_0x470282['to']};}switch(_0x1f8f6e){case _0xf4b1('0xf0'):_0x32d462[_0xf4b1('0x3a')][_0xf4b1('0x2f')]('browserName',_0xf4b1('0x111'),'customerPort',_0xf4b1('0x112'),'osName',_0xf4b1('0x113'),'ratingType',_0xf4b1('0x114'),_0xf4b1('0x115'));break;case'mail':_0x32d462[_0xf4b1('0x3a')][_0xf4b1('0x2f')]('subject','substatus');break;case _0xf4b1('0xf2'):_0x32d462[_0xf4b1('0x3a')][_0xf4b1('0x2f')](_0xf4b1('0x116'),'threadId');break;}return db[_[_0xf4b1('0x109')](_0x1f8f6e)+'Interaction'][_0xf4b1('0x108')](_0x32d462)['then'](function(_0x852e20){_0x4b2093[_0xf4b1('0x1e')]+=_0x852e20[_0xf4b1('0x1e')];return _[_0xf4b1('0x54')](_0x852e20[_0xf4b1('0xc9')],function(_0x5e204a){var _0x472e78=_0x5e204a[_0xf4b1('0x98')]({'plain':!![]});_0x472e78[_0xf4b1('0xf5')]=_0x1f8f6e;if(_0x472e78[_0xf4b1('0x117')]){_0x472e78['Owner']={'id':_0x472e78[_0xf4b1('0x117')]['id'],'name':_0x472e78[_0xf4b1('0x117')][_0xf4b1('0x29')],'fullname':_0x472e78[_0xf4b1('0x117')][_0xf4b1('0x110')]};}return _0x472e78;});});}});return Promise[_0xf4b1('0x33')](_0x59fde7);})[_0xf4b1('0x25')](function(_0x29c2dc){return _(_0x29c2dc)[_0xf4b1('0x118')]()[_0xf4b1('0x119')](_0xf4b1('0x104'))['reverse']()[_0xf4b1('0x52')]();})[_0xf4b1('0x25')](function(_0xcccd66){_0x4b2093[_0xf4b1('0xc9')]=_0x3b1afe['limit']?_0xcccd66['slice'](_0x3b1afe[_0xf4b1('0x1f')],_0x3b1afe[_0xf4b1('0x1f')]+_0x3b1afe[_0xf4b1('0x20')]):_0xcccd66;return _0x4b2093;})[_0xf4b1('0x25')](respondWithFilteredResult(_0x32e50f,_0x3b1afe))[_0xf4b1('0x96')](handleError(_0x32e50f,null));};