Events: Distribute user updates to servers.

Fix: Deleting a server now correctly deletes all associated objects.
This commit is contained in:
Paul
2021-07-28 13:40:03 +01:00
parent 7d3ce0c96a
commit 8f6e5be1d4
13 changed files with 142 additions and 201 deletions

View File

@@ -229,11 +229,11 @@ impl User {
}
/// Utility function to get all the server IDs the user is in.
pub async fn fetch_server_ids(&self) -> Result<Vec<String>> {
pub async fn fetch_server_ids(id: &str) -> Result<Vec<String>> {
Ok(get_collection("server_members")
.find(
doc! {
"_id.user": &self.id
"_id.user": id
},
None,
)
@@ -256,11 +256,11 @@ impl User {
}
/// Utility function to fetch unread objects for user.
pub async fn fetch_unreads(&self) -> Result<Vec<Document>> {
pub async fn fetch_unreads(id: &str) -> Result<Vec<Document>> {
Ok(get_collection("channel_unreads")
.find(
doc! {
"_id.user": &self.id
"_id.user": id
},
None,
)