mirror of
				https://gitlab.com/comunic/comunicapiv3
				synced 2025-10-30 23:24:42 +00:00 
			
		
		
		
	Can change canEveryoneAddMembers conversation parameter
This commit is contained in:
		| @@ -116,6 +116,13 @@ pub fn update_settings(r: &mut HttpRequestHandler) -> RequestResult { | |||||||
|  |  | ||||||
|             conversations_helper::set_name(conv_id, name)?; |             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!") |     r.success("Conversation information successfully updated!") | ||||||
|   | |||||||
| @@ -2,14 +2,14 @@ | |||||||
| //! | //! | ||||||
| //! @author Pierre Hubert | //! @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::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::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::helpers::database; | ||||||
|  | use crate::utils::date_utils::time; | ||||||
|  |  | ||||||
| /// Create a new conversation. This method returns the ID of the created conversation | /// Create a new conversation. This method returns the ID of the created conversation | ||||||
| pub fn create(conv: &NewConversation) -> ResultBoxError<u64> { | pub fn create(conv: &NewConversation) -> ResultBoxError<u64> { | ||||||
| @@ -175,6 +175,14 @@ pub fn set_name(conv_id: u64, name: Option<String>) -> ResultBoxError<()> { | |||||||
|         .exec() |         .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 | /// Turn a database entry into a ConversationInfo object | ||||||
| fn db_to_conversation_info(row: &database::RowResult) -> ResultBoxError<Conversation> { | fn db_to_conversation_info(row: &database::RowResult) -> ResultBoxError<Conversation> { | ||||||
|     let conv_id = row.get_u64("id")?; |     let conv_id = row.get_u64("id")?; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user