975ad24be31d9d677d98426f8071f33895a697d0
[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 _0x0102=['moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','request','UserWhatsappQueue,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','info','catch','lodash','util'];(function(_0x290eef,_0x4635a3){var _0x21c635=function(_0x43957a){while(--_0x43957a){_0x290eef['push'](_0x290eef['shift']());}};_0x21c635(++_0x4635a3);}(_0x0102,0x1b6));var _0x2010=function(_0x197e67,_0x40c02d){_0x197e67=_0x197e67-0x0;var _0x4cb246=_0x0102[_0x197e67];return _0x4cb246;};'use strict';var _=require(_0x2010('0x0'));var util=require(_0x2010('0x1'));var moment=require(_0x2010('0x2'));var BPromise=require('bluebird');var rs=require(_0x2010('0x3'));var fs=require('fs');var Redis=require(_0x2010('0x4'));var db=require(_0x2010('0x5'))['db'];var utils=require(_0x2010('0x6'));var logger=require(_0x2010('0x7'))(_0x2010('0x8'));var config=require('../../config/environment');var jayson=require(_0x2010('0x9'));var client=jayson[_0x2010('0xa')][_0x2010('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x391c67,_0x17027f,_0x3c9b96){return new BPromise(function(_0x233fcb,_0x1e3864){return client[_0x2010('0xc')](_0x391c67,_0x3c9b96)['then'](function(_0x302b90){logger['info'](_0x2010('0xd'),_0x17027f,_0x2010('0xe'));logger[_0x2010('0xf')]('UserWhatsappQueue,\x20%s,\x20%s,\x20%s',_0x17027f,_0x2010('0xe'),JSON[_0x2010('0x10')](_0x302b90));if(_0x302b90[_0x2010('0x11')]){if(_0x302b90[_0x2010('0x11')][_0x2010('0x12')]===0x1f4){logger[_0x2010('0x11')](_0x2010('0xd'),_0x17027f,_0x302b90[_0x2010('0x11')]['message']);return _0x1e3864(_0x302b90['error'][_0x2010('0x13')]);}logger[_0x2010('0x11')]('UserWhatsappQueue,\x20%s,\x20%s',_0x17027f,_0x302b90[_0x2010('0x11')][_0x2010('0x13')]);return _0x233fcb(_0x302b90['error']['message']);}else{logger[_0x2010('0x14')]('UserWhatsappQueue,\x20%s,\x20%s',_0x17027f,_0x2010('0xe'));_0x233fcb(_0x302b90['result']['message']);}})[_0x2010('0x15')](function(_0x119e93){logger['error']('UserWhatsappQueue,\x20%s,\x20%s',_0x17027f,_0x119e93);_0x1e3864(_0x119e93);});});}