mirror of
https://github.com/stoatchat/stoatchat.git
synced 2026-07-14 13:36:59 +00:00
Fix embeds not re-generating properly on edit.
Include own memberships in Ready payload.
This commit is contained in:
@@ -228,6 +228,30 @@ impl User {
|
||||
Ok(users)
|
||||
}
|
||||
|
||||
/// Utility function to get all of a user's memberships.
|
||||
pub async fn fetch_memberships(id: &str) -> Result<Vec<Member>> {
|
||||
Ok(get_collection("server_members")
|
||||
.find(
|
||||
doc! {
|
||||
"_id.user": id
|
||||
},
|
||||
None,
|
||||
)
|
||||
.await
|
||||
.map_err(|_| Error::DatabaseError {
|
||||
operation: "find",
|
||||
with: "server_members",
|
||||
})?
|
||||
.filter_map(async move |s| s.ok())
|
||||
.collect::<Vec<Document>>()
|
||||
.await
|
||||
.into_iter()
|
||||
.filter_map(|x| {
|
||||
from_document(x).ok()
|
||||
})
|
||||
.collect::<Vec<Member>>())
|
||||
}
|
||||
|
||||
/// Utility function to get all the server IDs the user is in.
|
||||
pub async fn fetch_server_ids(id: &str) -> Result<Vec<String>> {
|
||||
Ok(get_collection("server_members")
|
||||
|
||||
Reference in New Issue
Block a user