3e775f2c329665b63c7d41845318e25f6797ec19
[motion2.git] / server / api / chatInternalMessage / chatInternalMessage.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 _0x2aef=['../../config/logger','../../config/environment','client','http','defaults','redis','socket.io-emitter','info','request\x20sent','debug','ChatInternalMessage,\x20%s,\x20%s,\x20%s','stringify','error','ChatInternalMessage,\x20%s,\x20%s','message','result','catch','bluebird','randomstring','ioredis','../../config/utils'];(function(_0x2c8b50,_0x23a0d2){var _0x342eb2=function(_0x27df6e){while(--_0x27df6e){_0x2c8b50['push'](_0x2c8b50['shift']());}};_0x342eb2(++_0x23a0d2);}(_0x2aef,0x122));var _0xf2ae=function(_0x227dd3,_0x3f3428){_0x227dd3=_0x227dd3-0x0;var _0x4a595e=_0x2aef[_0x227dd3];return _0x4a595e;};'use strict';var _=require('lodash');var util=require('util');var moment=require('moment');var BPromise=require(_0xf2ae('0x0'));var rs=require(_0xf2ae('0x1'));var fs=require('fs');var Redis=require(_0xf2ae('0x2'));var db=require('../../mysqldb')['db'];var utils=require(_0xf2ae('0x3'));var logger=require(_0xf2ae('0x4'))('rpc');var config=require(_0xf2ae('0x5'));var jayson=require('jayson/promise');var client=jayson[_0xf2ae('0x6')][_0xf2ae('0x7')]({'port':0x232a});config['redis']=_[_0xf2ae('0x8')](config[_0xf2ae('0x9')],{'host':'localhost','port':0x18eb});var socket=require(_0xf2ae('0xa'))(new Redis(config['redis']));require('./chatInternalMessage.socket')['register'](socket);function respondWithRpcPromise(_0x257c86,_0x143a8c,_0x401f26){return new BPromise(function(_0x50f544,_0xdcaf7a){return client['request'](_0x257c86,_0x401f26)['then'](function(_0x79e05e){logger[_0xf2ae('0xb')]('ChatInternalMessage,\x20%s,\x20%s',_0x143a8c,_0xf2ae('0xc'));logger[_0xf2ae('0xd')](_0xf2ae('0xe'),_0x143a8c,_0xf2ae('0xc'),JSON[_0xf2ae('0xf')](_0x79e05e));if(_0x79e05e['error']){if(_0x79e05e['error']['code']===0x1f4){logger[_0xf2ae('0x10')](_0xf2ae('0x11'),_0x143a8c,_0x79e05e[_0xf2ae('0x10')][_0xf2ae('0x12')]);return _0xdcaf7a(_0x79e05e[_0xf2ae('0x10')][_0xf2ae('0x12')]);}logger[_0xf2ae('0x10')](_0xf2ae('0x11'),_0x143a8c,_0x79e05e['error'][_0xf2ae('0x12')]);return _0x50f544(_0x79e05e[_0xf2ae('0x10')][_0xf2ae('0x12')]);}else{logger['info'](_0xf2ae('0x11'),_0x143a8c,'request\x20sent');_0x50f544(_0x79e05e[_0xf2ae('0x13')]['message']);}})[_0xf2ae('0x14')](function(_0x39d561){logger[_0xf2ae('0x10')](_0xf2ae('0x11'),_0x143a8c,_0x39d561);_0xdcaf7a(_0x39d561);});});}