f1790001c3d1e76518bc7df8a9fa7f4b3890d674
[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 _0x0665=['socket.io-emitter','register','request','ChatInternalMessage,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','info','result','catch','lodash','util','moment','randomstring','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','client','http','redis','defaults','localhost'];(function(_0x49d9db,_0x41347b){var _0x5f049d=function(_0x2fb1ac){while(--_0x2fb1ac){_0x49d9db['push'](_0x49d9db['shift']());}};_0x5f049d(++_0x41347b);}(_0x0665,0x1e7));var _0x5066=function(_0x5ed65f,_0x23d121){_0x5ed65f=_0x5ed65f-0x0;var _0x1f43ae=_0x0665[_0x5ed65f];return _0x1f43ae;};'use strict';var _=require(_0x5066('0x0'));var util=require(_0x5066('0x1'));var moment=require(_0x5066('0x2'));var BPromise=require('bluebird');var rs=require(_0x5066('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x5066('0x4'))['db'];var utils=require(_0x5066('0x5'));var logger=require(_0x5066('0x6'))('rpc');var config=require(_0x5066('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x5066('0x8')][_0x5066('0x9')]({'port':0x232a});config[_0x5066('0xa')]=_[_0x5066('0xb')](config[_0x5066('0xa')],{'host':_0x5066('0xc'),'port':0x18eb});var socket=require(_0x5066('0xd'))(new Redis(config[_0x5066('0xa')]));require('./chatInternalMessage.socket')[_0x5066('0xe')](socket);function respondWithRpcPromise(_0x290a0f,_0x445e25,_0x373808){return new BPromise(function(_0x39ec9e,_0x1bc504){return client[_0x5066('0xf')](_0x290a0f,_0x373808)['then'](function(_0x3a07ae){logger['info'](_0x5066('0x10'),_0x445e25,_0x5066('0x11'));logger[_0x5066('0x12')]('ChatInternalMessage,\x20%s,\x20%s,\x20%s',_0x445e25,'request\x20sent',JSON[_0x5066('0x13')](_0x3a07ae));if(_0x3a07ae[_0x5066('0x14')]){if(_0x3a07ae['error']['code']===0x1f4){logger[_0x5066('0x14')]('ChatInternalMessage,\x20%s,\x20%s',_0x445e25,_0x3a07ae['error'][_0x5066('0x15')]);return _0x1bc504(_0x3a07ae[_0x5066('0x14')]['message']);}logger[_0x5066('0x14')]('ChatInternalMessage,\x20%s,\x20%s',_0x445e25,_0x3a07ae[_0x5066('0x14')][_0x5066('0x15')]);return _0x39ec9e(_0x3a07ae[_0x5066('0x14')][_0x5066('0x15')]);}else{logger[_0x5066('0x16')](_0x5066('0x10'),_0x445e25,'request\x20sent');_0x39ec9e(_0x3a07ae[_0x5066('0x17')]['message']);}})[_0x5066('0x18')](function(_0xb47496){logger[_0x5066('0x14')](_0x5066('0x10'),_0x445e25,_0xb47496);_0x1bc504(_0xb47496);});});}