76b6a4fd24ed86bd35cdfefe96153c235e921bdc
[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 _0x4372=['code','message','result','catch','util','bluebird','randomstring','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','then','info','ChatApplication,\x20%s,\x20%s','request\x20sent','debug','ChatApplication,\x20%s,\x20%s,\x20%s','stringify','error'];(function(_0x421cf8,_0x23152c){var _0x145c48=function(_0x565862){while(--_0x565862){_0x421cf8['push'](_0x421cf8['shift']());}};_0x145c48(++_0x23152c);}(_0x4372,0x97));var _0x2437=function(_0x1738ee,_0x32e204){_0x1738ee=_0x1738ee-0x0;var _0x4b1b60=_0x4372[_0x1738ee];return _0x4b1b60;};'use strict';var _=require('lodash');var util=require(_0x2437('0x0'));var moment=require('moment');var BPromise=require(_0x2437('0x1'));var rs=require(_0x2437('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x2437('0x3'));var logger=require(_0x2437('0x4'))(_0x2437('0x5'));var config=require(_0x2437('0x6'));var jayson=require('jayson/promise');var client=jayson[_0x2437('0x7')][_0x2437('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x2f424b,_0x1cd6cf,_0x2a8d9f){return new BPromise(function(_0x137547,_0x2157a6){return client['request'](_0x2f424b,_0x2a8d9f)[_0x2437('0x9')](function(_0x910016){logger[_0x2437('0xa')](_0x2437('0xb'),_0x1cd6cf,_0x2437('0xc'));logger[_0x2437('0xd')](_0x2437('0xe'),_0x1cd6cf,_0x2437('0xc'),JSON[_0x2437('0xf')](_0x910016));if(_0x910016[_0x2437('0x10')]){if(_0x910016[_0x2437('0x10')][_0x2437('0x11')]===0x1f4){logger[_0x2437('0x10')](_0x2437('0xb'),_0x1cd6cf,_0x910016[_0x2437('0x10')][_0x2437('0x12')]);return _0x2157a6(_0x910016[_0x2437('0x10')]['message']);}logger[_0x2437('0x10')]('ChatApplication,\x20%s,\x20%s',_0x1cd6cf,_0x910016['error'][_0x2437('0x12')]);return _0x137547(_0x910016[_0x2437('0x10')][_0x2437('0x12')]);}else{logger[_0x2437('0xa')](_0x2437('0xb'),_0x1cd6cf,_0x2437('0xc'));_0x137547(_0x910016[_0x2437('0x13')][_0x2437('0x12')]);}})[_0x2437('0x14')](function(_0x2e18dc){logger[_0x2437('0x10')](_0x2437('0xb'),_0x1cd6cf,_0x2e18dc);_0x2157a6(_0x2e18dc);});});}