16e461b31e694d2a9abe054751eb4e0ee5c781df
[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 _0x2c4d=['localhost','./userNotification.socket','register','request','info','request\x20sent','debug','stringify','error','code','message','UserNotification,\x20%s,\x20%s','result','lodash','util','moment','randomstring','../../mysqldb','rpc','../../config/environment','jayson/promise','client','redis'];(function(_0x5c4d27,_0x5b0822){var _0x1dda1a=function(_0x5ea638){while(--_0x5ea638){_0x5c4d27['push'](_0x5c4d27['shift']());}};_0x1dda1a(++_0x5b0822);}(_0x2c4d,0x1f0));var _0xd2c4=function(_0xa741fa,_0x14b888){_0xa741fa=_0xa741fa-0x0;var _0xfa882c=_0x2c4d[_0xa741fa];return _0xfa882c;};'use strict';var _=require(_0xd2c4('0x0'));var util=require(_0xd2c4('0x1'));var moment=require(_0xd2c4('0x2'));var BPromise=require('bluebird');var rs=require(_0xd2c4('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xd2c4('0x4'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0xd2c4('0x5'));var config=require(_0xd2c4('0x6'));var jayson=require(_0xd2c4('0x7'));var client=jayson[_0xd2c4('0x8')]['http']({'port':0x232a});config['redis']=_['defaults'](config[_0xd2c4('0x9')],{'host':_0xd2c4('0xa'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0xd2c4('0xb'))[_0xd2c4('0xc')](socket);function respondWithRpcPromise(_0xb36136,_0x430b01,_0x501088){return new BPromise(function(_0xc868bc,_0x5711f2){return client[_0xd2c4('0xd')](_0xb36136,_0x501088)['then'](function(_0x4b6222){logger[_0xd2c4('0xe')]('UserNotification,\x20%s,\x20%s',_0x430b01,_0xd2c4('0xf'));logger[_0xd2c4('0x10')]('UserNotification,\x20%s,\x20%s,\x20%s',_0x430b01,_0xd2c4('0xf'),JSON[_0xd2c4('0x11')](_0x4b6222));if(_0x4b6222[_0xd2c4('0x12')]){if(_0x4b6222[_0xd2c4('0x12')][_0xd2c4('0x13')]===0x1f4){logger[_0xd2c4('0x12')]('UserNotification,\x20%s,\x20%s',_0x430b01,_0x4b6222['error'][_0xd2c4('0x14')]);return _0x5711f2(_0x4b6222['error'][_0xd2c4('0x14')]);}logger[_0xd2c4('0x12')](_0xd2c4('0x15'),_0x430b01,_0x4b6222[_0xd2c4('0x12')][_0xd2c4('0x14')]);return _0xc868bc(_0x4b6222[_0xd2c4('0x12')][_0xd2c4('0x14')]);}else{logger[_0xd2c4('0xe')](_0xd2c4('0x15'),_0x430b01,_0xd2c4('0xf'));_0xc868bc(_0x4b6222[_0xd2c4('0x16')][_0xd2c4('0x14')]);}})['catch'](function(_0x2768c4){logger['error'](_0xd2c4('0x15'),_0x430b01,_0x2768c4);_0x5711f2(_0x2768c4);});});}