@@ -204,26 +204,39 @@ export class MatchGateway implements OnGatewayInit {
204
204
// Remove match-related data
205
205
this . matchParticipants . delete ( matchId ) ;
206
206
this . matchConfirmations . delete ( matchId ) ;
207
- client . emit ( MATCH_DECLINED , { message : 'You have declined the match.' } ) ;
207
+ client . emit ( MATCH_DECLINED , {
208
+ message : 'You have declined the match.' ,
209
+ isDecliningUser : true ,
210
+ } ) ;
208
211
}
209
212
210
213
// Notify both users when they are matched
211
- notifyUsersWithMatch ( matchedUsers : string [ ] ) {
214
+ async notifyUsersWithMatch ( matchedUsers : string [ ] ) {
212
215
const [ user1 , user2 ] = matchedUsers ;
213
216
const user1SocketId = this . getUserSocketId ( user1 ) ;
214
217
const user2SocketId = this . getUserSocketId ( user2 ) ;
215
218
219
+ const user1Details = await firstValueFrom (
220
+ this . userClient . send ( { cmd : 'get-user-by-id' } , user1 ) ,
221
+ ) ;
222
+
223
+ const user2Details = await firstValueFrom (
224
+ this . userClient . send ( { cmd : 'get-user-by-id' } , user2 ) ,
225
+ ) ;
226
+
216
227
if ( user1SocketId && user2SocketId ) {
217
228
const matchId = this . generateMatchId ( ) ;
218
229
this . server . to ( user1SocketId ) . emit ( MATCH_FOUND , {
219
230
message : `You have found a match` ,
220
- matchUserId : user2 ,
221
231
matchId,
232
+ matchUserId : user2 ,
233
+ matchUsername : user2Details . username ,
222
234
} ) ;
223
235
this . server . to ( user2SocketId ) . emit ( MATCH_FOUND , {
224
236
message : `You have found a match` ,
225
- matchUserId : user1 ,
226
237
matchId,
238
+ matchUserId : user1 ,
239
+ matchUsername : user1Details . username ,
227
240
} ) ;
228
241
229
242
// Store participants for this matchId
@@ -260,6 +273,7 @@ export class MatchGateway implements OnGatewayInit {
260
273
if ( socketId ) {
261
274
this . server . to ( socketId ) . emit ( MATCH_DECLINED , {
262
275
message : 'The other user has declined the match.' ,
276
+ isDecliningUser : false ,
263
277
} ) ;
264
278
}
265
279
}
0 commit comments