5484c0c838244bf48230ef1060a618e964b9301f
[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 _0xaf97=['UserNotification,\x20%s,\x20%s','request\x20sent','debug','UserNotification,\x20%s,\x20%s,\x20%s','error','code','message','catch','util','moment','bluebird','ioredis','../../config/utils','rpc','../../config/environment','jayson/promise','http','redis','localhost','socket.io-emitter','./userNotification.socket','register','request','then','info'];(function(_0x240e11,_0x244182){var _0x547ca6=function(_0x17b6af){while(--_0x17b6af){_0x240e11['push'](_0x240e11['shift']());}};_0x547ca6(++_0x244182);}(_0xaf97,0x198));var _0x7af9=function(_0x5997ba,_0x360bb7){_0x5997ba=_0x5997ba-0x0;var _0x5db2b0=_0xaf97[_0x5997ba];return _0x5db2b0;};'use strict';var _=require('lodash');var util=require(_0x7af9('0x0'));var moment=require(_0x7af9('0x1'));var BPromise=require(_0x7af9('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x7af9('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x7af9('0x4'));var logger=require('../../config/logger')(_0x7af9('0x5'));var config=require(_0x7af9('0x6'));var jayson=require(_0x7af9('0x7'));var client=jayson['client'][_0x7af9('0x8')]({'port':0x232a});config[_0x7af9('0x9')]=_['defaults'](config['redis'],{'host':_0x7af9('0xa'),'port':0x18eb});var socket=require(_0x7af9('0xb'))(new Redis(config[_0x7af9('0x9')]));require(_0x7af9('0xc'))[_0x7af9('0xd')](socket);function respondWithRpcPromise(_0x56b897,_0x578b0d,_0x1f54ee){return new BPromise(function(_0x49f642,_0x1a5abd){return client[_0x7af9('0xe')](_0x56b897,_0x1f54ee)[_0x7af9('0xf')](function(_0x1a064a){logger[_0x7af9('0x10')](_0x7af9('0x11'),_0x578b0d,_0x7af9('0x12'));logger[_0x7af9('0x13')](_0x7af9('0x14'),_0x578b0d,_0x7af9('0x12'),JSON['stringify'](_0x1a064a));if(_0x1a064a[_0x7af9('0x15')]){if(_0x1a064a[_0x7af9('0x15')][_0x7af9('0x16')]===0x1f4){logger[_0x7af9('0x15')](_0x7af9('0x11'),_0x578b0d,_0x1a064a[_0x7af9('0x15')][_0x7af9('0x17')]);return _0x1a5abd(_0x1a064a['error']['message']);}logger[_0x7af9('0x15')](_0x7af9('0x11'),_0x578b0d,_0x1a064a[_0x7af9('0x15')]['message']);return _0x49f642(_0x1a064a['error'][_0x7af9('0x17')]);}else{logger[_0x7af9('0x10')](_0x7af9('0x11'),_0x578b0d,_0x7af9('0x12'));_0x49f642(_0x1a064a['result'][_0x7af9('0x17')]);}})[_0x7af9('0x18')](function(_0x49a9dc){logger[_0x7af9('0x15')](_0x7af9('0x11'),_0x578b0d,_0x49a9dc);_0x1a5abd(_0x49a9dc);});});}