Skip to content

Commit 60ceced

Browse files
committed
dev: add user information to threads
1 parent 03045e2 commit 60ceced

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/backend/src/services/ThreadService.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,16 +425,24 @@ class ThreadService extends BaseService {
425425
[uid, offset, limit]
426426
);
427427

428-
res.json(threads.map(this.client_safe_thread));
428+
res.json(await Promise.all(threads.map(
429+
this.client_safe_thread.bind(this))));
429430
}
430431
}).attach(router);
431432
}
432433

433-
client_safe_thread (thread) {
434+
async client_safe_thread (thread) {
435+
const svc_getUser = this.services.get('get-user');
436+
const user = await svc_getUser.get_user({ id: thread.owner_user_id });
437+
434438
return {
435439
uid: thread.uid,
436440
parent: thread.parent_uid,
437441
text: thread.text,
442+
user: {
443+
username: user.username,
444+
uuid: user.uuid,
445+
},
438446
};
439447
}
440448

0 commit comments

Comments
 (0)