Built motion from commit da617fac.|2.6.6
[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 _0xb348=['ioredis','../../mysqldb','../../config/utils','../../config/logger','client','request','then','UserWhatsappQueue,\x20%s,\x20%s','UserWhatsappQueue,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','message','info','result','catch','lodash','moment','bluebird','randomstring'];(function(_0x34c525,_0x5a24f9){var _0x15a9a2=function(_0x33c3ae){while(--_0x33c3ae){_0x34c525['push'](_0x34c525['shift']());}};_0x15a9a2(++_0x5a24f9);}(_0xb348,0xb0));var _0x8b34=function(_0x1e27b2,_0x2abc02){_0x1e27b2=_0x1e27b2-0x0;var _0x2f8696=_0xb348[_0x1e27b2];return _0x2f8696;};'use strict';var _=require(_0x8b34('0x0'));var util=require('util');var moment=require(_0x8b34('0x1'));var BPromise=require(_0x8b34('0x2'));var rs=require(_0x8b34('0x3'));var fs=require('fs');var Redis=require(_0x8b34('0x4'));var db=require(_0x8b34('0x5'))['db'];var utils=require(_0x8b34('0x6'));var logger=require(_0x8b34('0x7'))('rpc');var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x8b34('0x8')]['http']({'port':0x232a});function respondWithRpcPromise(_0x3fda2f,_0x558c7f,_0x37f307){return new BPromise(function(_0x1c7982,_0x111ebe){return client[_0x8b34('0x9')](_0x3fda2f,_0x37f307)[_0x8b34('0xa')](function(_0x479696){logger['info'](_0x8b34('0xb'),_0x558c7f,'request\x20sent');logger['debug'](_0x8b34('0xc'),_0x558c7f,_0x8b34('0xd'),JSON[_0x8b34('0xe')](_0x479696));if(_0x479696[_0x8b34('0xf')]){if(_0x479696['error']['code']===0x1f4){logger['error']('UserWhatsappQueue,\x20%s,\x20%s',_0x558c7f,_0x479696[_0x8b34('0xf')][_0x8b34('0x10')]);return _0x111ebe(_0x479696[_0x8b34('0xf')]['message']);}logger[_0x8b34('0xf')](_0x8b34('0xb'),_0x558c7f,_0x479696[_0x8b34('0xf')][_0x8b34('0x10')]);return _0x1c7982(_0x479696[_0x8b34('0xf')]['message']);}else{logger[_0x8b34('0x11')](_0x8b34('0xb'),_0x558c7f,_0x8b34('0xd'));_0x1c7982(_0x479696[_0x8b34('0x12')][_0x8b34('0x10')]);}})[_0x8b34('0x13')](function(_0x21eec2){logger[_0x8b34('0xf')](_0x8b34('0xb'),_0x558c7f,_0x21eec2);_0x111ebe(_0x21eec2);});});}