dc30e63dc832614f5cb269c7827ea76f97c2e3a6
[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 _0x4523=['request\x20sent','result','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','http','redis','./notification.socket','register','request','then','info','Notification,\x20%s,\x20%s','debug','Notification,\x20%s,\x20%s,\x20%s','error','code','message'];(function(_0x1bbefb,_0x597094){var _0x1d9bbd=function(_0x5bc1aa){while(--_0x5bc1aa){_0x1bbefb['push'](_0x1bbefb['shift']());}};_0x1d9bbd(++_0x597094);}(_0x4523,0x182));var _0x3452=function(_0x4ed85c,_0x39b0c9){_0x4ed85c=_0x4ed85c-0x0;var _0x248a52=_0x4523[_0x4ed85c];return _0x248a52;};'use strict';var _=require('lodash');var util=require(_0x3452('0x0'));var moment=require('moment');var BPromise=require(_0x3452('0x1'));var rs=require(_0x3452('0x2'));var fs=require('fs');var Redis=require(_0x3452('0x3'));var db=require(_0x3452('0x4'))['db'];var utils=require(_0x3452('0x5'));var logger=require(_0x3452('0x6'))('rpc');var config=require(_0x3452('0x7'));var jayson=require(_0x3452('0x8'));var client=jayson['client'][_0x3452('0x9')]({'port':0x232a});config[_0x3452('0xa')]=_['defaults'](config[_0x3452('0xa')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x3452('0xa')]));require(_0x3452('0xb'))[_0x3452('0xc')](socket);function respondWithRpcPromise(_0xc100db,_0x101098,_0x3253e6){return new BPromise(function(_0x4dfadf,_0x341a2b){return client[_0x3452('0xd')](_0xc100db,_0x3253e6)[_0x3452('0xe')](function(_0x12d4b2){logger[_0x3452('0xf')](_0x3452('0x10'),_0x101098,'request\x20sent');logger[_0x3452('0x11')](_0x3452('0x12'),_0x101098,'request\x20sent',JSON['stringify'](_0x12d4b2));if(_0x12d4b2[_0x3452('0x13')]){if(_0x12d4b2[_0x3452('0x13')][_0x3452('0x14')]===0x1f4){logger[_0x3452('0x13')](_0x3452('0x10'),_0x101098,_0x12d4b2[_0x3452('0x13')][_0x3452('0x15')]);return _0x341a2b(_0x12d4b2[_0x3452('0x13')][_0x3452('0x15')]);}logger[_0x3452('0x13')]('Notification,\x20%s,\x20%s',_0x101098,_0x12d4b2[_0x3452('0x13')]['message']);return _0x4dfadf(_0x12d4b2['error'][_0x3452('0x15')]);}else{logger[_0x3452('0xf')]('Notification,\x20%s,\x20%s',_0x101098,_0x3452('0x16'));_0x4dfadf(_0x12d4b2[_0x3452('0x17')][_0x3452('0x15')]);}})['catch'](function(_0x3a1646){logger['error'](_0x3452('0x10'),_0x101098,_0x3a1646);_0x341a2b(_0x3a1646);});});}