Skip to content

Commit 5ababc1

Browse files
author
Elrond
committed
fix(admin): adapt archive commands to current main
Signed-off-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
1 parent 2b4a7b2 commit 5ababc1

3 files changed

Lines changed: 23 additions & 15 deletions

File tree

‎crates/buzz-admin/src/communities.rs‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,18 @@ async fn unarchive(
132132
.to_string();
133133

134134
let db = crate::connect_db().await?;
135-
let record = db
135+
let record = match db
136136
.unarchive_community_owned_by(&host, &owner_pubkey)
137137
.await?
138-
.ok_or_else(|| {
139-
anyhow::anyhow!(
140-
"no active-deletion-state community matched both the hostname and current owner pubkey"
141-
)
142-
})?;
138+
{
139+
buzz_db::UnarchiveCommunityResult::Unarchived(record) => record,
140+
buzz_db::UnarchiveCommunityResult::DeletionPending => {
141+
anyhow::bail!("community deletion is pending; unarchive is refused")
142+
}
143+
buzz_db::UnarchiveCommunityResult::NotFound => anyhow::bail!(
144+
"no active-deletion-state community matched both the hostname and current owner pubkey"
145+
),
146+
};
143147
print_json(&unarchive_evidence(&record, &operator_id, &reason))?;
144148
Ok(0)
145149
}

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,10 +1135,12 @@ mod postgres_tests {
11351135
.expect("matching archive fence"),
11361136
Some("applied")
11371137
);
1138-
db.unarchive_community_owned_by(&host, &owner)
1139-
.await
1140-
.expect("unarchive community")
1141-
.expect("owned community");
1138+
assert!(matches!(
1139+
db.unarchive_community_owned_by(&host, &owner)
1140+
.await
1141+
.expect("unarchive community"),
1142+
UnarchiveCommunityResult::Unarchived(_)
1143+
));
11421144
assert_eq!(
11431145
db.with_community_archive_fence(created.id, first_archive.archived_at, || "stale")
11441146
.await
@@ -1239,11 +1241,12 @@ mod postgres_tests {
12391241
.expect("inactive community fence"),
12401242
Some("disconnected")
12411243
);
1242-
assert!(db
1243-
.unarchive_community_owned_by(&host, &owner)
1244-
.await
1245-
.expect("unarchive community")
1246-
.is_some());
1244+
assert!(matches!(
1245+
db.unarchive_community_owned_by(&host, &owner)
1246+
.await
1247+
.expect("unarchive community"),
1248+
UnarchiveCommunityResult::Unarchived(_)
1249+
));
12471250
assert!(db
12481251
.is_community_active(created.id)
12491252
.await

‎crates/buzz-relay/src/connection.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2484,6 +2484,7 @@ pub(crate) mod tests {
24842484
sink,
24852485
data_rx,
24862486
ctrl_rx,
2487+
mpsc::channel(1).1,
24872488
restart_rx,
24882489
cancel,
24892490
archived_community_disconnect_reason(),

0 commit comments

Comments
 (0)