mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-27 17:58:07 +00:00
fix: scope kanban auto-subscriptions to active profile
This commit is contained in:
parent
f34a69b1cd
commit
67826e3068
2 changed files with 31 additions and 0 deletions
|
|
@ -2416,6 +2416,7 @@ def _sub_index(subs):
|
|||
"thread_id": getattr(s, "thread_id", None),
|
||||
"user_id": getattr(s, "user_id", None),
|
||||
"delivery_metadata": getattr(s, "delivery_metadata", None),
|
||||
"notifier_profile": getattr(s, "notifier_profile", None),
|
||||
})
|
||||
return out
|
||||
|
||||
|
|
@ -2457,6 +2458,30 @@ def test_create_subscribes_gateway_session(monkeypatch, worker_env):
|
|||
}
|
||||
|
||||
|
||||
def test_create_subscribes_gateway_session_with_active_profile_when_env_missing(monkeypatch, worker_env):
|
||||
"""Gateway auto-subscribe rows must be owned by the active profile even
|
||||
when session/env profile markers are missing. Otherwise every Telegram
|
||||
gateway with the same chat_id can deliver another bot's Kanban event."""
|
||||
from tools import kanban_tools as kt
|
||||
monkeypatch.setenv("HERMES_SESSION_PLATFORM", "telegram")
|
||||
monkeypatch.setenv("HERMES_SESSION_CHAT_ID", "chat-42")
|
||||
monkeypatch.delenv("HERMES_SESSION_PROFILE", raising=False)
|
||||
monkeypatch.delenv("HERMES_PROFILE", raising=False)
|
||||
monkeypatch.setattr("hermes_cli.profiles.get_active_profile_name", lambda: "spanorama")
|
||||
|
||||
out = kt._handle_create({
|
||||
"title": "auto-sub active profile",
|
||||
"assignee": "peer",
|
||||
})
|
||||
d = json.loads(out)
|
||||
assert d["ok"] is True
|
||||
assert d["subscribed"] is True, d
|
||||
|
||||
subs = _sub_index(_list_subs_for_task(d["task_id"]))
|
||||
assert len(subs) == 1
|
||||
assert subs[0]["notifier_profile"] == "spanorama"
|
||||
|
||||
|
||||
def test_create_subscribes_tui_session_via_session_key(monkeypatch, worker_env):
|
||||
"""TUI / desktop sessions don't have a platform/chat_id (single
|
||||
local channel), but the parent process exports HERMES_SESSION_KEY.
|
||||
|
|
|
|||
|
|
@ -1339,6 +1339,12 @@ def _maybe_auto_subscribe(conn: Any, task_id: str) -> bool:
|
|||
get_session_env("HERMES_SESSION_PROFILE", "")
|
||||
or os.environ.get("HERMES_PROFILE")
|
||||
)
|
||||
if not notifier_profile:
|
||||
try:
|
||||
from hermes_cli.profiles import get_active_profile_name
|
||||
notifier_profile = get_active_profile_name() or "default"
|
||||
except Exception:
|
||||
notifier_profile = "default"
|
||||
delivery_metadata: dict[str, Any] = {}
|
||||
if thread_id:
|
||||
delivery_metadata["thread_id"] = thread_id
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue