1cbf6b2a271fbc7ddf5ca5815d11ad2906b0fd6e
[motion2.git] / server / api / chatApplication / chatApplication.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 _0x5f23=['../../config/logger','rpc','../../config/environment','http','request','then','request\x20sent','debug','ChatApplication,\x20%s,\x20%s,\x20%s','stringify','error','message','ChatApplication,\x20%s,\x20%s','result','catch','util','moment','bluebird','randomstring','ioredis','../../config/utils'];(function(_0x122d2b,_0x70044d){var _0x55ac23=function(_0x1a954b){while(--_0x1a954b){_0x122d2b['push'](_0x122d2b['shift']());}};_0x55ac23(++_0x70044d);}(_0x5f23,0xb7));var _0x35f2=function(_0x418a0e,_0x45a42e){_0x418a0e=_0x418a0e-0x0;var _0x1c76e9=_0x5f23[_0x418a0e];return _0x1c76e9;};'use strict';var _=require('lodash');var util=require(_0x35f2('0x0'));var moment=require(_0x35f2('0x1'));var BPromise=require(_0x35f2('0x2'));var rs=require(_0x35f2('0x3'));var fs=require('fs');var Redis=require(_0x35f2('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x35f2('0x5'));var logger=require(_0x35f2('0x6'))(_0x35f2('0x7'));var config=require(_0x35f2('0x8'));var jayson=require('jayson/promise');var client=jayson['client'][_0x35f2('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x1839dc,_0x125995,_0x418063){return new BPromise(function(_0x636fd7,_0x5282ec){return client[_0x35f2('0xa')](_0x1839dc,_0x418063)[_0x35f2('0xb')](function(_0x4e7723){logger['info']('ChatApplication,\x20%s,\x20%s',_0x125995,_0x35f2('0xc'));logger[_0x35f2('0xd')](_0x35f2('0xe'),_0x125995,_0x35f2('0xc'),JSON[_0x35f2('0xf')](_0x4e7723));if(_0x4e7723[_0x35f2('0x10')]){if(_0x4e7723[_0x35f2('0x10')]['code']===0x1f4){logger[_0x35f2('0x10')]('ChatApplication,\x20%s,\x20%s',_0x125995,_0x4e7723[_0x35f2('0x10')][_0x35f2('0x11')]);return _0x5282ec(_0x4e7723['error']['message']);}logger[_0x35f2('0x10')]('ChatApplication,\x20%s,\x20%s',_0x125995,_0x4e7723['error'][_0x35f2('0x11')]);return _0x636fd7(_0x4e7723['error'][_0x35f2('0x11')]);}else{logger['info'](_0x35f2('0x12'),_0x125995,_0x35f2('0xc'));_0x636fd7(_0x4e7723[_0x35f2('0x13')][_0x35f2('0x11')]);}})[_0x35f2('0x14')](function(_0x3bfdd5){logger[_0x35f2('0x10')](_0x35f2('0x12'),_0x125995,_0x3bfdd5);_0x5282ec(_0x3bfdd5);});});}