feat(archivar): Route-Antwort in Zielraum + Notiz im Ursprungsraum
This commit is contained in:
@@ -572,6 +572,7 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
# ── Archivar-Klassifikation ──────────────────────────────────
|
||||
# Klassifiziere die Nachricht und reichere den Context an
|
||||
category = ""
|
||||
decision = None
|
||||
try:
|
||||
decision = await self.archivar.handle_and_forward(text, origin_room_id=room_id, message_id=msg_id)
|
||||
if decision and decision.category:
|
||||
@@ -579,6 +580,15 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
except Exception as e:
|
||||
logger.debug("[rocketchat] Archivar classification skipped: %s", e)
|
||||
|
||||
# Forward-Antwort-Umleitung
|
||||
if decision and hasattr(decision, 'target_room') and decision.target_room and decision.target_room != room_id:
|
||||
_CURRENT_ORIGIN_ROOM.set(decision.target_room)
|
||||
try:
|
||||
note_text = f"Ich antworte im {getattr(decision, 'matched_room_name', None) or 'Zielraum'}."
|
||||
await self.send(room_id, note_text)
|
||||
except Exception as e:
|
||||
logger.debug("[rocketchat] Failed to send forward note: %s", e)
|
||||
|
||||
# ── Virtual Room Translation ─────────────────────────────────
|
||||
# Replace room-based chat_id with user-based virtual chat_id.
|
||||
# This collapses all rooms per user into ONE Hermes session:
|
||||
@@ -587,6 +597,8 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
# Both get the same session key.
|
||||
virtual_chat_id = f"user:{username}"
|
||||
# Track the REAL room for send() to route the response back
|
||||
# Only set if no forwarding occurred
|
||||
if not (decision and hasattr(decision, 'target_room') and decision.target_room and decision.target_room != room_id):
|
||||
_CURRENT_ORIGIN_ROOM.set(room_id)
|
||||
|
||||
# Ensure this user→room mapping is recorded for proaktive sends
|
||||
|
||||
Reference in New Issue
Block a user