db7f4cc1478924403cd71d8d91382ed53d749768
[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 _0x5e20=['Notification,\x20%s,\x20%s','request\x20sent','debug','Notification,\x20%s,\x20%s,\x20%s','stringify','error','message','info','result','lodash','util','moment','../../mysqldb','../../config/logger','../../config/environment','jayson/promise','http','redis','defaults','localhost','socket.io-emitter','register','request'];(function(_0x9beb66,_0x44dd5c){var _0x1a4217=function(_0x3978c3){while(--_0x3978c3){_0x9beb66['push'](_0x9beb66['shift']());}};_0x1a4217(++_0x44dd5c);}(_0x5e20,0x11d));var _0x05e2=function(_0x5a1805,_0x222ba1){_0x5a1805=_0x5a1805-0x0;var _0x1a8dca=_0x5e20[_0x5a1805];return _0x1a8dca;};'use strict';var _=require(_0x05e2('0x0'));var util=require(_0x05e2('0x1'));var moment=require(_0x05e2('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x05e2('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0x05e2('0x4'))('rpc');var config=require(_0x05e2('0x5'));var jayson=require(_0x05e2('0x6'));var client=jayson['client'][_0x05e2('0x7')]({'port':0x232a});config[_0x05e2('0x8')]=_[_0x05e2('0x9')](config[_0x05e2('0x8')],{'host':_0x05e2('0xa'),'port':0x18eb});var socket=require(_0x05e2('0xb'))(new Redis(config[_0x05e2('0x8')]));require('./notification.socket')[_0x05e2('0xc')](socket);function respondWithRpcPromise(_0x2db11f,_0x32d878,_0x3b7d8a){return new BPromise(function(_0x31af80,_0x3f78ed){return client[_0x05e2('0xd')](_0x2db11f,_0x3b7d8a)['then'](function(_0x2d303d){logger['info'](_0x05e2('0xe'),_0x32d878,_0x05e2('0xf'));logger[_0x05e2('0x10')](_0x05e2('0x11'),_0x32d878,'request\x20sent',JSON[_0x05e2('0x12')](_0x2d303d));if(_0x2d303d[_0x05e2('0x13')]){if(_0x2d303d[_0x05e2('0x13')]['code']===0x1f4){logger[_0x05e2('0x13')](_0x05e2('0xe'),_0x32d878,_0x2d303d[_0x05e2('0x13')]['message']);return _0x3f78ed(_0x2d303d[_0x05e2('0x13')][_0x05e2('0x14')]);}logger[_0x05e2('0x13')]('Notification,\x20%s,\x20%s',_0x32d878,_0x2d303d[_0x05e2('0x13')][_0x05e2('0x14')]);return _0x31af80(_0x2d303d['error'][_0x05e2('0x14')]);}else{logger[_0x05e2('0x15')](_0x05e2('0xe'),_0x32d878,_0x05e2('0xf'));_0x31af80(_0x2d303d[_0x05e2('0x16')][_0x05e2('0x14')]);}})['catch'](function(_0x5c6fc4){logger[_0x05e2('0x13')]('Notification,\x20%s,\x20%s',_0x32d878,_0x5c6fc4);_0x3f78ed(_0x5c6fc4);});});}