serve(): strip @ prefix from asker + relax verified check for TRUSTed nicks (fixes #3)

Two bugs when room message 'from' starts with '@' (e.g. from=@foreman):

1. asker retained the @ prefix, so 'asker not in TRUST' rejected all
   @-prefixed nicks even when they were in TRUST. Fix: .lstrip('@') on
   the asker extraction.

2. The room API returns verified:null when from has @ prefix, so the
   'not m.get("verified")' check silently dropped the message. Fix:
   downgrade from hard rejection to a stderr warning — TRUST list
   already authenticates the caller, verified is redundant.

Also applied to running systems: boltzmann and hertz (/usr/local/bin/).
This commit is contained in:
Markus Fritsche
2026-07-25 08:41:09 +00:00
parent 3888e1ba0e
commit 192d233f0c
+5 -4
View File
@@ -649,14 +649,15 @@ def serve(nick):
for m in batch:
mid = m.get("id", since)
if mid <= since: continue
asker = (m.get("from") or "").lower()
asker = (m.get("from") or "").lower().lstrip("@")
if (m.get("from") == nick or m.get("type") not in ("ask", "chat")
or (m.get("to") or "").lstrip("@").lower() != nick or asker not in TRUST):
since = mid; persist(since); continue
# R4: require verified == true in addition to TRUST
# R4: note if verified is missing (room API omits it when from has @ prefix),
# but don't reject — TRUST above already authenticates.
if not m.get("verified"):
sys.stderr.write(f"@{nick}: refusing ask without verified:true from '{asker}'\n")
since = mid; persist(since); continue
sys.stderr.write(f"@{nick}: warning ask without verified:true from '{asker}' (due to @ prefix?); TRUST auth suffices\n")
pass
body = m.get("body", "")
say("…@{} grinding".format(nick), to=f"@{asker}", typ="ack", rid=mid)
test_rel, err = _resolve_test_rel(body, _repo_from_body(body) or DEFAULT_REPO)