Built motion from commit f0b1811d.|2.6.6
[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 _0x3f89=['redis','defaults','localhost','./whatsappQueue.socket','register','request','then','info','request\x20sent','error','code','WhatsappQueue,\x20%s,\x20%s','message','result','catch','GetWhatsappQueue','WhatsappQueue','findAll','options','raw','where','limit','include','map','model','attributes','debug','stringify','ShowWhatsappQueue','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/environment','jayson/promise','client','http'];(function(_0x25d100,_0x442e9e){var _0x4800ea=function(_0xf84135){while(--_0xf84135){_0x25d100['push'](_0x25d100['shift']());}};_0x4800ea(++_0x442e9e);}(_0x3f89,0xe5));var _0x93f8=function(_0x17ddf4,_0x7e9b47){_0x17ddf4=_0x17ddf4-0x0;var _0x5d6a36=_0x3f89[_0x17ddf4];return _0x5d6a36;};'use strict';var _=require(_0x93f8('0x0'));var util=require(_0x93f8('0x1'));var moment=require(_0x93f8('0x2'));var BPromise=require(_0x93f8('0x3'));var rs=require(_0x93f8('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x93f8('0x5'))['db'];var utils=require(_0x93f8('0x6'));var logger=require('../../config/logger')('rpc');var config=require(_0x93f8('0x7'));var jayson=require(_0x93f8('0x8'));var client=jayson[_0x93f8('0x9')][_0x93f8('0xa')]({'port':0x232a});config[_0x93f8('0xb')]=_[_0x93f8('0xc')](config[_0x93f8('0xb')],{'host':_0x93f8('0xd'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x93f8('0xb')]));require(_0x93f8('0xe'))[_0x93f8('0xf')](socket);function respondWithRpcPromise(_0x28798a,_0x3f058e,_0x3a0414){return new BPromise(function(_0x1939e4,_0x478779){return client[_0x93f8('0x10')](_0x28798a,_0x3a0414)[_0x93f8('0x11')](function(_0x5b8d81){logger[_0x93f8('0x12')]('WhatsappQueue,\x20%s,\x20%s',_0x3f058e,_0x93f8('0x13'));logger['debug']('WhatsappQueue,\x20%s,\x20%s,\x20%s',_0x3f058e,_0x93f8('0x13'),JSON['stringify'](_0x5b8d81));if(_0x5b8d81[_0x93f8('0x14')]){if(_0x5b8d81['error'][_0x93f8('0x15')]===0x1f4){logger[_0x93f8('0x14')](_0x93f8('0x16'),_0x3f058e,_0x5b8d81[_0x93f8('0x14')]['message']);return _0x478779(_0x5b8d81[_0x93f8('0x14')][_0x93f8('0x17')]);}logger[_0x93f8('0x14')](_0x93f8('0x16'),_0x3f058e,_0x5b8d81[_0x93f8('0x14')][_0x93f8('0x17')]);return _0x1939e4(_0x5b8d81['error'][_0x93f8('0x17')]);}else{logger[_0x93f8('0x12')](_0x93f8('0x16'),_0x3f058e,_0x93f8('0x13'));_0x1939e4(_0x5b8d81[_0x93f8('0x18')][_0x93f8('0x17')]);}})[_0x93f8('0x19')](function(_0xc1c375){logger[_0x93f8('0x14')](_0x93f8('0x16'),_0x3f058e,_0xc1c375);_0x478779(_0xc1c375);});});}exports[_0x93f8('0x1a')]=function(_0x4f03a7){var _0x3e820b=this;return new Promise(function(_0x4daa65,_0x4e4b79){return db[_0x93f8('0x1b')][_0x93f8('0x1c')]({'raw':_0x4f03a7[_0x93f8('0x1d')]?_0x4f03a7[_0x93f8('0x1d')][_0x93f8('0x1e')]===undefined?!![]:![]:!![],'where':_0x4f03a7[_0x93f8('0x1d')]?_0x4f03a7[_0x93f8('0x1d')][_0x93f8('0x1f')]||null:null,'attributes':_0x4f03a7[_0x93f8('0x1d')]?_0x4f03a7[_0x93f8('0x1d')]['attributes']||null:null,'limit':_0x4f03a7[_0x93f8('0x1d')]?_0x4f03a7['options'][_0x93f8('0x20')]||null:null,'include':_0x4f03a7['options']?_0x4f03a7[_0x93f8('0x1d')][_0x93f8('0x21')]?_[_0x93f8('0x22')](_0x4f03a7[_0x93f8('0x1d')][_0x93f8('0x21')],function(_0x263291){return{'model':db[_0x263291[_0x93f8('0x23')]],'as':_0x263291['as'],'attributes':_0x263291[_0x93f8('0x24')],'include':_0x263291[_0x93f8('0x21')]?_[_0x93f8('0x22')](_0x263291[_0x93f8('0x21')],function(_0x3602db){return{'model':db[_0x3602db[_0x93f8('0x23')]],'as':_0x3602db['as'],'attributes':_0x3602db['attributes'],'include':_0x3602db['include']?_['map'](_0x3602db['include'],function(_0x418482){return{'model':db[_0x418482[_0x93f8('0x23')]],'as':_0x418482['as'],'attributes':_0x418482[_0x93f8('0x24')]};}):[]};}):[]};}):[]:[]})[_0x93f8('0x11')](function(_0x425a26){logger[_0x93f8('0x12')]('GetWhatsappQueue',_0x4f03a7);logger[_0x93f8('0x25')](_0x93f8('0x1a'),_0x4f03a7,JSON[_0x93f8('0x26')](_0x425a26));_0x4daa65(_0x425a26);})[_0x93f8('0x19')](function(_0x55863f){logger[_0x93f8('0x14')]('GetWhatsappQueue',_0x55863f[_0x93f8('0x17')],_0x4f03a7);_0x4e4b79(_0x3e820b[_0x93f8('0x14')](0x1f4,_0x55863f['message']));});});};exports['ShowWhatsappQueue']=function(_0x8b74be){var _0x4eb8a6=this;return new Promise(function(_0x363d68,_0x3da2eb){return db[_0x93f8('0x1b')]['find']({'raw':_0x8b74be[_0x93f8('0x1d')]?_0x8b74be['options'][_0x93f8('0x1e')]===undefined?!![]:![]:!![],'where':_0x8b74be[_0x93f8('0x1d')]?_0x8b74be[_0x93f8('0x1d')]['where']||null:null,'attributes':_0x8b74be[_0x93f8('0x1d')]?_0x8b74be[_0x93f8('0x1d')][_0x93f8('0x24')]||null:null,'include':_0x8b74be[_0x93f8('0x1d')]?_0x8b74be[_0x93f8('0x1d')][_0x93f8('0x21')]?_[_0x93f8('0x22')](_0x8b74be['options']['include'],function(_0x34511a){return{'model':db[_0x34511a[_0x93f8('0x23')]],'as':_0x34511a['as'],'attributes':_0x34511a['attributes'],'include':_0x34511a[_0x93f8('0x21')]?_[_0x93f8('0x22')](_0x34511a['include'],function(_0x489898){return{'model':db[_0x489898[_0x93f8('0x23')]],'as':_0x489898['as'],'attributes':_0x489898[_0x93f8('0x24')],'include':_0x489898[_0x93f8('0x21')]?_[_0x93f8('0x22')](_0x489898['include'],function(_0x5ecf86){return{'model':db[_0x5ecf86[_0x93f8('0x23')]],'as':_0x5ecf86['as'],'attributes':_0x5ecf86[_0x93f8('0x24')]};}):[]};}):[]};}):[]:[]})[_0x93f8('0x11')](function(_0x433db1){logger[_0x93f8('0x12')](_0x93f8('0x27'),_0x8b74be);logger[_0x93f8('0x25')]('ShowWhatsappQueue',_0x8b74be,JSON[_0x93f8('0x26')](_0x433db1));_0x363d68(_0x433db1);})['catch'](function(_0x387bcd){logger[_0x93f8('0x14')](_0x93f8('0x27'),_0x387bcd[_0x93f8('0x17')],_0x8b74be);_0x3da2eb(_0x4eb8a6[_0x93f8('0x14')](0x1f4,_0x387bcd[_0x93f8('0x17')]));});});};