39c405c2676bf424225014fd86d881ef1e21597a
[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 _0x7c29=['catch','util','moment','bluebird','ioredis','../../mysqldb','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./userNotification.socket','register','request','UserNotification,\x20%s,\x20%s','request\x20sent','debug','UserNotification,\x20%s,\x20%s,\x20%s','stringify','error','code','message'];(function(_0x4fdee1,_0x3f290c){var _0x87826e=function(_0x2cbeaa){while(--_0x2cbeaa){_0x4fdee1['push'](_0x4fdee1['shift']());}};_0x87826e(++_0x3f290c);}(_0x7c29,0x16d));var _0x97c2=function(_0xecb0e9,_0x5cf22){_0xecb0e9=_0xecb0e9-0x0;var _0x41428a=_0x7c29[_0xecb0e9];return _0x41428a;};'use strict';var _=require('lodash');var util=require(_0x97c2('0x0'));var moment=require(_0x97c2('0x1'));var BPromise=require(_0x97c2('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x97c2('0x3'));var db=require(_0x97c2('0x4'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x97c2('0x5'));var config=require(_0x97c2('0x6'));var jayson=require(_0x97c2('0x7'));var client=jayson[_0x97c2('0x8')][_0x97c2('0x9')]({'port':0x232a});config[_0x97c2('0xa')]=_[_0x97c2('0xb')](config[_0x97c2('0xa')],{'host':_0x97c2('0xc'),'port':0x18eb});var socket=require(_0x97c2('0xd'))(new Redis(config[_0x97c2('0xa')]));require(_0x97c2('0xe'))[_0x97c2('0xf')](socket);function respondWithRpcPromise(_0x3dc794,_0x42562b,_0x1870de){return new BPromise(function(_0x124906,_0x4a3db5){return client[_0x97c2('0x10')](_0x3dc794,_0x1870de)['then'](function(_0x49bdbf){logger['info'](_0x97c2('0x11'),_0x42562b,_0x97c2('0x12'));logger[_0x97c2('0x13')](_0x97c2('0x14'),_0x42562b,_0x97c2('0x12'),JSON[_0x97c2('0x15')](_0x49bdbf));if(_0x49bdbf[_0x97c2('0x16')]){if(_0x49bdbf['error'][_0x97c2('0x17')]===0x1f4){logger[_0x97c2('0x16')]('UserNotification,\x20%s,\x20%s',_0x42562b,_0x49bdbf[_0x97c2('0x16')][_0x97c2('0x18')]);return _0x4a3db5(_0x49bdbf[_0x97c2('0x16')][_0x97c2('0x18')]);}logger[_0x97c2('0x16')](_0x97c2('0x11'),_0x42562b,_0x49bdbf[_0x97c2('0x16')][_0x97c2('0x18')]);return _0x124906(_0x49bdbf['error'][_0x97c2('0x18')]);}else{logger['info'](_0x97c2('0x11'),_0x42562b,'request\x20sent');_0x124906(_0x49bdbf['result'][_0x97c2('0x18')]);}})[_0x97c2('0x19')](function(_0x90252e){logger[_0x97c2('0x16')]('UserNotification,\x20%s,\x20%s',_0x42562b,_0x90252e);_0x4a3db5(_0x90252e);});});}