Files
matrix-ai-agent/pipelines/approval.py
Christian Gick 69ac33eb0a fix: strip emoji variation selectors in approval reaction matching
Element appends U+FE0F to emoji reactions (👍️ vs 👍). Strip before
matching against approval map.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-18 18:30:36 +02:00

21 lines
734 B
Python

"""Approval handling — maps Matrix reactions to pipeline approvals."""
import logging
logger = logging.getLogger(__name__)
# Reaction emoji to response mapping
APPROVAL_REACTIONS = {
"\U0001f44d": "approve", # thumbs up
"\U0001f44e": "decline", # thumbs down
"\u2705": "approve", # check mark
"\u274c": "decline", # cross mark
}
def reaction_to_response(reaction_key: str) -> str | None:
"""Map a reaction emoji to an approval response."""
# Strip variation selectors (U+FE0E, U+FE0F) — Element often appends these
cleaned = reaction_key.replace("\ufe0f", "").replace("\ufe0e", "")
return APPROVAL_REACTIONS.get(cleaned) or APPROVAL_REACTIONS.get(reaction_key)