a87c3a48214e3ddb7fb4a69fb54c6482ce5d55e6
[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 _0xa232=['redis','./chatInternalMessage.socket','register','request','ChatInternalMessage,\x20%s,\x20%s','request\x20sent','debug','ChatInternalMessage,\x20%s,\x20%s,\x20%s','error','message','info','result','catch','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','defaults'];(function(_0x595add,_0x15feb9){var _0x52eb1a=function(_0x32fcec){while(--_0x32fcec){_0x595add['push'](_0x595add['shift']());}};_0x52eb1a(++_0x15feb9);}(_0xa232,0x141));var _0x2a23=function(_0x4194e3,_0x5567a5){_0x4194e3=_0x4194e3-0x0;var _0x51a928=_0xa232[_0x4194e3];return _0x51a928;};'use strict';var _=require('lodash');var util=require('util');var moment=require('moment');var BPromise=require(_0x2a23('0x0'));var rs=require(_0x2a23('0x1'));var fs=require('fs');var Redis=require(_0x2a23('0x2'));var db=require('../../mysqldb')['db'];var utils=require(_0x2a23('0x3'));var logger=require(_0x2a23('0x4'))('rpc');var config=require(_0x2a23('0x5'));var jayson=require(_0x2a23('0x6'));var client=jayson[_0x2a23('0x7')]['http']({'port':0x232a});config['redis']=_[_0x2a23('0x8')](config[_0x2a23('0x9')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x2a23('0xa'))[_0x2a23('0xb')](socket);function respondWithRpcPromise(_0x22d58a,_0x416ef5,_0x42bb10){return new BPromise(function(_0x4914f1,_0x190445){return client[_0x2a23('0xc')](_0x22d58a,_0x42bb10)['then'](function(_0x2f82d1){logger['info'](_0x2a23('0xd'),_0x416ef5,_0x2a23('0xe'));logger[_0x2a23('0xf')](_0x2a23('0x10'),_0x416ef5,_0x2a23('0xe'),JSON['stringify'](_0x2f82d1));if(_0x2f82d1[_0x2a23('0x11')]){if(_0x2f82d1['error']['code']===0x1f4){logger[_0x2a23('0x11')](_0x2a23('0xd'),_0x416ef5,_0x2f82d1['error']['message']);return _0x190445(_0x2f82d1[_0x2a23('0x11')][_0x2a23('0x12')]);}logger[_0x2a23('0x11')]('ChatInternalMessage,\x20%s,\x20%s',_0x416ef5,_0x2f82d1[_0x2a23('0x11')][_0x2a23('0x12')]);return _0x4914f1(_0x2f82d1[_0x2a23('0x11')][_0x2a23('0x12')]);}else{logger[_0x2a23('0x13')]('ChatInternalMessage,\x20%s,\x20%s',_0x416ef5,_0x2a23('0xe'));_0x4914f1(_0x2f82d1[_0x2a23('0x14')][_0x2a23('0x12')]);}})[_0x2a23('0x15')](function(_0x1942b4){logger[_0x2a23('0x11')]('ChatInternalMessage,\x20%s,\x20%s',_0x416ef5,_0x1942b4);_0x190445(_0x1942b4);});});}