From: Carl Worth Date: Sun, 27 Dec 2020 20:11:59 +0000 (-0800) Subject: Add hunt_id to the puzzle table (instead of orig_channel_name) X-Git-Url: https://git.cworth.org/git?p=turbot;a=commitdiff_plain;h=1b30b2a273175896a209d9c37ef08a47d8af6175 Add hunt_id to the puzzle table (instead of orig_channel_name) A recent commit (to announce /solved in the main hunt channel) expected to find hunt_id in this table, but it wasn't there. So we add it in this commit. And while adding it, we drop the orig_channel_name field, (which embedded both hunt_id and channel_id into a single field in the database so would have made renaming of the hunt_id rather awkward). --- diff --git a/turbot/interaction.py b/turbot/interaction.py index d2514e5..cb84976 100644 --- a/turbot/interaction.py +++ b/turbot/interaction.py @@ -356,9 +356,9 @@ def puzzle_submission(turb, payload, metadata): table.put_item( Item={ "channel_id": puzzle_channel_id, - "orig_channel_name": hunt_dash_channel, "solution": [], "status": 'unsolved', + "hunt_id": hunt_id, "name": name, "puzzle_id": puzzle_id, "url": url, @@ -367,13 +367,6 @@ def puzzle_submission(turb, payload, metadata): return lambda_ok -def rename_channel_to_solved(turb, puzzle): - orig_channel_name = puzzle['orig_channel_name'] - channel_id = puzzle['channel_id'] - newName = orig_channel_name + '-solved' - turb.slack_client.conversations_rename(channel=channel_id, - name=newName) - # XXX: This duplicates functionality eith events.py:set_channel_description def set_channel_topic(turb, puzzle): channel_id = puzzle['channel_id'] @@ -469,7 +462,12 @@ def solved(turb, body, args): turbot.sheets.renameSheet(turb, puzzle['sheet_url'], 'SOLVED: ' + puzzle['name']) # Finally, rename the Slack channel to add the suffix '-solved' - rename_channel_to_solved(turb, puzzle) + channel_name = "{}-{}-solved".format( + puzzle['hunt_id'], + puzzle['puzzle_id']) + turb.slack_client.conversations_rename( + channel=puzzle['channel_id'], + name=channel_name) return lambda_ok