Add user name to share screen

This commit is contained in:
Joey Yakimowich-Payne 2026-01-16 10:55:55 -07:00
commit 7a83557dc9
No known key found for this signature in database
GPG key ID: 6BFE655FA5ABD1E1
2 changed files with 14 additions and 4 deletions

View file

@ -13,6 +13,8 @@ interface QuizRow {
gameConfig: string | null;
createdAt: string;
updatedAt: string;
sharedByUsername: string | null;
sharedByDisplayName: string | null;
}
interface QuestionRow {
@ -36,9 +38,13 @@ router.get('/:token', (req: Request, res: Response) => {
const { token } = req.params;
const quiz = db.prepare(`
SELECT id, title, source, ai_topic as aiTopic, game_config as gameConfig, created_at as createdAt, updated_at as updatedAt
FROM quizzes
WHERE share_token = ? AND is_shared = 1
SELECT
q.id, q.title, q.source, q.ai_topic as aiTopic, q.game_config as gameConfig,
q.created_at as createdAt, q.updated_at as updatedAt,
u.username as sharedByUsername, u.display_name as sharedByDisplayName
FROM quizzes q
LEFT JOIN users u ON q.user_id = u.id
WHERE q.share_token = ? AND q.is_shared = 1
`).get(token) as QuizRow | undefined;
if (!quiz) {
@ -86,6 +92,7 @@ router.get('/:token', (req: Request, res: Response) => {
gameConfig: parsedConfig,
questions: questionsWithOptions,
questionCount: questions.length,
sharedBy: quiz.sharedByDisplayName || quiz.sharedByUsername || null,
});
});