Discord: log node-reported stream state; remove a radio channel or a server
- handle_actual logs every node-reported state TRANSITION (not heartbeats) with stream/node/guild/channel/token ids and the node's error text: info for connected/connecting/stopped, warning for error, and a dedicated "radio bot X failed to log in on node N: <reason>" line for login_failed. The node's reason code is now stored in actual.code and shown next to the error on Settings > Discord and the node page. - Remove a radio channel permanently: streams.delete_stream stops it through desired state first (node republished without it, token -> releasing per #216, freed on the node's ack), then deletes the doc in a transaction that refuses if the channel was restarted in between. DELETE /discord/streams/{id} (platform admin) and DELETE /discord/nodes/{node}/streams/{id} (admin or org owner, same org + node only; operators can still stop, not remove). Audited. - Remove a server: DELETE /discord/guilds/{id} (admin) deletes every radio channel in it the same way, then tombstones discord_guilds (org_id None + unlinked_at, #218 semantics, plus removed_at) so it never falls back to DISCORD_UNLINKED_GUILD_ORG_ID; the admin page hides it, and /drb link or the admin link brings it back. Optional leave_radio_bots makes pool bots and the server's org's own BYO bots leave via Discord REST; the DRB server bot stays until kicked, and the UI says so. Audited. - UI: Remove (with confirm) on Radio channels, Servers and the node page list. Refs #213, #221 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
fabdf5839e
commit
c92bdfe841
@@ -75,6 +75,9 @@ class _Txn:
|
||||
def update(self, ref: _DocRef, data: dict):
|
||||
self.writes.append(("update", ref.coll, ref.id, copy.deepcopy(data), True))
|
||||
|
||||
def delete(self, ref: _DocRef):
|
||||
self.writes.append(("delete", ref.coll, ref.id, {}, False))
|
||||
|
||||
|
||||
class FakeFirestore:
|
||||
def __init__(self):
|
||||
@@ -91,6 +94,10 @@ class FakeFirestore:
|
||||
|
||||
def _write(self, kind: str, coll: str, doc_id: str, data: dict, merge: bool):
|
||||
docs = self.data.setdefault(coll, {})
|
||||
if kind == "delete":
|
||||
docs.pop(doc_id, None)
|
||||
self.versions[(coll, doc_id)] = self.versions.get((coll, doc_id), 0) + 1
|
||||
return
|
||||
if kind == "update" and doc_id not in docs:
|
||||
raise KeyError(f"No document to update: {coll}/{doc_id}")
|
||||
if merge and doc_id in docs:
|
||||
|
||||
Reference in New Issue
Block a user