48331fef5b0ec466ebb8c165f4ff5ba28e099cb1
[motion2.git] / server / api / whatsappApplication / whatsappApplication.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 _0x723e=['WhatsappApplication,\x20%s,\x20%s','debug','WhatsappApplication,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','message','result','catch','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','request','info'];(function(_0x35baae,_0x2f15da){var _0x5720a1=function(_0x38e725){while(--_0x38e725){_0x35baae['push'](_0x35baae['shift']());}};_0x5720a1(++_0x2f15da);}(_0x723e,0x179));var _0xe723=function(_0x3a70f0,_0xfcc97){_0x3a70f0=_0x3a70f0-0x0;var _0x1d69b9=_0x723e[_0x3a70f0];return _0x1d69b9;};'use strict';var _=require('lodash');var util=require(_0xe723('0x0'));var moment=require(_0xe723('0x1'));var BPromise=require(_0xe723('0x2'));var rs=require(_0xe723('0x3'));var fs=require('fs');var Redis=require(_0xe723('0x4'));var db=require(_0xe723('0x5'))['db'];var utils=require(_0xe723('0x6'));var logger=require(_0xe723('0x7'))(_0xe723('0x8'));var config=require(_0xe723('0x9'));var jayson=require('jayson/promise');var client=jayson[_0xe723('0xa')][_0xe723('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x1335cd,_0x3bf082,_0x2aebbd){return new BPromise(function(_0xe50f7,_0x1b46e0){return client[_0xe723('0xc')](_0x1335cd,_0x2aebbd)['then'](function(_0x380444){logger[_0xe723('0xd')](_0xe723('0xe'),_0x3bf082,'request\x20sent');logger[_0xe723('0xf')](_0xe723('0x10'),_0x3bf082,_0xe723('0x11'),JSON['stringify'](_0x380444));if(_0x380444[_0xe723('0x12')]){if(_0x380444[_0xe723('0x12')][_0xe723('0x13')]===0x1f4){logger[_0xe723('0x12')](_0xe723('0xe'),_0x3bf082,_0x380444['error'][_0xe723('0x14')]);return _0x1b46e0(_0x380444['error']['message']);}logger['error']('WhatsappApplication,\x20%s,\x20%s',_0x3bf082,_0x380444[_0xe723('0x12')][_0xe723('0x14')]);return _0xe50f7(_0x380444[_0xe723('0x12')][_0xe723('0x14')]);}else{logger[_0xe723('0xd')]('WhatsappApplication,\x20%s,\x20%s',_0x3bf082,_0xe723('0x11'));_0xe50f7(_0x380444[_0xe723('0x15')][_0xe723('0x14')]);}})[_0xe723('0x16')](function(_0x347fa0){logger[_0xe723('0x12')](_0xe723('0xe'),_0x3bf082,_0x347fa0);_0x1b46e0(_0x347fa0);});});}