@@ -2,6 +2,15 @@ import SocketIO = require('socket.io');
2
2
import { LoggifyClass } from '../decorators/Loggify' ;
3
3
import { EventModel , IEvent } from '../models/events' ;
4
4
import { 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
+ }
5
14
6
15
@LoggifyClass
7
16
export class SocketService {
@@ -29,7 +38,8 @@ export class SocketService {
29
38
Event . txStream . on ( 'data' , ( tx : IEvent . TxEvent ) => {
30
39
if ( this . io ) {
31
40
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 ) ;
33
43
}
34
44
} ) ;
35
45
@@ -44,8 +54,9 @@ export class SocketService {
44
54
if ( this . io ) {
45
55
const { coin, address } = addressCoin ;
46
56
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 ) ;
49
60
}
50
61
} ) ;
51
62
}
0 commit comments