Built motion from commit ffdca78c.|2.6.24
[motion2.git] / server / api / whatsappQueue / whatsappQueue.rpc.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 _0x9bc6=['options','raw','attributes','limit','include','map','model','WhatsappQueue','find','where','ShowWhatsappQueue','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','redis','localhost','socket.io-emitter','./whatsappQueue.socket','request','then','WhatsappQueue,\x20%s,\x20%s','debug','WhatsappQueue,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','info','result','catch','GetWhatsappQueue'];(function(_0x179c4a,_0x10eb06){var _0x5d1879=function(_0x1f1dcd){while(--_0x1f1dcd){_0x179c4a['push'](_0x179c4a['shift']());}};_0x5d1879(++_0x10eb06);}(_0x9bc6,0x1a5));var _0x69bc=function(_0x214450,_0x1f80ad){_0x214450=_0x214450-0x0;var _0xf0321f=_0x9bc6[_0x214450];return _0xf0321f;};'use strict';var _=require(_0x69bc('0x0'));var util=require(_0x69bc('0x1'));var moment=require(_0x69bc('0x2'));var BPromise=require('bluebird');var rs=require(_0x69bc('0x3'));var fs=require('fs');var Redis=require(_0x69bc('0x4'));var db=require(_0x69bc('0x5'))['db'];var utils=require(_0x69bc('0x6'));var logger=require(_0x69bc('0x7'))(_0x69bc('0x8'));var config=require(_0x69bc('0x9'));var jayson=require('jayson/promise');var client=jayson[_0x69bc('0xa')][_0x69bc('0xb')]({'port':0x232a});config['redis']=_['defaults'](config[_0x69bc('0xc')],{'host':_0x69bc('0xd'),'port':0x18eb});var socket=require(_0x69bc('0xe'))(new Redis(config[_0x69bc('0xc')]));require(_0x69bc('0xf'))['register'](socket);function respondWithRpcPromise(_0xf43210,_0x925345,_0x248e0f){return new BPromise(function(_0x3daf07,_0x13315d){return client[_0x69bc('0x10')](_0xf43210,_0x248e0f)[_0x69bc('0x11')](function(_0x3b4d36){logger['info'](_0x69bc('0x12'),_0x925345,'request\x20sent');logger[_0x69bc('0x13')](_0x69bc('0x14'),_0x925345,_0x69bc('0x15'),JSON[_0x69bc('0x16')](_0x3b4d36));if(_0x3b4d36[_0x69bc('0x17')]){if(_0x3b4d36[_0x69bc('0x17')][_0x69bc('0x18')]===0x1f4){logger[_0x69bc('0x17')](_0x69bc('0x12'),_0x925345,_0x3b4d36[_0x69bc('0x17')][_0x69bc('0x19')]);return _0x13315d(_0x3b4d36[_0x69bc('0x17')][_0x69bc('0x19')]);}logger[_0x69bc('0x17')](_0x69bc('0x12'),_0x925345,_0x3b4d36['error'][_0x69bc('0x19')]);return _0x3daf07(_0x3b4d36[_0x69bc('0x17')]['message']);}else{logger[_0x69bc('0x1a')](_0x69bc('0x12'),_0x925345,'request\x20sent');_0x3daf07(_0x3b4d36[_0x69bc('0x1b')][_0x69bc('0x19')]);}})[_0x69bc('0x1c')](function(_0xbe95d0){logger['error'](_0x69bc('0x12'),_0x925345,_0xbe95d0);_0x13315d(_0xbe95d0);});});}exports[_0x69bc('0x1d')]=function(_0x4c1a97){var _0x33ce0b=this;return new Promise(function(_0x5c3162,_0x397bbf){return db['WhatsappQueue']['findAll']({'raw':_0x4c1a97[_0x69bc('0x1e')]?_0x4c1a97[_0x69bc('0x1e')][_0x69bc('0x1f')]===undefined?!![]:![]:!![],'where':_0x4c1a97[_0x69bc('0x1e')]?_0x4c1a97[_0x69bc('0x1e')]['where']||null:null,'attributes':_0x4c1a97[_0x69bc('0x1e')]?_0x4c1a97[_0x69bc('0x1e')][_0x69bc('0x20')]||null:null,'limit':_0x4c1a97['options']?_0x4c1a97[_0x69bc('0x1e')][_0x69bc('0x21')]||null:null,'include':_0x4c1a97[_0x69bc('0x1e')]?_0x4c1a97['options'][_0x69bc('0x22')]?_[_0x69bc('0x23')](_0x4c1a97[_0x69bc('0x1e')][_0x69bc('0x22')],function(_0x2b4d5e){return{'model':db[_0x2b4d5e[_0x69bc('0x24')]],'as':_0x2b4d5e['as'],'attributes':_0x2b4d5e[_0x69bc('0x20')],'include':_0x2b4d5e[_0x69bc('0x22')]?_[_0x69bc('0x23')](_0x2b4d5e[_0x69bc('0x22')],function(_0x179750){return{'model':db[_0x179750['model']],'as':_0x179750['as'],'attributes':_0x179750[_0x69bc('0x20')],'include':_0x179750[_0x69bc('0x22')]?_['map'](_0x179750[_0x69bc('0x22')],function(_0xeaca9d){return{'model':db[_0xeaca9d['model']],'as':_0xeaca9d['as'],'attributes':_0xeaca9d[_0x69bc('0x20')]};}):[]};}):[]};}):[]:[]})[_0x69bc('0x11')](function(_0xef4354){logger[_0x69bc('0x1a')](_0x69bc('0x1d'),_0x4c1a97);logger[_0x69bc('0x13')](_0x69bc('0x1d'),_0x4c1a97,JSON['stringify'](_0xef4354));_0x5c3162(_0xef4354);})['catch'](function(_0x1c212b){logger[_0x69bc('0x17')]('GetWhatsappQueue',_0x1c212b[_0x69bc('0x19')],_0x4c1a97);_0x397bbf(_0x33ce0b[_0x69bc('0x17')](0x1f4,_0x1c212b[_0x69bc('0x19')]));});});};exports['ShowWhatsappQueue']=function(_0x278b52){var _0x3ea86d=this;return new Promise(function(_0x16921f,_0x573db2){return db[_0x69bc('0x25')][_0x69bc('0x26')]({'raw':_0x278b52[_0x69bc('0x1e')]?_0x278b52[_0x69bc('0x1e')][_0x69bc('0x1f')]===undefined?!![]:![]:!![],'where':_0x278b52[_0x69bc('0x1e')]?_0x278b52[_0x69bc('0x1e')][_0x69bc('0x27')]||null:null,'attributes':_0x278b52[_0x69bc('0x1e')]?_0x278b52['options']['attributes']||null:null,'include':_0x278b52[_0x69bc('0x1e')]?_0x278b52[_0x69bc('0x1e')][_0x69bc('0x22')]?_['map'](_0x278b52[_0x69bc('0x1e')][_0x69bc('0x22')],function(_0x23c36d){return{'model':db[_0x23c36d[_0x69bc('0x24')]],'as':_0x23c36d['as'],'attributes':_0x23c36d['attributes'],'include':_0x23c36d[_0x69bc('0x22')]?_[_0x69bc('0x23')](_0x23c36d['include'],function(_0x363df0){return{'model':db[_0x363df0['model']],'as':_0x363df0['as'],'attributes':_0x363df0['attributes'],'include':_0x363df0[_0x69bc('0x22')]?_[_0x69bc('0x23')](_0x363df0[_0x69bc('0x22')],function(_0xf4567e){return{'model':db[_0xf4567e['model']],'as':_0xf4567e['as'],'attributes':_0xf4567e[_0x69bc('0x20')]};}):[]};}):[]};}):[]:[]})[_0x69bc('0x11')](function(_0x54a32a){logger[_0x69bc('0x1a')]('ShowWhatsappQueue',_0x278b52);logger['debug'](_0x69bc('0x28'),_0x278b52,JSON[_0x69bc('0x16')](_0x54a32a));_0x16921f(_0x54a32a);})[_0x69bc('0x1c')](function(_0x3789e5){logger[_0x69bc('0x17')](_0x69bc('0x28'),_0x3789e5[_0x69bc('0x19')],_0x278b52);_0x573db2(_0x3ea86d[_0x69bc('0x17')](0x1f4,_0x3789e5[_0x69bc('0x19')]));});});};