344be13a89be1591334fa2b647e90e7bd89c35a1
[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 _0x9468=['lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','defaults','localhost','socket.io-emitter','redis','register','request','then','Notification,\x20%s,\x20%s','request\x20sent','debug','Notification,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch'];(function(_0x1602ef,_0x447aba){var _0x5870ee=function(_0x4d94e7){while(--_0x4d94e7){_0x1602ef['push'](_0x1602ef['shift']());}};_0x5870ee(++_0x447aba);}(_0x9468,0x12c));var _0x8946=function(_0x4715d2,_0x3371b2){_0x4715d2=_0x4715d2-0x0;var _0x141811=_0x9468[_0x4715d2];return _0x141811;};'use strict';var _=require(_0x8946('0x0'));var util=require(_0x8946('0x1'));var moment=require(_0x8946('0x2'));var BPromise=require('bluebird');var rs=require(_0x8946('0x3'));var fs=require('fs');var Redis=require(_0x8946('0x4'));var db=require(_0x8946('0x5'))['db'];var utils=require(_0x8946('0x6'));var logger=require(_0x8946('0x7'))(_0x8946('0x8'));var config=require('../../config/environment');var jayson=require(_0x8946('0x9'));var client=jayson[_0x8946('0xa')][_0x8946('0xb')]({'port':0x232a});config['redis']=_[_0x8946('0xc')](config['redis'],{'host':_0x8946('0xd'),'port':0x18eb});var socket=require(_0x8946('0xe'))(new Redis(config[_0x8946('0xf')]));require('./notification.socket')[_0x8946('0x10')](socket);function respondWithRpcPromise(_0x3a2336,_0x2ab8c4,_0x385b27){return new BPromise(function(_0x877918,_0x41cba4){return client[_0x8946('0x11')](_0x3a2336,_0x385b27)[_0x8946('0x12')](function(_0x3189bc){logger['info'](_0x8946('0x13'),_0x2ab8c4,_0x8946('0x14'));logger[_0x8946('0x15')](_0x8946('0x16'),_0x2ab8c4,'request\x20sent',JSON[_0x8946('0x17')](_0x3189bc));if(_0x3189bc['error']){if(_0x3189bc[_0x8946('0x18')][_0x8946('0x19')]===0x1f4){logger[_0x8946('0x18')]('Notification,\x20%s,\x20%s',_0x2ab8c4,_0x3189bc[_0x8946('0x18')][_0x8946('0x1a')]);return _0x41cba4(_0x3189bc['error']['message']);}logger[_0x8946('0x18')](_0x8946('0x13'),_0x2ab8c4,_0x3189bc['error'][_0x8946('0x1a')]);return _0x877918(_0x3189bc[_0x8946('0x18')][_0x8946('0x1a')]);}else{logger[_0x8946('0x1b')]('Notification,\x20%s,\x20%s',_0x2ab8c4,'request\x20sent');_0x877918(_0x3189bc[_0x8946('0x1c')][_0x8946('0x1a')]);}})[_0x8946('0x1d')](function(_0x927c6b){logger[_0x8946('0x18')](_0x8946('0x13'),_0x2ab8c4,_0x927c6b);_0x41cba4(_0x927c6b);});});}