Skip to content

Commit

Permalink
try a wrapper around the message
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathansick committed Feb 22, 2024
1 parent 63f3428 commit 529402c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/unfurlbot/handlers/kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from faststream.kafka.fastapi import KafkaRouter
from faststream.security import BaseSecurity
from pydantic import BaseModel
from rubin.squarebot.models.kafka import SquarebotSlackMessageValue
from structlog import get_logger

Expand All @@ -18,6 +19,12 @@
)


class SlackMessageContainer(BaseModel):
"""Container for a Slack message consumed from Kafka."""

message: SquarebotSlackMessageValue


@kafka_router.subscriber(
config.message_channels_topic,
config.message_groups_topic,
Expand All @@ -26,8 +33,8 @@
group_id=config.consumer_group_id,
)
async def handle_slack_message(
msg: SquarebotSlackMessageValue,
message: SlackMessageContainer,
) -> None:
"""Handle a Slack message."""
logger = get_logger(__name__)
logger.debug("Received a Slack message", text=msg.text)
logger.debug("Received a Slack message", type=type(message))

0 comments on commit 529402c

Please sign in to comment.