mirror of
https://github.com/stoatchat/stoatchat.git
synced 2026-07-14 05:26:59 +00:00
Channels: Make sure to delete last, to keep integrity.
This commit is contained in:
@@ -189,19 +189,6 @@ impl Channel {
|
||||
with: "messages",
|
||||
})?;
|
||||
|
||||
get_collection("channels")
|
||||
.delete_one(
|
||||
doc! {
|
||||
"_id": id
|
||||
},
|
||||
None,
|
||||
)
|
||||
.await
|
||||
.map_err(|_| Error::DatabaseError {
|
||||
operation: "delete_one",
|
||||
with: "channel",
|
||||
})?;
|
||||
|
||||
// Remove from server object.
|
||||
if let Channel::TextChannel { server, .. } = &self {
|
||||
let server = Ref::from_unchecked(server.clone()).fetch_server().await?;
|
||||
@@ -258,6 +245,20 @@ impl Channel {
|
||||
})?;
|
||||
}
|
||||
|
||||
// Finally, delete the channel object.
|
||||
get_collection("channels")
|
||||
.delete_one(
|
||||
doc! {
|
||||
"_id": id
|
||||
},
|
||||
None,
|
||||
)
|
||||
.await
|
||||
.map_err(|_| Error::DatabaseError {
|
||||
operation: "delete_one",
|
||||
with: "channel",
|
||||
})?;
|
||||
|
||||
ClientboundNotification::ChannelDelete { id: id.to_string() }.publish(id.to_string());
|
||||
|
||||
if let Channel::Group { icon, .. } = self {
|
||||
|
||||
Reference in New Issue
Block a user