99c38b281a1b40b274f3d77f9545dc483b9a3bec
[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 _0x2a26=['../../config/utils','../../config/logger','rpc','../../config/environment','client','http','redis','defaults','localhost','socket.io-emitter','./notification.socket','then','request\x20sent','debug','Notification,\x20%s,\x20%s,\x20%s','stringify','error','Notification,\x20%s,\x20%s','message','result','lodash','moment','bluebird','../../mysqldb'];(function(_0x2272b5,_0x362458){var _0x110156=function(_0x5c2e32){while(--_0x5c2e32){_0x2272b5['push'](_0x2272b5['shift']());}};_0x110156(++_0x362458);}(_0x2a26,0xbc));var _0x62a2=function(_0x44e4e1,_0x5637b2){_0x44e4e1=_0x44e4e1-0x0;var _0x300cd2=_0x2a26[_0x44e4e1];return _0x300cd2;};'use strict';var _=require(_0x62a2('0x0'));var util=require('util');var moment=require(_0x62a2('0x1'));var BPromise=require(_0x62a2('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x62a2('0x3'))['db'];var utils=require(_0x62a2('0x4'));var logger=require(_0x62a2('0x5'))(_0x62a2('0x6'));var config=require(_0x62a2('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x62a2('0x8')][_0x62a2('0x9')]({'port':0x232a});config[_0x62a2('0xa')]=_[_0x62a2('0xb')](config['redis'],{'host':_0x62a2('0xc'),'port':0x18eb});var socket=require(_0x62a2('0xd'))(new Redis(config[_0x62a2('0xa')]));require(_0x62a2('0xe'))['register'](socket);function respondWithRpcPromise(_0x152951,_0x2fe865,_0x14f7fe){return new BPromise(function(_0x4bebb9,_0x121b8a){return client['request'](_0x152951,_0x14f7fe)[_0x62a2('0xf')](function(_0x19849d){logger['info']('Notification,\x20%s,\x20%s',_0x2fe865,_0x62a2('0x10'));logger[_0x62a2('0x11')](_0x62a2('0x12'),_0x2fe865,'request\x20sent',JSON[_0x62a2('0x13')](_0x19849d));if(_0x19849d['error']){if(_0x19849d['error']['code']===0x1f4){logger[_0x62a2('0x14')](_0x62a2('0x15'),_0x2fe865,_0x19849d[_0x62a2('0x14')][_0x62a2('0x16')]);return _0x121b8a(_0x19849d[_0x62a2('0x14')][_0x62a2('0x16')]);}logger[_0x62a2('0x14')]('Notification,\x20%s,\x20%s',_0x2fe865,_0x19849d[_0x62a2('0x14')][_0x62a2('0x16')]);return _0x4bebb9(_0x19849d[_0x62a2('0x14')]['message']);}else{logger['info'](_0x62a2('0x15'),_0x2fe865,_0x62a2('0x10'));_0x4bebb9(_0x19849d[_0x62a2('0x17')]['message']);}})['catch'](function(_0x47f57d){logger[_0x62a2('0x14')](_0x62a2('0x15'),_0x2fe865,_0x47f57d);_0x121b8a(_0x47f57d);});});}