35da1d6bdde37ad29f7f57447ba0077f6c52c3d4
[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 _0xebf4=['stringify','error','ChatInternalMessage,\x20%s,\x20%s','message','info','result','catch','lodash','randomstring','ioredis','../../config/utils','../../config/logger','jayson/promise','http','socket.io-emitter','redis','register','request','then','debug','ChatInternalMessage,\x20%s,\x20%s,\x20%s','request\x20sent'];(function(_0x55677b,_0x3e5655){var _0x104b88=function(_0x78d34f){while(--_0x78d34f){_0x55677b['push'](_0x55677b['shift']());}};_0x104b88(++_0x3e5655);}(_0xebf4,0xe3));var _0x4ebf=function(_0x111eca,_0x2da62){_0x111eca=_0x111eca-0x0;var _0x21c89a=_0xebf4[_0x111eca];return _0x21c89a;};'use strict';var _=require(_0x4ebf('0x0'));var util=require('util');var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x4ebf('0x1'));var fs=require('fs');var Redis=require(_0x4ebf('0x2'));var db=require('../../mysqldb')['db'];var utils=require(_0x4ebf('0x3'));var logger=require(_0x4ebf('0x4'))('rpc');var config=require('../../config/environment');var jayson=require(_0x4ebf('0x5'));var client=jayson['client'][_0x4ebf('0x6')]({'port':0x232a});config['redis']=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x4ebf('0x7'))(new Redis(config[_0x4ebf('0x8')]));require('./chatInternalMessage.socket')[_0x4ebf('0x9')](socket);function respondWithRpcPromise(_0x50f1d6,_0x31c47a,_0x2a2c04){return new BPromise(function(_0x317c9e,_0x127d70){return client[_0x4ebf('0xa')](_0x50f1d6,_0x2a2c04)[_0x4ebf('0xb')](function(_0x251927){logger['info']('ChatInternalMessage,\x20%s,\x20%s',_0x31c47a,'request\x20sent');logger[_0x4ebf('0xc')](_0x4ebf('0xd'),_0x31c47a,_0x4ebf('0xe'),JSON[_0x4ebf('0xf')](_0x251927));if(_0x251927[_0x4ebf('0x10')]){if(_0x251927[_0x4ebf('0x10')]['code']===0x1f4){logger[_0x4ebf('0x10')](_0x4ebf('0x11'),_0x31c47a,_0x251927['error'][_0x4ebf('0x12')]);return _0x127d70(_0x251927[_0x4ebf('0x10')][_0x4ebf('0x12')]);}logger['error']('ChatInternalMessage,\x20%s,\x20%s',_0x31c47a,_0x251927[_0x4ebf('0x10')][_0x4ebf('0x12')]);return _0x317c9e(_0x251927[_0x4ebf('0x10')]['message']);}else{logger[_0x4ebf('0x13')](_0x4ebf('0x11'),_0x31c47a,_0x4ebf('0xe'));_0x317c9e(_0x251927[_0x4ebf('0x14')]['message']);}})[_0x4ebf('0x15')](function(_0x2d32f4){logger[_0x4ebf('0x10')](_0x4ebf('0x11'),_0x31c47a,_0x2d32f4);_0x127d70(_0x2d32f4);});});}