// Player · Events — the one handler behind /player/events/history (Phase 14a). // // Self-scoped on `req.user.id` and on nothing the caller sent. The model does // the same joins the public surface does — rehearsals and unlisted events are // absent — so a participant cannot learn from their own history that an // unannounced event exists. const events = require('../../../model/events/eventPublic.model') const log = require('../../../utils/logger')('player:events') async function getHistory(req, res) { try { // A non-integer cursor is dropped rather than bound. `Number('abc')` is NaN, // and NaN reaching a placeholder is a driver-level failure — a 500 for what // is a malformed query string, and the honest answer to one is the first // page. const cursor = Number(req.query.before) const result = await events.history(req.user.id, { limit: req.query.limit ? Number(req.query.limit) : undefined, before: Number.isInteger(cursor) && cursor > 0 ? cursor : null, }) return res.json(result) } catch (err) { log.error('participation history failed', { message: err.message }) return res.status(500).json({ message: 'Internal Server Error' }) } } module.exports = { getHistory }