diff --git a/src/controllers/conversations_controller.rs b/src/controllers/conversations_controller.rs index 847f273..930e735 100644 --- a/src/controllers/conversations_controller.rs +++ b/src/controllers/conversations_controller.rs @@ -116,6 +116,13 @@ pub fn update_settings(r: &mut HttpRequestHandler) -> RequestResult { conversations_helper::set_name(conv_id, name)?; } + + + // Change "canEveryoneAddMembers" parameter + if r.has_post_parameter("canEveryoneAddMembers") { + conversations_helper::set_can_everyone_add_members( + conv_id, r.post_bool("canEveryoneAddMembers")?)?; + } } r.success("Conversation information successfully updated!") diff --git a/src/helpers/conversations_helper.rs b/src/helpers/conversations_helper.rs index 446c158..ffcb1d1 100644 --- a/src/helpers/conversations_helper.rs +++ b/src/helpers/conversations_helper.rs @@ -2,14 +2,14 @@ //! //! @author Pierre Hubert -use crate::data::new_conversation::NewConversation; -use crate::data::error::{ResultBoxError, ExecError}; -use crate::helpers::database::{InsertQuery}; use crate::constants::database_tables_names::{CONV_LIST_TABLE, CONV_USERS_TABLE}; -use crate::utils::date_utils::time; -use crate::data::user::UserID; use crate::data::conversation::Conversation; +use crate::data::error::{ExecError, ResultBoxError}; +use crate::data::new_conversation::NewConversation; +use crate::data::user::UserID; +use crate::helpers::database::InsertQuery; use crate::helpers::database; +use crate::utils::date_utils::time; /// Create a new conversation. This method returns the ID of the created conversation pub fn create(conv: &NewConversation) -> ResultBoxError { @@ -175,6 +175,14 @@ pub fn set_name(conv_id: u64, name: Option) -> ResultBoxError<()> { .exec() } +/// Specify whether any member of this conversation can invite other users to join it +pub fn set_can_everyone_add_members(conv_id: u64, allow: bool) -> ResultBoxError<()> { + database::UpdateInfo::new(CONV_LIST_TABLE) + .cond_u64("id", conv_id) + .set_legacy_bool("can_everyone_add_members", allow) + .exec() +} + /// Turn a database entry into a ConversationInfo object fn db_to_conversation_info(row: &database::RowResult) -> ResultBoxError { let conv_id = row.get_u64("id")?;