986fe4926fdcf721da93b3da73ea3a0bb751df48
[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 _0x7bc2=['redis','localhost','socket.io-emitter','./userNotification.socket','UserNotification,\x20%s,\x20%s','request\x20sent','debug','UserNotification,\x20%s,\x20%s,\x20%s','stringify','error','message','info','result','catch','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','defaults'];(function(_0x1d9f84,_0x14f190){var _0x148206=function(_0x37129b){while(--_0x37129b){_0x1d9f84['push'](_0x1d9f84['shift']());}};_0x148206(++_0x14f190);}(_0x7bc2,0x7e));var _0x27bc=function(_0x3b57a3,_0x4d7071){_0x3b57a3=_0x3b57a3-0x0;var _0x3e6391=_0x7bc2[_0x3b57a3];return _0x3e6391;};'use strict';var _=require(_0x27bc('0x0'));var util=require(_0x27bc('0x1'));var moment=require(_0x27bc('0x2'));var BPromise=require(_0x27bc('0x3'));var rs=require(_0x27bc('0x4'));var fs=require('fs');var Redis=require(_0x27bc('0x5'));var db=require(_0x27bc('0x6'))['db'];var utils=require(_0x27bc('0x7'));var logger=require(_0x27bc('0x8'))(_0x27bc('0x9'));var config=require(_0x27bc('0xa'));var jayson=require('jayson/promise');var client=jayson[_0x27bc('0xb')][_0x27bc('0xc')]({'port':0x232a});config['redis']=_[_0x27bc('0xd')](config[_0x27bc('0xe')],{'host':_0x27bc('0xf'),'port':0x18eb});var socket=require(_0x27bc('0x10'))(new Redis(config[_0x27bc('0xe')]));require(_0x27bc('0x11'))['register'](socket);function respondWithRpcPromise(_0x85cdfa,_0x3865d5,_0x1bb131){return new BPromise(function(_0x40f2a3,_0x5541cc){return client['request'](_0x85cdfa,_0x1bb131)['then'](function(_0x517cad){logger['info'](_0x27bc('0x12'),_0x3865d5,_0x27bc('0x13'));logger[_0x27bc('0x14')](_0x27bc('0x15'),_0x3865d5,_0x27bc('0x13'),JSON[_0x27bc('0x16')](_0x517cad));if(_0x517cad[_0x27bc('0x17')]){if(_0x517cad['error']['code']===0x1f4){logger[_0x27bc('0x17')](_0x27bc('0x12'),_0x3865d5,_0x517cad['error'][_0x27bc('0x18')]);return _0x5541cc(_0x517cad[_0x27bc('0x17')][_0x27bc('0x18')]);}logger[_0x27bc('0x17')](_0x27bc('0x12'),_0x3865d5,_0x517cad['error']['message']);return _0x40f2a3(_0x517cad['error']['message']);}else{logger[_0x27bc('0x19')](_0x27bc('0x12'),_0x3865d5,_0x27bc('0x13'));_0x40f2a3(_0x517cad[_0x27bc('0x1a')][_0x27bc('0x18')]);}})[_0x27bc('0x1b')](function(_0x12a83c){logger[_0x27bc('0x17')](_0x27bc('0x12'),_0x3865d5,_0x12a83c);_0x5541cc(_0x12a83c);});});}