9636f0ff4c33fb23c1ee5500a4505821475d7aee
[motion2.git] / server / api / userNotification / userNotification.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 _0xcc14=['util','moment','bluebird','randomstring','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','redis','defaults','register','request','then','UserNotification,\x20%s,\x20%s','request\x20sent','debug','UserNotification,\x20%s,\x20%s,\x20%s','stringify','error','message','info','result','catch','lodash'];(function(_0xa88fb5,_0x3238ba){var _0x37880a=function(_0x512601){while(--_0x512601){_0xa88fb5['push'](_0xa88fb5['shift']());}};_0x37880a(++_0x3238ba);}(_0xcc14,0x67));var _0x4cc1=function(_0x2e8482,_0x13f4d8){_0x2e8482=_0x2e8482-0x0;var _0x588c3b=_0xcc14[_0x2e8482];return _0x588c3b;};'use strict';var _=require(_0x4cc1('0x0'));var util=require(_0x4cc1('0x1'));var moment=require(_0x4cc1('0x2'));var BPromise=require(_0x4cc1('0x3'));var rs=require(_0x4cc1('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x4cc1('0x5'));var logger=require(_0x4cc1('0x6'))(_0x4cc1('0x7'));var config=require(_0x4cc1('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x4cc1('0x9')][_0x4cc1('0xa')]({'port':0x232a});config[_0x4cc1('0xb')]=_[_0x4cc1('0xc')](config[_0x4cc1('0xb')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x4cc1('0xb')]));require('./userNotification.socket')[_0x4cc1('0xd')](socket);function respondWithRpcPromise(_0x1cf5d6,_0x55c4d4,_0x42a727){return new BPromise(function(_0x2e01dd,_0x536824){return client[_0x4cc1('0xe')](_0x1cf5d6,_0x42a727)[_0x4cc1('0xf')](function(_0x1770e9){logger['info'](_0x4cc1('0x10'),_0x55c4d4,_0x4cc1('0x11'));logger[_0x4cc1('0x12')](_0x4cc1('0x13'),_0x55c4d4,_0x4cc1('0x11'),JSON[_0x4cc1('0x14')](_0x1770e9));if(_0x1770e9[_0x4cc1('0x15')]){if(_0x1770e9[_0x4cc1('0x15')]['code']===0x1f4){logger[_0x4cc1('0x15')](_0x4cc1('0x10'),_0x55c4d4,_0x1770e9['error'][_0x4cc1('0x16')]);return _0x536824(_0x1770e9[_0x4cc1('0x15')]['message']);}logger['error'](_0x4cc1('0x10'),_0x55c4d4,_0x1770e9[_0x4cc1('0x15')][_0x4cc1('0x16')]);return _0x2e01dd(_0x1770e9[_0x4cc1('0x15')][_0x4cc1('0x16')]);}else{logger[_0x4cc1('0x17')](_0x4cc1('0x10'),_0x55c4d4,_0x4cc1('0x11'));_0x2e01dd(_0x1770e9[_0x4cc1('0x18')][_0x4cc1('0x16')]);}})[_0x4cc1('0x19')](function(_0x40c0a2){logger[_0x4cc1('0x15')](_0x4cc1('0x10'),_0x55c4d4,_0x40c0a2);_0x536824(_0x40c0a2);});});}