File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 ( ) ,
You can’t perform that action at this time.
0 commit comments