82a9b99f134f0e453d69ec62648688dd85c40b40
[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 _0xa5d8=['UserWhatsappQueue,\x20%s,\x20%s','message','result','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','info','request\x20sent','debug','UserWhatsappQueue,\x20%s,\x20%s,\x20%s','stringify','error'];(function(_0x1227ef,_0x44099f){var _0x7636f2=function(_0x4d6a4a){while(--_0x4d6a4a){_0x1227ef['push'](_0x1227ef['shift']());}};_0x7636f2(++_0x44099f);}(_0xa5d8,0x9d));var _0x8a5d=function(_0x5187ee,_0x184b0c){_0x5187ee=_0x5187ee-0x0;var _0xe05230=_0xa5d8[_0x5187ee];return _0xe05230;};'use strict';var _=require('lodash');var util=require(_0x8a5d('0x0'));var moment=require('moment');var BPromise=require(_0x8a5d('0x1'));var rs=require(_0x8a5d('0x2'));var fs=require('fs');var Redis=require(_0x8a5d('0x3'));var db=require(_0x8a5d('0x4'))['db'];var utils=require(_0x8a5d('0x5'));var logger=require(_0x8a5d('0x6'))(_0x8a5d('0x7'));var config=require(_0x8a5d('0x8'));var jayson=require(_0x8a5d('0x9'));var client=jayson[_0x8a5d('0xa')][_0x8a5d('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x1c3b1f,_0xa77245,_0x52986a){return new BPromise(function(_0x457179,_0x22d579){return client[_0x8a5d('0xc')](_0x1c3b1f,_0x52986a)['then'](function(_0xf298ae){logger[_0x8a5d('0xd')]('UserWhatsappQueue,\x20%s,\x20%s',_0xa77245,_0x8a5d('0xe'));logger[_0x8a5d('0xf')](_0x8a5d('0x10'),_0xa77245,'request\x20sent',JSON[_0x8a5d('0x11')](_0xf298ae));if(_0xf298ae[_0x8a5d('0x12')]){if(_0xf298ae[_0x8a5d('0x12')]['code']===0x1f4){logger[_0x8a5d('0x12')](_0x8a5d('0x13'),_0xa77245,_0xf298ae[_0x8a5d('0x12')]['message']);return _0x22d579(_0xf298ae[_0x8a5d('0x12')][_0x8a5d('0x14')]);}logger[_0x8a5d('0x12')](_0x8a5d('0x13'),_0xa77245,_0xf298ae[_0x8a5d('0x12')][_0x8a5d('0x14')]);return _0x457179(_0xf298ae[_0x8a5d('0x12')][_0x8a5d('0x14')]);}else{logger[_0x8a5d('0xd')](_0x8a5d('0x13'),_0xa77245,'request\x20sent');_0x457179(_0xf298ae[_0x8a5d('0x15')][_0x8a5d('0x14')]);}})['catch'](function(_0x22ad29){logger['error'](_0x8a5d('0x13'),_0xa77245,_0x22ad29);_0x22d579(_0x22ad29);});});}