9f46e37e21c65572d5df1fe4b07eae833cb3874b
[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 _0x266b=['http','request','then','UserWhatsappQueue,\x20%s,\x20%s','request\x20sent','debug','stringify','message','error','info','result','catch','util','moment','randomstring','../../mysqldb','rpc','../../config/environment','client'];(function(_0x22d696,_0x359d98){var _0x4f583b=function(_0x2764b7){while(--_0x2764b7){_0x22d696['push'](_0x22d696['shift']());}};_0x4f583b(++_0x359d98);}(_0x266b,0x1c1));var _0xb266=function(_0x5442ab,_0x3e4b10){_0x5442ab=_0x5442ab-0x0;var _0x1be600=_0x266b[_0x5442ab];return _0x1be600;};'use strict';var _=require('lodash');var util=require(_0xb266('0x0'));var moment=require(_0xb266('0x1'));var BPromise=require('bluebird');var rs=require(_0xb266('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xb266('0x3'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0xb266('0x4'));var config=require(_0xb266('0x5'));var jayson=require('jayson/promise');var client=jayson[_0xb266('0x6')][_0xb266('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x288615,_0x50922f,_0x128dd7){return new BPromise(function(_0x2e44ca,_0x21d6a7){return client[_0xb266('0x8')](_0x288615,_0x128dd7)[_0xb266('0x9')](function(_0x366195){logger['info'](_0xb266('0xa'),_0x50922f,_0xb266('0xb'));logger[_0xb266('0xc')]('UserWhatsappQueue,\x20%s,\x20%s,\x20%s',_0x50922f,_0xb266('0xb'),JSON[_0xb266('0xd')](_0x366195));if(_0x366195['error']){if(_0x366195['error']['code']===0x1f4){logger['error'](_0xb266('0xa'),_0x50922f,_0x366195['error'][_0xb266('0xe')]);return _0x21d6a7(_0x366195['error'][_0xb266('0xe')]);}logger['error'](_0xb266('0xa'),_0x50922f,_0x366195[_0xb266('0xf')][_0xb266('0xe')]);return _0x2e44ca(_0x366195['error']['message']);}else{logger[_0xb266('0x10')](_0xb266('0xa'),_0x50922f,_0xb266('0xb'));_0x2e44ca(_0x366195[_0xb266('0x11')][_0xb266('0xe')]);}})[_0xb266('0x12')](function(_0x516712){logger[_0xb266('0xf')](_0xb266('0xa'),_0x50922f,_0x516712);_0x21d6a7(_0x516712);});});}