bc73a11c75887bef153c1561b1455a9574b6619d
[motion2.git] / server / api / notification / notification.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 _0xc620=['Notification,\x20%s,\x20%s,\x20%s','request\x20sent','error','message','result','lodash','util','bluebird','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','./notification.socket','register','request','then','info','Notification,\x20%s,\x20%s','debug'];(function(_0x46e674,_0x391538){var _0x50984e=function(_0x3760f5){while(--_0x3760f5){_0x46e674['push'](_0x46e674['shift']());}};_0x50984e(++_0x391538);}(_0xc620,0xcd));var _0x0c62=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xc620[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0x0c62('0x0'));var util=require(_0x0c62('0x1'));var moment=require('moment');var BPromise=require(_0x0c62('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x0c62('0x3'));var db=require(_0x0c62('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0x0c62('0x5'))(_0x0c62('0x6'));var config=require(_0x0c62('0x7'));var jayson=require(_0x0c62('0x8'));var client=jayson[_0x0c62('0x9')][_0x0c62('0xa')]({'port':0x232a});config[_0x0c62('0xb')]=_[_0x0c62('0xc')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x0c62('0xd'))[_0x0c62('0xe')](socket);function respondWithRpcPromise(_0x1c6b4f,_0x1a88e3,_0x260c51){return new BPromise(function(_0x248284,_0x2313af){return client[_0x0c62('0xf')](_0x1c6b4f,_0x260c51)[_0x0c62('0x10')](function(_0x4e1297){logger[_0x0c62('0x11')](_0x0c62('0x12'),_0x1a88e3,'request\x20sent');logger[_0x0c62('0x13')](_0x0c62('0x14'),_0x1a88e3,_0x0c62('0x15'),JSON['stringify'](_0x4e1297));if(_0x4e1297[_0x0c62('0x16')]){if(_0x4e1297[_0x0c62('0x16')]['code']===0x1f4){logger[_0x0c62('0x16')]('Notification,\x20%s,\x20%s',_0x1a88e3,_0x4e1297[_0x0c62('0x16')]['message']);return _0x2313af(_0x4e1297[_0x0c62('0x16')]['message']);}logger[_0x0c62('0x16')](_0x0c62('0x12'),_0x1a88e3,_0x4e1297['error'][_0x0c62('0x17')]);return _0x248284(_0x4e1297[_0x0c62('0x16')][_0x0c62('0x17')]);}else{logger[_0x0c62('0x11')](_0x0c62('0x12'),_0x1a88e3,_0x0c62('0x15'));_0x248284(_0x4e1297[_0x0c62('0x18')]['message']);}})['catch'](function(_0x3fe7be){logger['error'](_0x0c62('0x12'),_0x1a88e3,_0x3fe7be);_0x2313af(_0x3fe7be);});});}