e4470e531101336953d3a34eab6ea7c6aad0304e
[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 _0x9999=['result','catch','util','moment','bluebird','randomstring','ioredis','../../mysqldb','rpc','../../config/environment','client','http','info','UserWhatsappQueue,\x20%s,\x20%s','request\x20sent','debug','code','error','message'];(function(_0x20be9f,_0x4e3110){var _0x53581a=function(_0x4b628b){while(--_0x4b628b){_0x20be9f['push'](_0x20be9f['shift']());}};_0x53581a(++_0x4e3110);}(_0x9999,0x16b));var _0x9999=function(_0x51b917,_0x3f31bd){_0x51b917=_0x51b917-0x0;var _0x334616=_0x9999[_0x51b917];return _0x334616;};'use strict';var _=require('lodash');var util=require(_0x9999('0x0'));var moment=require(_0x9999('0x1'));var BPromise=require(_0x9999('0x2'));var rs=require(_0x9999('0x3'));var fs=require('fs');var Redis=require(_0x9999('0x4'));var db=require(_0x9999('0x5'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x9999('0x6'));var config=require(_0x9999('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x9999('0x8')][_0x9999('0x9')]({'port':0x232a});function respondWithRpcPromise(_0xa01c3,_0x14ab30,_0x15a6bd){return new BPromise(function(_0x29db08,_0x21b74a){return client['request'](_0xa01c3,_0x15a6bd)['then'](function(_0x2d587f){logger[_0x9999('0xa')](_0x9999('0xb'),_0x14ab30,_0x9999('0xc'));logger[_0x9999('0xd')]('UserWhatsappQueue,\x20%s,\x20%s,\x20%s',_0x14ab30,'request\x20sent',JSON['stringify'](_0x2d587f));if(_0x2d587f['error']){if(_0x2d587f['error'][_0x9999('0xe')]===0x1f4){logger['error']('UserWhatsappQueue,\x20%s,\x20%s',_0x14ab30,_0x2d587f[_0x9999('0xf')][_0x9999('0x10')]);return _0x21b74a(_0x2d587f['error'][_0x9999('0x10')]);}logger[_0x9999('0xf')](_0x9999('0xb'),_0x14ab30,_0x2d587f[_0x9999('0xf')][_0x9999('0x10')]);return _0x29db08(_0x2d587f[_0x9999('0xf')][_0x9999('0x10')]);}else{logger[_0x9999('0xa')]('UserWhatsappQueue,\x20%s,\x20%s',_0x14ab30,_0x9999('0xc'));_0x29db08(_0x2d587f[_0x9999('0x11')][_0x9999('0x10')]);}})[_0x9999('0x12')](function(_0x22f9c4){logger[_0x9999('0xf')](_0x9999('0xb'),_0x14ab30,_0x22f9c4);_0x21b74a(_0x22f9c4);});});}