From a0919b7c286259b7d0f4f7f49a8465d863423786 Mon Sep 17 00:00:00 2001 From: John Tennant Date: Mon, 31 Aug 2026 22:13:12 -0400 Subject: [PATCH] fix(projects): reject archived home authority Signed-off-by: John Tennant --- crates/buzz-db/src/store/project_revision.rs | 30 ++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/crates/buzz-db/src/store/project_revision.rs b/crates/buzz-db/src/store/project_revision.rs index b49372c079..fc9749ae78 100644 --- a/crates/buzz-db/src/store/project_revision.rs +++ b/crates/buzz-db/src/store/project_revision.rs @@ -170,7 +170,8 @@ impl Db { "SELECT cm.role::text FROM channel_members cm \ JOIN channels c ON c.community_id=cm.community_id AND c.id=cm.channel_id \ WHERE cm.community_id=$1 AND cm.channel_id=$2 AND cm.pubkey=$3 \ - AND cm.removed_at IS NULL AND c.deleted_at IS NULL", + AND cm.removed_at IS NULL AND c.deleted_at IS NULL \ + AND c.archived_at IS NULL", ) .bind(community_id.as_uuid()) .bind(home_channel_id) @@ -575,12 +576,37 @@ mod tests { .1 ); - sqlx::query("UPDATE channels SET deleted_at=NOW() WHERE community_id=$1 AND id=$2") + sqlx::query("UPDATE channels SET archived_at=NOW() WHERE community_id=$1 AND id=$2") .bind(community.as_uuid()) .bind(home) .execute(&pool) .await .unwrap(); + let after_archive = revision_event( + &admin, + &coordinate, + &recreated.id.to_hex(), + ProjectRevisionOperation::AddRelatedChannel, + related_b, + ); + let parsed = ProjectRevision::parse(&after_archive).unwrap(); + assert_eq!( + db.apply_project_revision(community, &after_archive, &parsed) + .await + .unwrap() + .status, + ProjectRevisionApplyStatus::Forbidden + ); + + sqlx::query( + "UPDATE channels SET archived_at=NULL, deleted_at=NOW() \ + WHERE community_id=$1 AND id=$2", + ) + .bind(community.as_uuid()) + .bind(home) + .execute(&pool) + .await + .unwrap(); let after_delete = revision_event( &admin, &coordinate,