P-051: action_id in allen Button-Dicts ergänzen (RC 6.x Rendering-Fix)
- button_builder.py: _make_action_id() Helper + action_id in Regular/Special Buttons
- __init__.py _build_custom_buttons: action_id via SHA1(msg_payload:idx)
- adapter.py _get_build_custom_buttons local fallback: action_id ergänzt
- adapter.py send_clarify: action_id=f'clarify_{clarify_id}_{i}' (deterministisch)
- adapter.py _send_archivar_buttons: action_id via SHA1(selector:i)
Rocket.Chat 6.x ignoriert das actions-Array komplett wenn kein action_id-Feld
vorhanden ist. Buttons erscheinen als plain-text statt klickbar.
This commit is contained in:
@@ -11,12 +11,23 @@ Regeln:
|
||||
- Jedes Attachment hat max 3 actions
|
||||
"""
|
||||
|
||||
import hashlib
|
||||
from typing import Any, List, Tuple
|
||||
|
||||
# Emoji-Nummern für bis zu 10 Buttons
|
||||
EMOJI_NUMBERS = ["1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣", "8️⃣", "9️⃣", "🔟"]
|
||||
|
||||
|
||||
def _make_action_id(msg_payload: str, index: int = 0) -> str:
|
||||
"""Deterministische action_id aus msg-Payload (SHA1, 12 Zeichen).
|
||||
|
||||
Rocket.Chat 6.x benötigt zwingend ein action_id-Feld im Button-Dict,
|
||||
sonst wird das gesamte actions-Array ignoriert (P-051).
|
||||
"""
|
||||
raw = f"{msg_payload}:{index}".encode()
|
||||
return hashlib.sha1(raw).hexdigest()[:12]
|
||||
|
||||
|
||||
def build_button_attachments(
|
||||
num_buttons: List[Tuple[Any, ...]],
|
||||
special_buttons: List[Tuple[Any, ...]],
|
||||
@@ -75,6 +86,7 @@ def build_button_attachments(
|
||||
"msg": msg_payload,
|
||||
"msg_in_chat_window": True,
|
||||
"style": button_style,
|
||||
"action_id": _make_action_id(msg_payload, i + j),
|
||||
})
|
||||
att = {
|
||||
"color": color,
|
||||
@@ -87,7 +99,7 @@ def build_button_attachments(
|
||||
# Sonderschaltflächen in separatem Attachment
|
||||
if special_buttons:
|
||||
special_actions = []
|
||||
for tup in special_buttons:
|
||||
for s_idx, tup in enumerate(special_buttons):
|
||||
label = tup[0]
|
||||
prefix = tup[1]
|
||||
style = tup[2]
|
||||
@@ -99,6 +111,7 @@ def build_button_attachments(
|
||||
"msg": msg_payload,
|
||||
"msg_in_chat_window": True,
|
||||
"style": style,
|
||||
"action_id": _make_action_id(msg_payload, s_idx),
|
||||
})
|
||||
attachments.append({
|
||||
"color": color,
|
||||
|
||||
Reference in New Issue
Block a user