dd8465ed9e8e841e2425ac59d7260351db2992f4
[motion2.git] / server / api / userNotification / userNotification.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 _0xee05=['localhost','socket.io-emitter','redis','./userNotification.socket','register','then','info','UserNotification,\x20%s,\x20%s','debug','UserNotification,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','message','result','catch','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','client','http','defaults'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xee05,0x162));var _0x5ee0=function(_0x3d6367,_0x5a06b0){_0x3d6367=_0x3d6367-0x0;var _0x247257=_0xee05[_0x3d6367];return _0x247257;};'use strict';var _=require('lodash');var util=require('util');var moment=require('moment');var BPromise=require(_0x5ee0('0x0'));var rs=require(_0x5ee0('0x1'));var fs=require('fs');var Redis=require(_0x5ee0('0x2'));var db=require(_0x5ee0('0x3'))['db'];var utils=require(_0x5ee0('0x4'));var logger=require(_0x5ee0('0x5'))(_0x5ee0('0x6'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x5ee0('0x7')][_0x5ee0('0x8')]({'port':0x232a});config['redis']=_[_0x5ee0('0x9')](config['redis'],{'host':_0x5ee0('0xa'),'port':0x18eb});var socket=require(_0x5ee0('0xb'))(new Redis(config[_0x5ee0('0xc')]));require(_0x5ee0('0xd'))[_0x5ee0('0xe')](socket);function respondWithRpcPromise(_0xbe57aa,_0x9a4919,_0x4a3881){return new BPromise(function(_0x2878bb,_0x39ca42){return client['request'](_0xbe57aa,_0x4a3881)[_0x5ee0('0xf')](function(_0x8c5f43){logger[_0x5ee0('0x10')](_0x5ee0('0x11'),_0x9a4919,'request\x20sent');logger[_0x5ee0('0x12')](_0x5ee0('0x13'),_0x9a4919,_0x5ee0('0x14'),JSON[_0x5ee0('0x15')](_0x8c5f43));if(_0x8c5f43[_0x5ee0('0x16')]){if(_0x8c5f43['error']['code']===0x1f4){logger['error'](_0x5ee0('0x11'),_0x9a4919,_0x8c5f43[_0x5ee0('0x16')][_0x5ee0('0x17')]);return _0x39ca42(_0x8c5f43[_0x5ee0('0x16')][_0x5ee0('0x17')]);}logger['error'](_0x5ee0('0x11'),_0x9a4919,_0x8c5f43[_0x5ee0('0x16')][_0x5ee0('0x17')]);return _0x2878bb(_0x8c5f43[_0x5ee0('0x16')]['message']);}else{logger[_0x5ee0('0x10')](_0x5ee0('0x11'),_0x9a4919,'request\x20sent');_0x2878bb(_0x8c5f43[_0x5ee0('0x18')][_0x5ee0('0x17')]);}})[_0x5ee0('0x19')](function(_0x2d7024){logger[_0x5ee0('0x16')](_0x5ee0('0x11'),_0x9a4919,_0x2d7024);_0x39ca42(_0x2d7024);});});}