d6c3ced2f6c8651b2ac044a861f687aabe1bf937
[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 _0xb6f0=['http','redis','localhost','socket.io-emitter','./notification.socket','register','then','debug','Notification,\x20%s,\x20%s,\x20%s','request\x20sent','error','Notification,\x20%s,\x20%s','message','info','catch','lodash','util','moment','randomstring','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','client'];(function(_0x22b68a,_0x2bffc3){var _0x1ac67a=function(_0x25f9d5){while(--_0x25f9d5){_0x22b68a['push'](_0x22b68a['shift']());}};_0x1ac67a(++_0x2bffc3);}(_0xb6f0,0xff));var _0x0b6f=function(_0x3bc298,_0x583d14){_0x3bc298=_0x3bc298-0x0;var _0x31bf58=_0xb6f0[_0x3bc298];return _0x31bf58;};'use strict';var _=require(_0x0b6f('0x0'));var util=require(_0x0b6f('0x1'));var moment=require(_0x0b6f('0x2'));var BPromise=require('bluebird');var rs=require(_0x0b6f('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x0b6f('0x4'))['db'];var utils=require(_0x0b6f('0x5'));var logger=require(_0x0b6f('0x6'))('rpc');var config=require(_0x0b6f('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x0b6f('0x8')][_0x0b6f('0x9')]({'port':0x232a});config[_0x0b6f('0xa')]=_['defaults'](config['redis'],{'host':_0x0b6f('0xb'),'port':0x18eb});var socket=require(_0x0b6f('0xc'))(new Redis(config['redis']));require(_0x0b6f('0xd'))[_0x0b6f('0xe')](socket);function respondWithRpcPromise(_0x541f2b,_0x53d5c2,_0x2a1170){return new BPromise(function(_0x2fa7d1,_0x243a18){return client['request'](_0x541f2b,_0x2a1170)[_0x0b6f('0xf')](function(_0x28e54a){logger['info']('Notification,\x20%s,\x20%s',_0x53d5c2,'request\x20sent');logger[_0x0b6f('0x10')](_0x0b6f('0x11'),_0x53d5c2,_0x0b6f('0x12'),JSON['stringify'](_0x28e54a));if(_0x28e54a[_0x0b6f('0x13')]){if(_0x28e54a['error']['code']===0x1f4){logger['error'](_0x0b6f('0x14'),_0x53d5c2,_0x28e54a['error']['message']);return _0x243a18(_0x28e54a[_0x0b6f('0x13')]['message']);}logger['error'](_0x0b6f('0x14'),_0x53d5c2,_0x28e54a[_0x0b6f('0x13')]['message']);return _0x2fa7d1(_0x28e54a['error'][_0x0b6f('0x15')]);}else{logger[_0x0b6f('0x16')](_0x0b6f('0x14'),_0x53d5c2,_0x0b6f('0x12'));_0x2fa7d1(_0x28e54a['result']['message']);}})[_0x0b6f('0x17')](function(_0x5582d5){logger[_0x0b6f('0x13')]('Notification,\x20%s,\x20%s',_0x53d5c2,_0x5582d5);_0x243a18(_0x5582d5);});});}