Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-46427: Handle slack interaction payloads #33

Merged
merged 12 commits into from
Sep 26, 2024
Merged

Conversation

jonathansick
Copy link
Member

@jonathansick jonathansick commented Sep 23, 2024

This pull request introduces significant updates to the Slack interaction handling and the Docker environment. The main changes include adding support for Slack block actions and view submissions, updating the Docker base image, and improving message verification. This is driven by the re-implementation of templatebot as a FastAPI/FastStream application, see lsst-sqre/templatebot#67.

Slack Interaction Enhancements:

  • New Features:

    • Added support for Slack block actions and view submissions. These interactions are now parsed into respective payload objects and published to Kafka topics ($SQUAREBOT_TOPIC_BLOCK_ACTIONS and $SQUAREBOT_TOPIC_VIEW_SUBMISSION).
    • Introduced new Kafka message key and value models for Slack block actions and view submissions in client/src/rubin/squarebot/models/kafka.py.
    • Updated client/src/rubin/squarebot/models/slack.py to include models for Slack block actions and view submissions. [1] [2]
  • Configuration and Service Updates:

    • Added new configuration fields for block actions and view submission Kafka topics in server/src/squarebot/config.py.
    • Updated server/src/squarebot/factory.py to include publishers for the new Slack interactions. [1] [2] [3]
    • Modified server/src/squarebot/main.py to handle the new Kafka topics.

Docker Environment Update:

  • Base Image Update:
    • Updated the Docker base image from python:3.12.3-slim-bullseye to python:3.12.6-slim-bookworm in the Dockerfile.

Bug Fixes:

  • Slack Message Verification:
    • Improved Slack message verification to handle both JSON-formatted posts and url-encoded form posts in server/src/squarebot/services/slack.py. [1] [2] [3] [4]

jonathansick added a commit to lsst-sqre/phalanx that referenced this pull request Sep 23, 2024
This adds support for parsing block_actions interaction events from
Slack. See lsst-sqre/squarebot#33
jonathansick added a commit to lsst-sqre/phalanx that referenced this pull request Sep 24, 2024
This adds support for parsing block_actions interaction events from
Slack. See lsst-sqre/squarebot#33
jonathansick added a commit to lsst-sqre/templatebot that referenced this pull request Sep 24, 2024
From lsst-sqre/squarebot#33 this pre-release has
support for block actions payloads and kafka topic.
Base automatically changed from tickets/DM-46413 to main September 26, 2024 19:04
@jonathansick jonathansick marked this pull request as ready for review September 26, 2024 21:53
This improves the model so it better captures an interaction with a
static select menu in a message.

Other types of interactions will need to add to subtypes to
SlackBlockActionBase.
This adapts the `verify_slack` method to now handle both JSON payloads
(like from the events API), and form-encoded data (like from the
interactions API). This idea is based on the tip from
encode/starlette#1933 (reply in thread)
It seems that static selects published with block kit message
attachments actually come out as "message" container types.

Include an actual interaction payload featuring this behaviour for
testing. I think it should be safe to include in the test library
because all triggers, IDs, and response URLs should be expired by now.
This Kafka topic and publisher is for block_actions interaction types.
It replaces the original interim topic for interactions in general since
we've decided to make separate Kafka topics for the different types of
Kafka interactions (block actions vs views vs message shortcuts).
The value is based on the full Pydantic model for the block actions
payload since we're modelling it well. It also includes the raw json
body in the slack_interaction field for clients to get additional
details that aren't parsed.
- Parse the view_submission interaction type into a Pydantic model (this
  model needs more work because it'll need to contain a copy of the
  view, but it'd be easy to base that model off the Block Kit models
  that we'll eventually put in Safir)
- Add a topic configuration for view submissions
- Add a publisher for view submissions, including models for the Kafka
  key and topic.
@jonathansick jonathansick merged commit 01e5bcd into main Sep 26, 2024
6 checks passed
@jonathansick jonathansick deleted the tickets/DM-46427 branch September 26, 2024 22:21
jonathansick added a commit to lsst-sqre/phalanx that referenced this pull request Sep 26, 2024
This adds support for parsing block_actions interaction events from
Slack. See lsst-sqre/squarebot#33
jonathansick added a commit to lsst-sqre/templatebot that referenced this pull request Oct 8, 2024
From lsst-sqre/squarebot#33 this pre-release has
support for block actions payloads and kafka topic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant