@@ -2,6 +2,15 @@ import SocketIO = require('socket.io');
22import { LoggifyClass } from '../decorators/Loggify' ;
33import { EventModel , IEvent } from '../models/events' ;
44import { Event } from './event' ;
5+ import { ObjectID } from 'mongodb' ;
6+
7+ function SanitizeWallet ( x : { wallets : ObjectID [ ] } ) {
8+ const sanitized = Object . assign ( { } , x , { wallets : undefined } ) ;
9+ if ( sanitized . wallets && sanitized . wallets . length > 0 ) {
10+ delete sanitized . wallets ;
11+ }
12+ return sanitized ;
13+ }
514
615@LoggifyClass
716export class SocketService {
@@ -29,7 +38,8 @@ export class SocketService {
2938 Event . txStream . on ( 'data' , ( tx : IEvent . TxEvent ) => {
3039 if ( this . io ) {
3140 const { chain, network } = tx ;
32- this . io . sockets . in ( `/${ chain } /${ network } /inv` ) . emit ( 'tx' , tx ) ;
41+ const sanitizedTx = SanitizeWallet ( tx ) ;
42+ this . io . sockets . in ( `/${ chain } /${ network } /inv` ) . emit ( 'tx' , sanitizedTx ) ;
3343 }
3444 } ) ;
3545
@@ -44,8 +54,9 @@ export class SocketService {
4454 if ( this . io ) {
4555 const { coin, address } = addressCoin ;
4656 const { chain, network } = coin ;
47- this . io . sockets . in ( `/${ chain } /${ network } /address` ) . emit ( address , coin ) ;
48- this . io . sockets . in ( `/${ chain } /${ network } /inv` ) . emit ( 'coin' , coin ) ;
57+ const sanitizedCoin = SanitizeWallet ( coin ) ;
58+ this . io . sockets . in ( `/${ chain } /${ network } /address` ) . emit ( address , sanitizedCoin ) ;
59+ this . io . sockets . in ( `/${ chain } /${ network } /inv` ) . emit ( 'coin' , sanitizedCoin ) ;
4960 }
5061 } ) ;
5162 }
0 commit comments