aboutsummaryrefslogtreecommitdiffstats
path: root/bot/constants.py
diff options
context:
space:
mode:
authorGravatar Sebastiaan Zeeff <[email protected]>2020-12-05 00:39:09 +0100
committerGravatar Sebastiaan Zeeff <[email protected]>2020-12-05 00:39:09 +0100
commitc21014abc7c74a72363daeac3714b9fa976247ce (patch)
tree5dcc9b32be8189b04523c33e1567aad9ad449f47 /bot/constants.py
parentSupport a fallback session cookie in constants (diff)
Mitigate session expiry by using fallback session
Unfortunately, an expired session cookie wreaked havoc to our Advent of Code commands: All commands that relied on leaderboard data failed because we couldn't refresh our data and the cache had expired. To mitigate an expired session, I've added a fallback session feature that enables us to try again with a different session. While it will issue an error message to inform us to refresh the expired session cookie, it does mean that the functionality should continue to work in the mean time. The fallback session cookie is currently set to my session cookie, using an environment variable, `AOC_FALLBACK_SESSION`. It is important that the user connected to the session is a member of all boards and that it's a fresh session: We don't want our fallback to expire! At the same time, while a single fallback session works, the AoC website also does not like too many requests from a single user. That's why we'll still use a multi-session model under normal circumstances. To check for expired sessions, I've added a URL check: The Advent of Code website will silently redirect people with an expired session, issuing an 200: OK status as usual. The only way to really check for it is by comparing the final URL in the response object to the URL we set out to GET. I've added a custom exception to signal such an unexpected redirect. Finally, instead of having the commands just break, I've added an Exception signal that propagates back to the caller. The solution, with try-except, is a bit hacky and could benefit from an actual error handler, but I wanted to get things fixed first; polish can be added later.
Diffstat (limited to 'bot/constants.py')
0 files changed, 0 insertions, 0 deletions