19e87b61ca572ce0adf66e68689e608e18681c56
[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 _0x81a9=['redis','defaults','./chatInternalMessage.socket','register','request','info','ChatInternalMessage,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','catch','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/environment','jayson/promise','http'];(function(_0x5a9666,_0x30bc94){var _0x28601f=function(_0x52e447){while(--_0x52e447){_0x5a9666['push'](_0x5a9666['shift']());}};_0x28601f(++_0x30bc94);}(_0x81a9,0x81));var _0x981a=function(_0x4ed865,_0x2f18d){_0x4ed865=_0x4ed865-0x0;var _0xc4e344=_0x81a9[_0x4ed865];return _0xc4e344;};'use strict';var _=require(_0x981a('0x0'));var util=require('util');var moment=require(_0x981a('0x1'));var BPromise=require(_0x981a('0x2'));var rs=require(_0x981a('0x3'));var fs=require('fs');var Redis=require(_0x981a('0x4'));var db=require(_0x981a('0x5'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')('rpc');var config=require(_0x981a('0x6'));var jayson=require(_0x981a('0x7'));var client=jayson['client'][_0x981a('0x8')]({'port':0x232a});config[_0x981a('0x9')]=_[_0x981a('0xa')](config[_0x981a('0x9')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x981a('0x9')]));require(_0x981a('0xb'))[_0x981a('0xc')](socket);function respondWithRpcPromise(_0x32f8d9,_0x381c86,_0x2d1b70){return new BPromise(function(_0x41854f,_0x5ab43b){return client[_0x981a('0xd')](_0x32f8d9,_0x2d1b70)['then'](function(_0x5076f9){logger[_0x981a('0xe')](_0x981a('0xf'),_0x381c86,_0x981a('0x10'));logger[_0x981a('0x11')]('ChatInternalMessage,\x20%s,\x20%s,\x20%s',_0x381c86,'request\x20sent',JSON[_0x981a('0x12')](_0x5076f9));if(_0x5076f9[_0x981a('0x13')]){if(_0x5076f9['error'][_0x981a('0x14')]===0x1f4){logger[_0x981a('0x13')](_0x981a('0xf'),_0x381c86,_0x5076f9[_0x981a('0x13')][_0x981a('0x15')]);return _0x5ab43b(_0x5076f9[_0x981a('0x13')]['message']);}logger[_0x981a('0x13')](_0x981a('0xf'),_0x381c86,_0x5076f9[_0x981a('0x13')][_0x981a('0x15')]);return _0x41854f(_0x5076f9['error']['message']);}else{logger['info'](_0x981a('0xf'),_0x381c86,_0x981a('0x10'));_0x41854f(_0x5076f9['result'][_0x981a('0x15')]);}})[_0x981a('0x16')](function(_0x2968f8){logger[_0x981a('0x13')]('ChatInternalMessage,\x20%s,\x20%s',_0x381c86,_0x2968f8);_0x5ab43b(_0x2968f8);});});}