From 2da7e775f26043e0d475faf89d1fce03c798b1e3 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 13 Sep 2023 19:22:07 +0200 Subject: Don't show private open games on user page. --- server.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/server.js b/server.js index 8b4194d..6b38b7a 100644 --- a/server.js +++ b/server.js @@ -647,7 +647,7 @@ app.get('/user/:who_name', function (req, res) { if (who) { who.ctime = human_date(who.ctime) who.atime = human_date(who.atime) - let games = QUERY_LIST_ACTIVE_GAMES_OF_USER.all({ user_id: who.user_id }) + let games = QUERY_LIST_PUBLIC_GAMES_OF_USER.all({ user_id: who.user_id }) annotate_games(games, 0, null) let relation = 0 if (req.user) @@ -1204,6 +1204,17 @@ const QUERY_NEXT_GAME_OF_USER = SQL(` limit 1 `) +const QUERY_LIST_PUBLIC_GAMES_OF_USER = SQL(` + select * from game_view + where + ( owner_id=$user_id or game_id in ( select game_id from players where players.user_id=$user_id ) ) + and + ( status <= ${STATUS_FINISHED} ) + and + ( not is_private or status = ${STATUS_ACTIVE} ) + order by status asc, mtime desc + `) + const QUERY_LIST_ACTIVE_GAMES_OF_USER = SQL(` select * from game_view where @@ -1380,10 +1391,6 @@ app.get('/games/public', function (req, res) { res.render('games_public.pug', { user: req.user, games0, games1 }) }) -app.get('/info/:title_id', function (req, res) { - return res.redirect('/' + req.params.title_id) -}) - function get_title_page(req, res, title_id) { let title = TITLES[title_id] if (!title) @@ -1778,7 +1785,6 @@ const webhook_text_options = { } function on_webhook_success(user_id) { - console.log("WEBHOOK SENT", user_id) SQL_UPDATE_WEBHOOK_SUCCESS.run(user_id) } -- cgit v1.2.3