mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-26 07:19:22 +00:00
Can change canEveryoneAddMembers conversation parameter
This commit is contained in:
parent
82eb997e2d
commit
174ed6244c
@ -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!")
|
||||
|
@ -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<u64> {
|
||||
@ -175,6 +175,14 @@ pub fn set_name(conv_id: u64, name: Option<String>) -> 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<Conversation> {
|
||||
let conv_id = row.get_u64("id")?;
|
||||
|
Loading…
Reference in New Issue
Block a user