Skip to content

Commit

Permalink
Fixes issue with timeline event Slack-based reaction by using a liste…
Browse files Browse the repository at this point in the history
…rner matcher (Netflix#3121) (#101)

* Fixes issue with timeline event Slack-based reaction by using a listerner matcher

* Removes unnecessary print

Co-authored-by: Marc Vilanova <39573146+mvilanova@users.noreply.github.com>
  • Loading branch information
rutvijmehta-harness and mvilanova authored Mar 17, 2023
1 parent 4b3632e commit 641e584
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/dispatch/plugins/dispatch_slack/incident/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,15 @@
log = logging.getLogger(__file__)


def is_target_reaction(reaction: str) -> bool:
"""Returns True if given reaction matches the events' reaction."""

def is_target(event) -> bool:
return event["reaction"] == reaction

return is_target


def configure(config):
"""Maps commands/events to their functions."""
middleware = [
Expand Down Expand Up @@ -190,9 +199,9 @@ def configure(config):
handle_add_timeline_event_command
)

# required to allow the user to change the reaction string
app.event(
{"type": "reaction_added", "reaction": config.timeline_event_reaction},
event="reaction_added",
matchers=[is_target_reaction(config.timeline_event_reaction)],
middleware=[reaction_context_middleware],
)(handle_timeline_added_event)

Expand Down

0 comments on commit 641e584

Please sign in to comment.