It was only by accident that what I had written happened to work,
(apparently AWS reuses Lambda containers within a 30-minute window or
so). Obviously, I don't want to rely on anything like that, so instead
in this commit I take advantage of the "private_metadata" field that
Slack offers for me to pass data back and forth on a view and use that
to decide which function to invoke to handle view submission.
from turbot.blocks import input_block
import uuid
from turbot.blocks import input_block
import uuid
-submission_handlers = {}
-
def new_hunt(turb, payload):
"""Handler for the action of user pressing the new_hunt button"""
view = {
"type": "modal",
def new_hunt(turb, payload):
"""Handler for the action of user pressing the new_hunt button"""
view = {
"type": "modal",
+ "private_metadata": "new_hunt",
"title": { "type": "plain_text", "text": "New Hunt" },
"submit": { "type": "plain_text", "text": "Create" },
"blocks": [
"title": { "type": "plain_text", "text": "New Hunt" },
"submit": { "type": "plain_text", "text": "Create" },
"blocks": [
Specifically, those that have a payload type of 'view_submission'"""
Specifically, those that have a payload type of 'view_submission'"""
- view_id = payload['view']['id']
+ view_id = payload['view']['private_metadata']
if view_id in submission_handlers:
return submission_handlers[view_id](turb, payload)
if view_id in submission_handlers:
return submission_handlers[view_id](turb, payload)
+
+submission_handlers = {
+ "new_hunt": new_hunt_submission
+}