fix: don't allow members to be added more than once

fixes #182
This commit is contained in:
Paul Makles
2022-06-14 17:27:15 +01:00
parent 11d89b3bf0
commit 4c4eb60cdb

View File

@@ -242,7 +242,12 @@ impl Channel {
/// Add user to a group
pub async fn add_user_to_group(&mut self, db: &Database, user: &str, by: &str) -> Result<()> {
if let Channel::Group { recipients, .. } = self {
recipients.push(user.to_string());
let user = user.to_string();
if recipients.contains(&user) {
return Err(Error::AlreadyInGroup);
}
recipients.push(user);
}
match &self {