Skip to content

Conversation

@david-lyft
Copy link
Contributor

@david-lyft david-lyft commented May 31, 2025

Adds support for reactions made on thread replies.

The item_user field is only present for reaction events on messages such as those made with chat.postMessage. Responses made through slack command responses look similar to messages but reactions events on them do not contain item_user field and require a fallback check to determine which bot sent the response.

@david-lyft david-lyft requested a review from Copilot May 31, 2025 02:09
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds support for handling reactions on thread replies by capturing the item_user field and updating the processing logic to branch on thread messages vs. regular messages.

  • Extended Reaction payload with item_user and added a corresponding property.
  • Updated _process_reaction_message_handlers to ignore non-bot thread replies and to defer to _is_message_from_bot for top-level messages.
  • Refined _is_message_from_bot to separate missing-message and non-bot message logging and return behavior.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
omnibot/services/slack/reaction.py Added item_user into payload with property and adjusted logs.
omnibot/processor.py Branched on item_user, refined ignore logic, and improved logging in _is_message_from_bot.
Comments suppressed due to low confidence (3)

omnibot/services/slack/reaction.py:24

  • Add consistent punctuation (e.g., a trailing period) to the log message to match existing style guidelines.
logger.error("Reaction event is missing reaction attribute")

omnibot/services/slack/reaction.py:22

  • Catching all exceptions is too broad; consider catching specific exceptions (e.g., KeyError) to avoid masking unrelated errors.
except Exception:

omnibot/services/slack/reaction.py:38

  • Add tests to cover cases where item_user is present and absent to ensure thread reaction handling behaves as expected.
self._payload["item_user"] = event.get("item_user")

@david-lyft david-lyft requested a review from colinsl May 31, 2025 02:11
if not _is_message_from_bot(bot, item_channel, item_ts):
if item_user is not None:
if item_user != bot.user_id:
statsd.incr("event.ignored")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we get called with irrelevant events?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, an event is sent for every bot that is in the channel.

handler_called = False
item_channel = reaction.item_channel
item_ts = reaction.item_ts
item_user = reaction.item_user
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we differentiating reaction user too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the user who made the reaction is set in BaseMessage using user field

@david-lyft david-lyft requested a review from Copilot June 2, 2025 18:21
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds thread support for reaction message handlers by updating reaction payload extraction and refining message processing.

  • Captures the item_user field in reaction events, and exposes it via a new property in reaction.py.
  • Updates the reaction message handler in processor.py to use item_user when present, with a fallback to the bot message check, and refines logging in _is_message_from_bot.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
omnibot/services/slack/reaction.py Adds extraction of the item_user field and a corresponding property to expose it.
omnibot/processor.py Updates reaction handler logic to prioritize item_user and refines log level handling.

@david-lyft david-lyft requested a review from colinsl June 2, 2025 18:25
@david-lyft david-lyft merged commit d007dc2 into master Jun 2, 2025
5 checks passed
@david-lyft david-lyft deleted the INTPROD-9643 branch June 2, 2025 18:31
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.

3 participants