9109d26bd384afa9ff14dac1398d5c061b797542
[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 _0x266e=['error','code','Notification,\x20%s,\x20%s','message','result','catch','lodash','moment','bluebird','randomstring','../../config/logger','rpc','../../config/environment','http','redis','defaults','socket.io-emitter','./notification.socket','register','request','then','info','request\x20sent','Notification,\x20%s,\x20%s,\x20%s','stringify'];(function(_0x595a7a,_0x25e38a){var _0x3910fc=function(_0x384b79){while(--_0x384b79){_0x595a7a['push'](_0x595a7a['shift']());}};_0x3910fc(++_0x25e38a);}(_0x266e,0x9c));var _0xe266=function(_0x5dd1f7,_0x5a2948){_0x5dd1f7=_0x5dd1f7-0x0;var _0x1239bc=_0x266e[_0x5dd1f7];return _0x1239bc;};'use strict';var _=require(_0xe266('0x0'));var util=require('util');var moment=require(_0xe266('0x1'));var BPromise=require(_0xe266('0x2'));var rs=require(_0xe266('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0xe266('0x4'))(_0xe266('0x5'));var config=require(_0xe266('0x6'));var jayson=require('jayson/promise');var client=jayson['client'][_0xe266('0x7')]({'port':0x232a});config[_0xe266('0x8')]=_[_0xe266('0x9')](config[_0xe266('0x8')],{'host':'localhost','port':0x18eb});var socket=require(_0xe266('0xa'))(new Redis(config[_0xe266('0x8')]));require(_0xe266('0xb'))[_0xe266('0xc')](socket);function respondWithRpcPromise(_0xd0db18,_0x3700e1,_0x3a31f1){return new BPromise(function(_0x3265a3,_0x5e37a0){return client[_0xe266('0xd')](_0xd0db18,_0x3a31f1)[_0xe266('0xe')](function(_0x2be67b){logger[_0xe266('0xf')]('Notification,\x20%s,\x20%s',_0x3700e1,_0xe266('0x10'));logger['debug'](_0xe266('0x11'),_0x3700e1,_0xe266('0x10'),JSON[_0xe266('0x12')](_0x2be67b));if(_0x2be67b[_0xe266('0x13')]){if(_0x2be67b['error'][_0xe266('0x14')]===0x1f4){logger['error'](_0xe266('0x15'),_0x3700e1,_0x2be67b[_0xe266('0x13')][_0xe266('0x16')]);return _0x5e37a0(_0x2be67b[_0xe266('0x13')][_0xe266('0x16')]);}logger[_0xe266('0x13')]('Notification,\x20%s,\x20%s',_0x3700e1,_0x2be67b[_0xe266('0x13')][_0xe266('0x16')]);return _0x3265a3(_0x2be67b['error'][_0xe266('0x16')]);}else{logger['info']('Notification,\x20%s,\x20%s',_0x3700e1,_0xe266('0x10'));_0x3265a3(_0x2be67b[_0xe266('0x17')][_0xe266('0x16')]);}})[_0xe266('0x18')](function(_0x5625cc){logger['error']('Notification,\x20%s,\x20%s',_0x3700e1,_0x5625cc);_0x5e37a0(_0x5625cc);});});}