1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-06-20 08:25:16 +00:00

Can add member to conversations

This commit is contained in:
2021-03-06 17:57:04 +01:00
parent cbb12a87e1
commit 72a9553f1a
4 changed files with 47 additions and 101 deletions

View File

@ -70,6 +70,11 @@ impl Conversation {
.any(|m| m.user_id == user_id && m.is_admin)
}
/// Check out whether a user can add members to a conversation or not
pub fn can_user_add_members(&self, user_id: &UserID) -> bool {
!self.is_managed() && (self.is_admin(user_id) || self.can_everyone_add_members)
}
/// Check out whether a user is the last administrator of a conversation or not
pub fn is_last_admin(&self, user_id: &UserID) -> bool {
let admins: Vec<&ConversationMember> = self.members
@ -79,6 +84,11 @@ impl Conversation {
admins.len() == 1 && admins[0].user_id == user_id
}
/// Get the membership of a user over a conversation
pub fn get_membership(&self, user_id: &UserID) -> Option<&ConversationMember> {
self.members.iter().filter(|u| u.user_id == user_id).next()
}
}
/// Structure used to update the list of members of the conversation