]> git.cworth.org Git - turbot/commitdiff
Add hunt_id to the puzzle table (instead of orig_channel_name)
authorCarl Worth <cworth@cworth.org>
Sun, 27 Dec 2020 20:11:59 +0000 (12:11 -0800)
committerCarl Worth <cworth@cworth.org>
Sun, 27 Dec 2020 20:23:28 +0000 (12:23 -0800)
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).

turbot/interaction.py

index d2514e5d6543878b58483e582eea381db24e3313..cb849763c33ff153ec92f06201dffe0e57cd6007 100644 (file)
@@ -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