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:
@ -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
|
||||
|
Reference in New Issue
Block a user