23977d920fc071599a7e85d6b59b868cb45c1892
[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 _0x31c2=['bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/environment','jayson/promise','client','http','request','info','WhatsappApplication,\x20%s,\x20%s','request\x20sent','debug','WhatsappApplication,\x20%s,\x20%s,\x20%s','error','message','result','catch','lodash','util','moment'];(function(_0xf50820,_0x56f041){var _0x2a9b10=function(_0x33f0f4){while(--_0x33f0f4){_0xf50820['push'](_0xf50820['shift']());}};_0x2a9b10(++_0x56f041);}(_0x31c2,0x1e1));var _0x231c=function(_0x28170f,_0x18fefd){_0x28170f=_0x28170f-0x0;var _0x4a77e1=_0x31c2[_0x28170f];return _0x4a77e1;};'use strict';var _=require(_0x231c('0x0'));var util=require(_0x231c('0x1'));var moment=require(_0x231c('0x2'));var BPromise=require(_0x231c('0x3'));var rs=require(_0x231c('0x4'));var fs=require('fs');var Redis=require(_0x231c('0x5'));var db=require(_0x231c('0x6'))['db'];var utils=require(_0x231c('0x7'));var logger=require('../../config/logger')('rpc');var config=require(_0x231c('0x8'));var jayson=require(_0x231c('0x9'));var client=jayson[_0x231c('0xa')][_0x231c('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x48bfb2,_0x111bf9,_0x49ff9e){return new BPromise(function(_0x439df8,_0x38b3b9){return client[_0x231c('0xc')](_0x48bfb2,_0x49ff9e)['then'](function(_0x2524bf){logger[_0x231c('0xd')](_0x231c('0xe'),_0x111bf9,_0x231c('0xf'));logger[_0x231c('0x10')](_0x231c('0x11'),_0x111bf9,_0x231c('0xf'),JSON['stringify'](_0x2524bf));if(_0x2524bf[_0x231c('0x12')]){if(_0x2524bf[_0x231c('0x12')]['code']===0x1f4){logger[_0x231c('0x12')](_0x231c('0xe'),_0x111bf9,_0x2524bf[_0x231c('0x12')][_0x231c('0x13')]);return _0x38b3b9(_0x2524bf[_0x231c('0x12')][_0x231c('0x13')]);}logger[_0x231c('0x12')](_0x231c('0xe'),_0x111bf9,_0x2524bf[_0x231c('0x12')][_0x231c('0x13')]);return _0x439df8(_0x2524bf[_0x231c('0x12')][_0x231c('0x13')]);}else{logger[_0x231c('0xd')](_0x231c('0xe'),_0x111bf9,_0x231c('0xf'));_0x439df8(_0x2524bf[_0x231c('0x14')][_0x231c('0x13')]);}})[_0x231c('0x15')](function(_0x1852e5){logger[_0x231c('0x12')]('WhatsappApplication,\x20%s,\x20%s',_0x111bf9,_0x1852e5);_0x38b3b9(_0x1852e5);});});}