Skip to content

Commit

Permalink
try to use KafkaMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathansick committed Feb 22, 2024
1 parent e9debf1 commit 70592c3
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/unfurlbot/handlers/kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from faststream.kafka.fastapi import Context, KafkaRouter
from faststream.kafka.fastapi import Context, KafkaMessage, KafkaRouter
from faststream.security import BaseSecurity
from pydantic import BaseModel
from rubin.squarebot.models.kafka import SquarebotSlackMessageValue
Expand Down Expand Up @@ -33,10 +33,17 @@ class SlackMessageContainer(BaseModel):
group_id=config.consumer_group_id,
)
async def handle_slack_message(
msg: str,
body: str,
msg: str = KafkaMessage,
topic: str = Context("message.topic"),
) -> None:
"""Handle a Slack message."""
logger = get_logger(__name__)
message = SquarebotSlackMessageValue.model_validate_json(msg)
logger.info("Slack message text", text=message.text, topic=topic)
message = SquarebotSlackMessageValue.model_validate_json(body)
logger.info(
"Slack message text",
text=message.text,
topic=topic,
msg=msg,
msg_topic=msg.topic,
)

0 comments on commit 70592c3

Please sign in to comment.