Built motion from commit 26d08302.|2.6.31
[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 _0x7bae=['rpc','../../config/environment','jayson/promise','client','http','request','then','info','WhatsappApplication,\x20%s,\x20%s','request\x20sent','debug','WhatsappApplication,\x20%s,\x20%s,\x20%s','stringify','error','message','moment','bluebird','ioredis','../../config/utils','../../config/logger'];(function(_0x42cae2,_0x284ef8){var _0x5f256f=function(_0x41abc8){while(--_0x41abc8){_0x42cae2['push'](_0x42cae2['shift']());}};_0x5f256f(++_0x284ef8);}(_0x7bae,0x13b));var _0xe7ba=function(_0x1ddedd,_0x485606){_0x1ddedd=_0x1ddedd-0x0;var _0xa3e1ac=_0x7bae[_0x1ddedd];return _0xa3e1ac;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0xe7ba('0x0'));var BPromise=require(_0xe7ba('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xe7ba('0x2'));var db=require('../../mysqldb')['db'];var utils=require(_0xe7ba('0x3'));var logger=require(_0xe7ba('0x4'))(_0xe7ba('0x5'));var config=require(_0xe7ba('0x6'));var jayson=require(_0xe7ba('0x7'));var client=jayson[_0xe7ba('0x8')][_0xe7ba('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x3c5e59,_0x10b307,_0x34fb18){return new BPromise(function(_0x160565,_0x27b1d5){return client[_0xe7ba('0xa')](_0x3c5e59,_0x34fb18)[_0xe7ba('0xb')](function(_0x588f08){logger[_0xe7ba('0xc')](_0xe7ba('0xd'),_0x10b307,_0xe7ba('0xe'));logger[_0xe7ba('0xf')](_0xe7ba('0x10'),_0x10b307,_0xe7ba('0xe'),JSON[_0xe7ba('0x11')](_0x588f08));if(_0x588f08[_0xe7ba('0x12')]){if(_0x588f08[_0xe7ba('0x12')]['code']===0x1f4){logger[_0xe7ba('0x12')]('WhatsappApplication,\x20%s,\x20%s',_0x10b307,_0x588f08[_0xe7ba('0x12')][_0xe7ba('0x13')]);return _0x27b1d5(_0x588f08[_0xe7ba('0x12')][_0xe7ba('0x13')]);}logger[_0xe7ba('0x12')](_0xe7ba('0xd'),_0x10b307,_0x588f08['error']['message']);return _0x160565(_0x588f08[_0xe7ba('0x12')][_0xe7ba('0x13')]);}else{logger[_0xe7ba('0xc')]('WhatsappApplication,\x20%s,\x20%s',_0x10b307,_0xe7ba('0xe'));_0x160565(_0x588f08['result']['message']);}})['catch'](function(_0x393f75){logger['error'](_0xe7ba('0xd'),_0x10b307,_0x393f75);_0x27b1d5(_0x393f75);});});}