7254ce2eef9460f51ed7187db3119aac52bf9496
[motion2.git] / server / api / userWhatsappQueue / userWhatsappQueue.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 _0x9d96=['code','message','result','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','../../config/environment','client','http','info','UserWhatsappQueue,\x20%s,\x20%s','request\x20sent','debug','UserWhatsappQueue,\x20%s,\x20%s,\x20%s','error'];(function(_0x1c0bad,_0x2e9bb6){var _0x2348e3=function(_0x199b2d){while(--_0x199b2d){_0x1c0bad['push'](_0x1c0bad['shift']());}};_0x2348e3(++_0x2e9bb6);}(_0x9d96,0x1a5));var _0x69d9=function(_0x6ab2bb,_0x48dd89){_0x6ab2bb=_0x6ab2bb-0x0;var _0x2d1aba=_0x9d96[_0x6ab2bb];return _0x2d1aba;};'use strict';var _=require('lodash');var util=require(_0x69d9('0x0'));var moment=require(_0x69d9('0x1'));var BPromise=require(_0x69d9('0x2'));var rs=require(_0x69d9('0x3'));var fs=require('fs');var Redis=require(_0x69d9('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x69d9('0x5'));var logger=require(_0x69d9('0x6'))('rpc');var config=require(_0x69d9('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x69d9('0x8')][_0x69d9('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x8704f9,_0x2e8f35,_0x35e3c6){return new BPromise(function(_0x4348fc,_0x110cc2){return client['request'](_0x8704f9,_0x35e3c6)['then'](function(_0x1b09c0){logger[_0x69d9('0xa')](_0x69d9('0xb'),_0x2e8f35,_0x69d9('0xc'));logger[_0x69d9('0xd')](_0x69d9('0xe'),_0x2e8f35,_0x69d9('0xc'),JSON['stringify'](_0x1b09c0));if(_0x1b09c0['error']){if(_0x1b09c0[_0x69d9('0xf')][_0x69d9('0x10')]===0x1f4){logger[_0x69d9('0xf')]('UserWhatsappQueue,\x20%s,\x20%s',_0x2e8f35,_0x1b09c0[_0x69d9('0xf')]['message']);return _0x110cc2(_0x1b09c0[_0x69d9('0xf')][_0x69d9('0x11')]);}logger[_0x69d9('0xf')](_0x69d9('0xb'),_0x2e8f35,_0x1b09c0[_0x69d9('0xf')][_0x69d9('0x11')]);return _0x4348fc(_0x1b09c0[_0x69d9('0xf')][_0x69d9('0x11')]);}else{logger[_0x69d9('0xa')]('UserWhatsappQueue,\x20%s,\x20%s',_0x2e8f35,_0x69d9('0xc'));_0x4348fc(_0x1b09c0[_0x69d9('0x12')][_0x69d9('0x11')]);}})['catch'](function(_0x5a0996){logger[_0x69d9('0xf')](_0x69d9('0xb'),_0x2e8f35,_0x5a0996);_0x110cc2(_0x5a0996);});});}