2438e41658aee69d6360979a7889cbdb42542caa
[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 _0x185b=['redis','localhost','socket.io-emitter','./notification.socket','register','request','info','Notification,\x20%s,\x20%s','request\x20sent','debug','Notification,\x20%s,\x20%s,\x20%s','stringify','error','message','result','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','client','http'];(function(_0x58c20f,_0x4cdb1b){var _0x3b0318=function(_0x36fa84){while(--_0x36fa84){_0x58c20f['push'](_0x58c20f['shift']());}};_0x3b0318(++_0x4cdb1b);}(_0x185b,0x1a4));var _0xb185=function(_0x1694f5,_0x49b7c3){_0x1694f5=_0x1694f5-0x0;var _0x5b4321=_0x185b[_0x1694f5];return _0x5b4321;};'use strict';var _=require(_0xb185('0x0'));var util=require(_0xb185('0x1'));var moment=require(_0xb185('0x2'));var BPromise=require(_0xb185('0x3'));var rs=require(_0xb185('0x4'));var fs=require('fs');var Redis=require(_0xb185('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0xb185('0x6'));var logger=require(_0xb185('0x7'))(_0xb185('0x8'));var config=require(_0xb185('0x9'));var jayson=require('jayson/promise');var client=jayson[_0xb185('0xa')][_0xb185('0xb')]({'port':0x232a});config[_0xb185('0xc')]=_['defaults'](config[_0xb185('0xc')],{'host':_0xb185('0xd'),'port':0x18eb});var socket=require(_0xb185('0xe'))(new Redis(config['redis']));require(_0xb185('0xf'))[_0xb185('0x10')](socket);function respondWithRpcPromise(_0x457c99,_0x36cead,_0x4428be){return new BPromise(function(_0x3298fa,_0x16e013){return client[_0xb185('0x11')](_0x457c99,_0x4428be)['then'](function(_0xe4120c){logger[_0xb185('0x12')](_0xb185('0x13'),_0x36cead,_0xb185('0x14'));logger[_0xb185('0x15')](_0xb185('0x16'),_0x36cead,_0xb185('0x14'),JSON[_0xb185('0x17')](_0xe4120c));if(_0xe4120c[_0xb185('0x18')]){if(_0xe4120c['error']['code']===0x1f4){logger[_0xb185('0x18')]('Notification,\x20%s,\x20%s',_0x36cead,_0xe4120c['error'][_0xb185('0x19')]);return _0x16e013(_0xe4120c['error'][_0xb185('0x19')]);}logger[_0xb185('0x18')](_0xb185('0x13'),_0x36cead,_0xe4120c[_0xb185('0x18')][_0xb185('0x19')]);return _0x3298fa(_0xe4120c[_0xb185('0x18')]['message']);}else{logger['info']('Notification,\x20%s,\x20%s',_0x36cead,'request\x20sent');_0x3298fa(_0xe4120c[_0xb185('0x1a')][_0xb185('0x19')]);}})['catch'](function(_0x5f6812){logger[_0xb185('0x18')](_0xb185('0x13'),_0x36cead,_0x5f6812);_0x16e013(_0x5f6812);});});}