88eccfbe9afbc4d4a524a73ccbfffae213b5cc75
[motion2.git] / server / api / notification / notification.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 _0x53e0=['then','Notification,\x20%s,\x20%s','request\x20sent','debug','Notification,\x20%s,\x20%s,\x20%s','stringify','code','error','message','info','catch','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','http','localhost','redis','register','request'];(function(_0x5e1649,_0x2f9027){var _0x4b0d66=function(_0x55fbdc){while(--_0x55fbdc){_0x5e1649['push'](_0x5e1649['shift']());}};_0x4b0d66(++_0x2f9027);}(_0x53e0,0x1b4));var _0x053e=function(_0x4f2530,_0x5c0bb5){_0x4f2530=_0x4f2530-0x0;var _0x4a9e71=_0x53e0[_0x4f2530];return _0x4a9e71;};'use strict';var _=require(_0x053e('0x0'));var util=require('util');var moment=require(_0x053e('0x1'));var BPromise=require(_0x053e('0x2'));var rs=require(_0x053e('0x3'));var fs=require('fs');var Redis=require(_0x053e('0x4'));var db=require(_0x053e('0x5'))['db'];var utils=require(_0x053e('0x6'));var logger=require('../../config/logger')(_0x053e('0x7'));var config=require(_0x053e('0x8'));var jayson=require('jayson/promise');var client=jayson['client'][_0x053e('0x9')]({'port':0x232a});config['redis']=_['defaults'](config['redis'],{'host':_0x053e('0xa'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x053e('0xb')]));require('./notification.socket')[_0x053e('0xc')](socket);function respondWithRpcPromise(_0xad9b0a,_0x37c2a4,_0x116ecb){return new BPromise(function(_0xff9f0a,_0x1e8132){return client[_0x053e('0xd')](_0xad9b0a,_0x116ecb)[_0x053e('0xe')](function(_0xc8c712){logger['info'](_0x053e('0xf'),_0x37c2a4,_0x053e('0x10'));logger[_0x053e('0x11')](_0x053e('0x12'),_0x37c2a4,'request\x20sent',JSON[_0x053e('0x13')](_0xc8c712));if(_0xc8c712['error']){if(_0xc8c712['error'][_0x053e('0x14')]===0x1f4){logger[_0x053e('0x15')]('Notification,\x20%s,\x20%s',_0x37c2a4,_0xc8c712[_0x053e('0x15')][_0x053e('0x16')]);return _0x1e8132(_0xc8c712['error'][_0x053e('0x16')]);}logger[_0x053e('0x15')](_0x053e('0xf'),_0x37c2a4,_0xc8c712['error'][_0x053e('0x16')]);return _0xff9f0a(_0xc8c712[_0x053e('0x15')][_0x053e('0x16')]);}else{logger[_0x053e('0x17')]('Notification,\x20%s,\x20%s',_0x37c2a4,_0x053e('0x10'));_0xff9f0a(_0xc8c712['result']['message']);}})[_0x053e('0x18')](function(_0x2814be){logger['error'](_0x053e('0xf'),_0x37c2a4,_0x2814be);_0x1e8132(_0x2814be);});});}