6bb96f169a1459d2d34596eca10aef0af078681f
[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 _0x312e=['info','UserNotification,\x20%s,\x20%s','debug','request\x20sent','stringify','error','message','result','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','http','redis','defaults','localhost','socket.io-emitter','register','then'];(function(_0x59d880,_0x4252db){var _0xd0f919=function(_0x12d39){while(--_0x12d39){_0x59d880['push'](_0x59d880['shift']());}};_0xd0f919(++_0x4252db);}(_0x312e,0x1ca));var _0xe312=function(_0x4073ec,_0x4ea5d5){_0x4073ec=_0x4073ec-0x0;var _0x24245b=_0x312e[_0x4073ec];return _0x24245b;};'use strict';var _=require(_0xe312('0x0'));var util=require(_0xe312('0x1'));var moment=require(_0xe312('0x2'));var BPromise=require(_0xe312('0x3'));var rs=require(_0xe312('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xe312('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0xe312('0x6'))(_0xe312('0x7'));var config=require(_0xe312('0x8'));var jayson=require(_0xe312('0x9'));var client=jayson['client'][_0xe312('0xa')]({'port':0x232a});config[_0xe312('0xb')]=_[_0xe312('0xc')](config[_0xe312('0xb')],{'host':_0xe312('0xd'),'port':0x18eb});var socket=require(_0xe312('0xe'))(new Redis(config['redis']));require('./userNotification.socket')[_0xe312('0xf')](socket);function respondWithRpcPromise(_0x19f431,_0x50d67f,_0x204fdc){return new BPromise(function(_0x4f7292,_0x46cd10){return client['request'](_0x19f431,_0x204fdc)[_0xe312('0x10')](function(_0x461b64){logger[_0xe312('0x11')](_0xe312('0x12'),_0x50d67f,'request\x20sent');logger[_0xe312('0x13')]('UserNotification,\x20%s,\x20%s,\x20%s',_0x50d67f,_0xe312('0x14'),JSON[_0xe312('0x15')](_0x461b64));if(_0x461b64[_0xe312('0x16')]){if(_0x461b64['error']['code']===0x1f4){logger[_0xe312('0x16')](_0xe312('0x12'),_0x50d67f,_0x461b64[_0xe312('0x16')][_0xe312('0x17')]);return _0x46cd10(_0x461b64[_0xe312('0x16')][_0xe312('0x17')]);}logger['error'](_0xe312('0x12'),_0x50d67f,_0x461b64[_0xe312('0x16')]['message']);return _0x4f7292(_0x461b64[_0xe312('0x16')][_0xe312('0x17')]);}else{logger[_0xe312('0x11')](_0xe312('0x12'),_0x50d67f,_0xe312('0x14'));_0x4f7292(_0x461b64[_0xe312('0x18')]['message']);}})['catch'](function(_0x464ae5){logger[_0xe312('0x16')](_0xe312('0x12'),_0x50d67f,_0x464ae5);_0x46cd10(_0x464ae5);});});}