@@ -69,6 +69,12 @@ async getStatus(userId) {
6969 const isUserA = String ( userId ) === rawMatch . userA ;
7070 const currentUserId = isUserA ? rawMatch . userA : rawMatch . userB ;
7171 const partnerId = isUserA ? rawMatch . userB : rawMatch . userA ;
72+ const currentUsername = isUserA
73+ ? rawMatch . userAName || rawMatch . userAUsername || rawMatch . userA
74+ : rawMatch . userBName || rawMatch . userBUsername || rawMatch . userB ;
75+ const partnerUsername = isUserA
76+ ? rawMatch . userBName || rawMatch . userBUsername || rawMatch . userB
77+ : rawMatch . userAName || rawMatch . userAUsername || rawMatch . userA ;
7278
7379 // ✅ Return fully personalized payload
7480 return {
@@ -80,7 +86,9 @@ async getStatus(userId) {
8086 createdAt : rawMatch . createdAt ,
8187 sessionId,
8288 userId : currentUserId ,
89+ username : currentUsername ,
8390 partnerId,
91+ partnerUsername,
8492 question,
8593 } ,
8694 } ;
@@ -206,7 +214,7 @@ async getStatus(userId) {
206214 /*───────────────────────────────────────────────
207215 * Add user to queue
208216 *───────────────────────────────────────────────*/
209- async join ( { userId, selectedTopics, selectedDifficulty } ) {
217+ async join ( { userId, username = "" , selectedTopics, selectedDifficulty } ) {
210218 console . log ( `[join] Attempting to join for user ${ userId } with topics=${ JSON . stringify ( selectedTopics ) } , difficulty=${ selectedDifficulty } ` ) ;
211219
212220 const existing = await redisClient . hGetAll ( `waiter:${ userId } ` ) ;
@@ -325,6 +333,7 @@ async getStatus(userId) {
325333 const enqueueAt = nowMs ( ) ;
326334 const waiter = {
327335 userId,
336+ username,
328337 selectedTopics : JSON . stringify ( selectedTopics ) ,
329338 selectedDifficulty,
330339 enqueueAt : enqueueAt . toString ( ) ,
@@ -410,16 +419,20 @@ async getStatus(userId) {
410419 /*───────────────────────────────────────────────
411420 * Finalize match
412421 *───────────────────────────────────────────────*/
413- async _finalizePair ( { a, b, topic, difficulty } ) {
422+ async _finalizePair ( { a, b, topic, difficulty } ) {
414423 const matchId = genId ( ) ;
415424 const createdAt = nowMs ( ) ;
416425 const handshakeExpiresAt = createdAt + this . handshakeTtlMs ;
417426
418427 // Base match metadata
428+ const userAName = a . username || "" ;
429+ const userBName = b . username || "" ;
419430 const match = {
420431 matchId,
421432 userA : a . userId ,
433+ userAName,
422434 userB : b . userId ,
435+ userBName,
423436 topic,
424437 difficulty,
425438 createdAt : createdAt . toString ( ) ,
@@ -452,9 +465,16 @@ async _finalizePair({ a, b, topic, difficulty }) {
452465 const res = await axios . post ( `${ COLLAB_SERVICE_BASE_URL } /sessions` , {
453466 userA : a . userId ,
454467 userB : b . userId ,
468+ userAName,
469+ userBName,
455470 topic,
456471 difficulty,
457472 questionId : match . question . id ,
473+ questionTitle : match . question . title ,
474+ questionDescription : match . question . description ,
475+ questionDifficulty : match . question . difficulty || difficulty ,
476+ questionTopic : match . question . topic || topic ,
477+ question : match . question ,
458478 } ) ;
459479 sessionId = res . data ?. id || "" ;
460480 console . log ( `[collab] Session created: ${ sessionId } ` ) ;
0 commit comments