1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-26 07:19:22 +00:00

Ready to update the list of members of a conversation

This commit is contained in:
Pierre HUBERT 2020-06-15 09:29:38 +02:00
parent b15a09cf07
commit 16298d54fb
2 changed files with 18 additions and 0 deletions

View File

@ -75,5 +75,15 @@ pub fn update_settings(r: &mut HttpRequestHandler) -> RequestResult {
)?;
}
// Update members list
if r.has_post_parameter("members") {
let members = r.post_numbers_list("members", 1);
let can_everyone_add_members = conversations_helper::can_everyone_add_members(conv_id)?;
if !is_moderator && !can_everyone_add_members {
r.forbidden("You can not update the list of members of this conversation!".to_string())?;
}
}
r.success("Conversation information successfully updated!")
}

View File

@ -115,6 +115,14 @@ pub fn is_user_moderator(user_id: UserID, conv_id: u64) -> ResultBoxError<bool>
.exec_count()? > 0)
}
/// Check out whether all the members of a conversation can add members to it or not
pub fn can_everyone_add_members(conv_id: u64) -> ResultBoxError<bool> {
database::QueryInfo::new(CONV_LIST_TABLE)
.cond_u64("id", conv_id)
.add_field("can_everyone_add_members")
.query_row(|f|f.get_legacy_bool("can_everyone_add_members"))
}
/// Set whether a user is following a conversation or not
pub fn set_following(user_id: UserID, conv_id: u64, following: bool) -> ResultBoxError<()> {
database::UpdateInfo::new(CONV_USERS_TABLE)