f552748c4df15044266482c16824cc50b43d56be
[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 _0x37a7=['../../mysqldb','../../config/environment','jayson/promise','client','http','request','info','request\x20sent','debug','WhatsappApplication,\x20%s,\x20%s,\x20%s','stringify','error','WhatsappApplication,\x20%s,\x20%s','message','result','catch','lodash','util','ioredis'];(function(_0x1e85dc,_0x34902c){var _0x41c366=function(_0x31227a){while(--_0x31227a){_0x1e85dc['push'](_0x1e85dc['shift']());}};_0x41c366(++_0x34902c);}(_0x37a7,0x6f));var _0x737a=function(_0x381246,_0x14abc3){_0x381246=_0x381246-0x0;var _0x48c74b=_0x37a7[_0x381246];return _0x48c74b;};'use strict';var _=require(_0x737a('0x0'));var util=require(_0x737a('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x737a('0x2'));var db=require(_0x737a('0x3'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')('rpc');var config=require(_0x737a('0x4'));var jayson=require(_0x737a('0x5'));var client=jayson[_0x737a('0x6')][_0x737a('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x2f6800,_0x5cc52c,_0x244850){return new BPromise(function(_0x249898,_0x17c76d){return client[_0x737a('0x8')](_0x2f6800,_0x244850)['then'](function(_0x303f55){logger[_0x737a('0x9')]('WhatsappApplication,\x20%s,\x20%s',_0x5cc52c,_0x737a('0xa'));logger[_0x737a('0xb')](_0x737a('0xc'),_0x5cc52c,_0x737a('0xa'),JSON[_0x737a('0xd')](_0x303f55));if(_0x303f55[_0x737a('0xe')]){if(_0x303f55[_0x737a('0xe')]['code']===0x1f4){logger[_0x737a('0xe')](_0x737a('0xf'),_0x5cc52c,_0x303f55[_0x737a('0xe')][_0x737a('0x10')]);return _0x17c76d(_0x303f55[_0x737a('0xe')][_0x737a('0x10')]);}logger[_0x737a('0xe')](_0x737a('0xf'),_0x5cc52c,_0x303f55['error'][_0x737a('0x10')]);return _0x249898(_0x303f55[_0x737a('0xe')]['message']);}else{logger['info'](_0x737a('0xf'),_0x5cc52c,_0x737a('0xa'));_0x249898(_0x303f55[_0x737a('0x11')][_0x737a('0x10')]);}})[_0x737a('0x12')](function(_0x195749){logger['error'](_0x737a('0xf'),_0x5cc52c,_0x195749);_0x17c76d(_0x195749);});});}