Skip to content

Commit a38707d

Browse files
wpfleger96Hayt
andauthored
fix(relay): close community ban gaps across audio, agents and HTTP (#8005)
🤖 Community bans had gaps. Audio sockets never checked them: the audio join path didn't look up ban state, and a ban closed only the member's root sockets, so a banned member could join a huddle or stay in one. An agent's access comes from its owner, but the ban and timeout checks only looked at the pubkey that signed the event. Several write paths returned before those checks ran, admission could miss a ban that landed mid-AUTH, and removing or losing a member left live sockets open. This PR closes those gaps. ## Audio - `handlers/auth.rs`: the root socket's ban lookup, including the NIP-OA owner cascade and fail-closed DB handling, is `community_ban_outcome`. Root auth and audio join both call it, so the two checks can't drift apart. - `audio/handler.rs`: audio join runs the ban check after the write-free channel membership check and before any huddle lease or durable write. A ban is refused with `AuthorizationDenied` and a DB error with `AuthorizationUnavailable`. With no FI assertion, the refusal is the root route's text (`blocked: you are banned from this community` / `error: internal error checking restriction state`). - `state.rs`: `CommunityConnectionControl` holds the authenticated pubkey. `CommunityConnectionRegistry::disconnect_pubkey` closes bound audio sockets for one pubkey in one community with a 1008 `access revoked` close. `AppState::disconnect_pubkey_local` closes everything a pubkey has open in a community on this pod (root and audio); the clusterwide disconnect and the conn-control Redis subscriber in `main.rs` both use it, so remote pods close audio sockets too. Root sockets are still closed through `ConnectionManager`, so nothing is closed twice. A socket that proved a NIP-FI identity instead gets the standard NIP-FI denial (the restricted frame, then 1008 `authorization denied`), and a ban never overwrites a close reason already chosen. ## Behavior - **Owner restrictions carry to agents.** `restriction_state` folds in the restriction row of the agent's owner (`users.agent_owner_pubkey`) at read time. Nothing is copied onto the agent, so unbanning or un-timing-out the owner restores the agent immediately. Every hot-path caller (AUTH, ingest, audio, HTTP) picks this up. - **Admission is fenced against a concurrent ban.** Root AUTH and audio admission bind the proven pubkey to the socket first, then make the final ban and relay-membership decision (`handlers::auth::final_admission_denial`), then refuse if a disconnect already cancelled the socket. A ban or removal whose disconnect ran before the bind is visible to those fresh reads; one that runs after it finds and closes the bound socket. Both reads come from the writer, never the bounded-stale replica, so a removal that committed before the bind cannot be undone by a lagging replica. Both fail closed, and the check covers a delegated agent's owner. Each admitted socket records the agent's owner, from the NIP-OA tag or the stored link. - **Agents are always linked to their owner before admission.** Root AUTH and audio both record `users.agent_owner_pubkey` for a NIP-OA agent before admitting it, and refuse admission (`error: internal error recording agent owner`) if that write fails, because revoking the owner finds the agent's sockets through that link. - **Revoking live access covers agents without a database read.** `AppState::revoke_live_access` sends one clusterwide disconnect that closes, on every pod, each root and audio socket in the community whose principal **or recorded owner** is the target. An agent socket admitted before its owner link existed carries no recorded owner, so recording an owner for the first time (`materialize_nip_oa_owner`, the single writer used by root AUTH, audio admission and HTTP NIP-OA) closes that agent's ownerless root and audio sockets clusterwide; they reconnect with the owner attached. That disconnect skips owner-bound sockets. Admission with a NIP-OA owner records it on the socket before binding the pubkey, so the socket survives its own link; admission without one binds the pubkey first and then reads the stored owner, so a concurrent link either closes the socket or is seen by the read. A `users.agent_owner_pubkey` sweep still runs as a secondary path; if its lookup fails, the error is returned and there is no retry task. The kind-9040 ban, the report-action ban (left non-terminal so recovery re-runs it), relay-admin removal (9031), and NIP-43 self-leave all use it and report an incomplete revoke instead of claiming success. Each revokes right after its change commits; the ban no longer waits on its audit insert, whose error is still returned. - **NIP-43 self-leave works over WebSocket.** Kind 28936 is in the ephemeral range, so `handle_event` used to fan it out and answer `OK true` without removing membership. It is now routed to ingest; no other ephemeral kind changes. - **The write gate runs before every kind-specific branch.** `enforce_write_restriction` runs ahead of command routing (DM open, DM add member, DM hide, workflow definitions and triggers, approvals), product feedback, reports, and moderation or relay-admin commands. Ephemeral events and agent observer frames return before ingest in `handle_event`, so they go through the same gate there. - A ban exempts nothing. - A timeout admits only reports (kind 1984), unban (9041) and untimeout (9043). A timed-out admin cannot send relay-admin commands (9030–9033) until the timeout ends. - **HTTP refuses banned principals.** `enforce_relay_membership` runs a ban check after the membership decision, including on open relays: 403 `blocked: you are banned from this community` for a ban, 503 for a failed lookup. Media upload, media GET/HEAD and Git transport keep that 503 instead of reporting it as "not a relay member": in NIP-FI Enforce mode they send the canonical `AuthorizationUnavailable` response (`text/plain; charset=utf-8`, `authorization unavailable\n`), and in Off mode each keeps its legacy unavailable response. Media storage failures are not reclassified. Git transport checks membership and then runs its own ban check once per request. The NIP-OA owner is resolved from `x-auth-tag` when present. HTTP checks **bans only**: a timeout blocks writes, HTTP writes already reach the ingest gate, and reading stays allowed under a timeout. Unchanged by design: a lost Redis fan-out can leave another pod's socket open until it reconnects, and there is no recurring ban recheck on open sockets. ## Path table | Path | Category | Ban check | |---|---|---| | Root WebSocket AUTH and audio admission, including NIP-OA owner binding | community admission | final fenced check after bind; owner link required | | `POST /events`, `/query`, `/count` (`bridge.rs`) | community HTTP | existing `enforce_relay_membership` caller | | GIF search and `POST /gifs/share` (`gifs.rs`), media upload and fetch (`media.rs`), workflows (`workflows.rs`) | community HTTP | existing caller; media keeps 503 on lookup failure | | Git transport (`git/transport.rs`), git settings (`git/settings.rs`) | community HTTP | existing caller; transport keeps 503 on lookup failure | | `GET /moderation/reports`, `/moderation/audit`, `/moderation/restricted` | community HTTP | **newly covered** | | `POST /api/invites` (invite mint) | community HTTP | **newly covered** | | NIP-43 self-leave (WebSocket and `POST /events`, both via ingest) | roster change | revokes live access like admin removal | | Invite claim, accept-policy, `/api/join-policy*` | pre-membership invite and policy flows | none; ban state is checked when the caller authenticates | | `/`, `/info`, `/.well-known/nostr.json`, `/health`, `/_liveness`, `/_readiness` | public metadata and health | none | | `/hooks/{id}` | secret-authenticated webhooks | none; no community pubkey | | `/operator/*`, `/api/admin/v1`, `/internal/git/policy` | operator, admin and internal routes | none; separate auth plane | | `/_mesh/demo/echo` | demo only (mesh plus `mesh_demo_echo`) | none | ## Known limits - Cross-pod closure depends on the Redis fan-out; the tests prove the pod-local close by principal and recorded owner. - Live delivery to existing subscriptions depends on the disconnect. Events are not rechecked one by one. --------- Signed-off-by: Will Pfleger <[email protected]> Co-authored-by: Hayt <211b96e6a2b7f45fd4047988976c7bbbeeda0c15f3ae7b32eec20834b5a55118@buzz.block.builderlab.xyz>
1 parent 9b08395 commit a38707d

24 files changed

Lines changed: 3673 additions & 337 deletions

‎Justfile‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,6 @@ test-unit:
518518
+ test(=handlers::auth::tests::fi_invalid_nip42_proof_emits_terminal_evidence_rejected)
519519
+ test(=handlers::auth::tests::handle_auth_pairing_mismatch_runs_full_root_denial_path)
520520
+ test(=handlers::auth::tests::nip42_denial_class_separates_internal_failure_from_bad_evidence)
521-
+ test(=handlers::event::tests::p1b_agent_observer_event_barrier_expiry_blocks_fanout_and_ack)
522521
+ test(=handlers::event::tests::fanout_access::owner_only_kinds_keep_only_the_owner)
523522
+ test(=handlers::event::tests::pubsub_fanout::pubsub_owner_only_kinds_reach_only_the_owner)
524523
+ test(=handlers::event::tests::pubsub_fanout::dispatch_owner_only_kinds_reach_only_the_owner)

‎crates/buzz-db/src/store/moderation.rs‎

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,12 @@ pub struct RestrictionState {
564564
pub muted_until: Option<DateTime<Utc>>,
565565
}
566566

567-
/// Fetch the current restriction state for a pubkey in one community.
568-
/// Missing row ⇒ `RestrictionState::default()` (unrestricted).
567+
/// Fetch the effective restriction state for a pubkey in one community.
568+
///
569+
/// An agent is restricted by its own row and by its owner's row
570+
/// (`users.agent_owner_pubkey`), read now rather than copied onto the agent,
571+
/// so lifting the owner's restriction restores the agent with no extra step.
572+
/// No rows ⇒ `RestrictionState::default()` (unrestricted).
569573
pub async fn restriction_state(
570574
pool: &PgPool,
571575
community: CommunityId,
@@ -579,24 +583,28 @@ pub async fn restriction_state(
579583
let row = sqlx::query(
580584
r#"
581585
SELECT
582-
(banned AND (ban_expires_at IS NULL OR ban_expires_at > now())) AS banned,
583-
CASE WHEN muted_until > now() THEN muted_until ELSE NULL END AS muted_until
586+
COALESCE(bool_or(banned AND (ban_expires_at IS NULL OR ban_expires_at > now())), false)
587+
AS banned,
588+
max(CASE WHEN muted_until > now() THEN muted_until END) AS muted_until
584589
FROM community_bans
585-
WHERE community_id = $1 AND pubkey = $2
590+
WHERE community_id = $1
591+
AND pubkey IN (
592+
SELECT $2::bytea
593+
UNION ALL
594+
SELECT agent_owner_pubkey FROM users
595+
WHERE community_id = $1 AND pubkey = $2 AND agent_owner_pubkey IS NOT NULL
596+
)
586597
"#,
587598
)
588599
.bind(community.as_uuid())
589600
.bind(pubkey)
590-
.fetch_optional(&mut *connection)
601+
.fetch_one(&mut *connection)
591602
.await?;
592603

593-
match row {
594-
Some(row) => Ok(RestrictionState {
595-
banned: row.try_get("banned")?,
596-
muted_until: row.try_get("muted_until")?,
597-
}),
598-
None => Ok(RestrictionState::default()),
599-
}
604+
Ok(RestrictionState {
605+
banned: row.try_get("banned")?,
606+
muted_until: row.try_get("muted_until")?,
607+
})
600608
}
601609

602610
/// Fetch the full ban/timeout row (moderation queue / audit views).
@@ -949,7 +957,8 @@ impl Db {
949957
untimeout_member(&self.pool, community, pubkey, actor).await
950958
}
951959

952-
/// Fetch the active ban/timeout restriction state for enforcement hot paths.
960+
/// Fetch the effective (own or agent-owner) ban/timeout restriction state
961+
/// for enforcement hot paths.
953962
#[datastore_span(name = "moderation_restriction_state", system = "postgresql")]
954963
pub async fn moderation_restriction_state(
955964
&self,

‎crates/buzz-db/src/store/relay_members.rs‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,18 @@ impl Db {
887887
}
888888
}
889889

890+
/// Writer-authoritative [`Db::is_relay_member`]: never replica-routed.
891+
/// For admission fences that run after a removal's disconnect may already
892+
/// have passed, where a stale replica answer would grant lasting access.
893+
#[datastore_span(name = "is_relay_member_writer", system = "postgresql")]
894+
pub async fn is_relay_member_writer(
895+
&self,
896+
community: CommunityId,
897+
pubkey: &str,
898+
) -> Result<bool> {
899+
is_relay_member(&self.pool, community, pubkey).await
900+
}
901+
890902
/// Returns the relay member record for `pubkey` in `community`, or `None` if not found.
891903
#[datastore_span(name = "get_relay_member", system = "postgresql")]
892904
pub async fn get_relay_member(

‎crates/buzz-db/src/store/user.rs‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,21 @@ pub async fn get_agent_channel_policy(
389389
.transpose()
390390
}
391391

392+
/// List the agents whose `agent_owner_pubkey` is `owner_pubkey` in one community.
393+
pub async fn list_agents_for_owner(
394+
pool: &PgPool,
395+
community_id: CommunityId,
396+
owner_pubkey: &[u8],
397+
) -> Result<Vec<Vec<u8>>> {
398+
Ok(sqlx::query_scalar::<_, Vec<u8>>(
399+
"SELECT pubkey FROM users WHERE community_id = $1 AND agent_owner_pubkey = $2",
400+
)
401+
.bind(community_id.as_uuid())
402+
.bind(owner_pubkey)
403+
.fetch_all(pool)
404+
.await?)
405+
}
406+
392407
/// Check whether `actor_pubkey` is the `agent_owner_pubkey` of `target_pubkey`.
393408
/// Queries `agent_owner_pubkey` directly rather than going through
394409
/// `get_agent_channel_policy`, which would fetch unrelated fields.
@@ -568,6 +583,16 @@ impl Db {
568583
crate::user::get_agent_channel_policy(&self.pool, community_id, pubkey).await
569584
}
570585

586+
/// List the agents owned by `owner_pubkey` in one community.
587+
#[datastore_span(name = "list_agents_for_owner", system = "postgresql")]
588+
pub async fn list_agents_for_owner(
589+
&self,
590+
community_id: CommunityId,
591+
owner_pubkey: &[u8],
592+
) -> Result<Vec<Vec<u8>>> {
593+
crate::user::list_agents_for_owner(&self.pool, community_id, owner_pubkey).await
594+
}
595+
571596
/// Check whether `actor_pubkey` is the agent owner of `target_pubkey`.
572597
#[datastore_span(name = "is_agent_owner", system = "postgresql")]
573598
pub async fn is_agent_owner(

‎crates/buzz-media/src/error.rs‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ pub enum BlossomDenialKind {
2020
/// or similar authorization refusal that is not an auth-credential failure.
2121
/// Maps to HTTP 403 with fixed `authorization denied\n` body [NIP-FI.md:764-775].
2222
AuthorizationDenied,
23+
/// The relay could not evaluate its access policy (membership or
24+
/// restriction lookup failed). Maps to HTTP 503 with fixed
25+
/// `authorization unavailable\n` body [NIP-FI.md:769-789].
26+
AuthorizationUnavailable,
2327
}
2428

2529
/// Errors from media operations.
@@ -80,6 +84,10 @@ pub enum MediaError {
8084
CommunityWriteFenced,
8185
#[error("media service temporarily unavailable")]
8286
ServiceUnavailable,
87+
/// An access-policy lookup failed. Legacy responses match
88+
/// [`MediaError::ServiceUnavailable`]; Strict mode uses the NIP-FI body.
89+
#[error("media service temporarily unavailable")]
90+
AuthorizationUnavailable,
8391
#[error("token revoked")]
8492
TokenRevoked,
8593
#[error("pubkey mismatch")]
@@ -166,6 +174,7 @@ impl MediaError {
166174
Self::RelayMembershipRequired | Self::CommunityWriteFenced => {
167175
Some(BlossomDenialKind::AuthorizationDenied)
168176
}
177+
Self::AuthorizationUnavailable => Some(BlossomDenialKind::AuthorizationUnavailable),
169178
_ => None,
170179
}
171180
}
@@ -216,7 +225,9 @@ impl IntoResponse for MediaError {
216225
Self::RelayMembershipRequired | Self::CommunityWriteFenced => {
217226
(StatusCode::FORBIDDEN, self.to_string())
218227
}
219-
Self::ServiceUnavailable => (StatusCode::SERVICE_UNAVAILABLE, self.to_string()),
228+
Self::ServiceUnavailable | Self::AuthorizationUnavailable => {
229+
(StatusCode::SERVICE_UNAVAILABLE, self.to_string())
230+
}
220231
Self::UploadRateLimitExceeded | Self::UploadConcurrencyLimitReached => {
221232
(StatusCode::TOO_MANY_REQUESTS, self.to_string())
222233
}

‎crates/buzz-pubsub/src/conn_control.rs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ pub enum ConnControl {
116116
event_id: String,
117117
/// Human-readable close reason for the `OK` frame.
118118
reason: String,
119+
/// Close only sockets admitted with no recorded owner. Sent when an
120+
/// agent's owner is first recorded, so its ownerless sockets reconnect
121+
/// with the owner attached while owner-bound sockets stay up.
122+
#[serde(default)]
123+
unowned_only: bool,
119124
},
120125
}
121126

@@ -341,6 +346,7 @@ mod tests {
341346
pubkey: vec![7u8; 32],
342347
event_id: "abc123".to_string(),
343348
reason: "blocked: you are banned from this community".to_string(),
349+
unowned_only: true,
344350
};
345351
let json = serde_json::to_string(&cmd).unwrap();
346352
assert_eq!(serde_json::from_str::<ConnControl>(&json).unwrap(), cmd);

‎crates/buzz-relay/src/api/bridge.rs‎

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2711,6 +2711,17 @@ async fn authorize_moderation_read(
27112711
.map_err(|e| e.into_response())?;
27122712
let pubkey_bytes = pubkey.to_bytes().to_vec();
27132713

2714+
// Membership and community ban, same step as the other NIP-98 routes.
2715+
super::relay_members::enforce_relay_membership(
2716+
state,
2717+
tenant.community(),
2718+
&pubkey_bytes,
2719+
super::relay_members::extract_auth_tag_header(headers),
2720+
None,
2721+
)
2722+
.await
2723+
.map_err(|e| e.into_response())?;
2724+
27142725
crate::handlers::moderation_authz::authorize_moderation_action(
27152726
&tenant,
27162727
state,
@@ -8079,4 +8090,183 @@ mod postgres_tests {
80798090
drop(conn);
80808091
fx.drop().await;
80818092
}
8093+
8094+
/// An agent socket admitted with no owner, then linked to its owner by a
8095+
/// later `POST /events` carrying NIP-OA, closes when the owner is banned
8096+
/// or removed even though the owner-to-agent lookup fails: recording the
8097+
/// owner made the ownerless sockets reconnect. The same agent's socket in
8098+
/// another community stays up.
8099+
/// Mutation: drop `disconnect_unowned_agent_clusterwide` from
8100+
/// `materialize_nip_oa_owner` → the agent's sockets stay open → RED.
8101+
#[tokio::test]
8102+
#[ignore = "requires Postgres"]
8103+
async fn late_owner_link_closes_ownerless_agent_sockets_on_owner_revoke() {
8104+
use crate::state::CommunityConnectionControl;
8105+
use sqlx::postgres::PgConnectOptions;
8106+
use tokio_util::sync::CancellationToken;
8107+
8108+
for action in ["ban", "removal"] {
8109+
let mut state = bridge_handler_test_state()
8110+
.await
8111+
.expect("local Postgres and Redis");
8112+
// A schema whose `users` table can be taken away after the link,
8113+
// so only the owner-to-agent lookup fails at revoke time.
8114+
let db_url = crate::test_support::database_url();
8115+
let schema = format!("late_owner_{}", uuid::Uuid::new_v4().simple());
8116+
sqlx::raw_sql(sqlx::AssertSqlSafe(format!(
8117+
"CREATE SCHEMA {schema}; \
8118+
CREATE TABLE {schema}.users (LIKE public.users INCLUDING ALL); \
8119+
CREATE TABLE {schema}.community_bans (LIKE public.community_bans INCLUDING ALL); \
8120+
CREATE TABLE {schema}.relay_members (LIKE public.relay_members INCLUDING ALL);"
8121+
)))
8122+
.execute(state.db.pool())
8123+
.await
8124+
.expect("create schema");
8125+
let admin = state.db.pool().clone();
8126+
let pool = sqlx::PgPool::connect_with(
8127+
db_url
8128+
.parse::<PgConnectOptions>()
8129+
.expect("database url")
8130+
.options([("search_path", schema.as_str())]),
8131+
)
8132+
.await
8133+
.expect("schema pool");
8134+
Arc::get_mut(&mut state).expect("unique state").db = buzz_db::Db::from_pool(pool);
8135+
8136+
let tenant = fresh_tenant("late-owner.test");
8137+
let other = fresh_tenant("late-owner-other.test");
8138+
let (owner, agent) = (Keys::generate(), Keys::generate());
8139+
let agent_bytes = agent.public_key().to_bytes();
8140+
8141+
// The agent's ownerless main and audio sockets, plus its socket in
8142+
// another community.
8143+
let root = CancellationToken::new();
8144+
let root_id = uuid::Uuid::new_v4();
8145+
let (tx, _rx) = tokio::sync::mpsc::channel(4);
8146+
let (ctrl, _ctrl_rx) = tokio::sync::mpsc::channel(4);
8147+
let (terminal, _terminal_rx) = tokio::sync::mpsc::channel(1);
8148+
state.conn_manager.register(
8149+
root_id,
8150+
tx,
8151+
ctrl,
8152+
terminal,
8153+
None,
8154+
root.clone(),
8155+
tenant.community(),
8156+
Arc::new(std::sync::atomic::AtomicU8::new(0)),
8157+
Arc::new(tokio::sync::Mutex::new(std::collections::HashMap::new())),
8158+
3,
8159+
crate::state::CommunityConnectionControl::new(root.clone()),
8160+
);
8161+
state
8162+
.conn_manager
8163+
.set_authenticated_pubkey(root_id, agent_bytes.to_vec());
8164+
let bound = |community| {
8165+
let control = CommunityConnectionControl::new(CancellationToken::new());
8166+
control.bind_pubkey(agent_bytes);
8167+
let guard = state.community_connections.register(
8168+
uuid::Uuid::new_v4(),
8169+
community,
8170+
control.clone(),
8171+
);
8172+
(control, guard)
8173+
};
8174+
let (audio, _g1) = bound(tenant.community());
8175+
let (elsewhere, _g2) = bound(other.community());
8176+
8177+
// The real HTTP submit path records the owner from `x-auth-tag`.
8178+
let auth_tag = buzz_sdk::nip_oa::compute_auth_tag(&owner, &agent.public_key(), "")
8179+
.expect("sign NIP-OA credential");
8180+
let mut headers = HeaderMap::new();
8181+
headers.insert("x-auth-tag", auth_tag.parse().expect("header value"));
8182+
let event = EventBuilder::new(Kind::TextNote, "linked")
8183+
.sign_with_keys(&agent)
8184+
.expect("sign event");
8185+
let _ = submit_event_authed(
8186+
&state,
8187+
&tenant,
8188+
&headers,
8189+
serde_json::to_vec(&event).expect("event json").as_slice(),
8190+
agent.public_key(),
8191+
fresh_nip98_event_id_bytes(),
8192+
Some(nostr::Timestamp::now().as_secs()),
8193+
)
8194+
.await;
8195+
assert!(
8196+
state
8197+
.db
8198+
.is_agent_owner(
8199+
tenant.community(),
8200+
agent.public_key().as_bytes(),
8201+
owner.public_key().as_bytes(),
8202+
)
8203+
.await
8204+
.expect("owner lookup"),
8205+
"{action}: the HTTP request recorded the owner"
8206+
);
8207+
8208+
sqlx::raw_sql(sqlx::AssertSqlSafe(format!(
8209+
"ALTER TABLE {schema}.users RENAME TO users_unavailable"
8210+
)))
8211+
.execute(&admin)
8212+
.await
8213+
.expect("break the owner-to-agent lookup");
8214+
let owner_hex = owner.public_key().to_hex();
8215+
match action {
8216+
"ban" => state
8217+
.db
8218+
.ban_community_member(
8219+
tenant.community(),
8220+
owner.public_key().as_bytes(),
8221+
&[9u8; 32],
8222+
None,
8223+
None,
8224+
)
8225+
.await
8226+
.map(|_| ())
8227+
.expect("ban commits"),
8228+
_ => {
8229+
buzz_db::relay_members::add_relay_member(
8230+
state.db.pool(),
8231+
tenant.community(),
8232+
&owner_hex,
8233+
"member",
8234+
None,
8235+
)
8236+
.await
8237+
.expect("seed member");
8238+
state
8239+
.db
8240+
.remove_relay_member(tenant.community(), &owner_hex)
8241+
.await
8242+
.map(|_| ())
8243+
.expect("removal commits");
8244+
}
8245+
}
8246+
let revoked = state
8247+
.revoke_live_access(
8248+
&tenant,
8249+
owner.public_key().as_bytes(),
8250+
"owner-revoke",
8251+
"blocked: you are banned from this community",
8252+
)
8253+
.await;
8254+
assert!(revoked.is_err(), "{action}: the failed lookup is reported");
8255+
assert!(
8256+
root.is_cancelled(),
8257+
"{action}: the agent's main socket closes"
8258+
);
8259+
assert!(
8260+
audio.cancellation_token().is_cancelled(),
8261+
"{action}: the agent's audio socket closes"
8262+
);
8263+
assert!(
8264+
!elsewhere.cancellation_token().is_cancelled(),
8265+
"{action}: the agent's socket in another community stays"
8266+
);
8267+
let _ = sqlx::raw_sql(sqlx::AssertSqlSafe(format!("DROP SCHEMA {schema} CASCADE")))
8268+
.execute(&admin)
8269+
.await;
8270+
}
8271+
}
80828272
}

0 commit comments

Comments
 (0)