mirror of
				https://gitlab.com/comunic/comunicapiv3
				synced 2025-11-04 09:34:04 +00:00 
			
		
		
		
	Ready to update the list of members of a conversation
This commit is contained in:
		@@ -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!")
 | 
					    r.success("Conversation information successfully updated!")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -115,6 +115,14 @@ pub fn is_user_moderator(user_id: UserID, conv_id: u64) -> ResultBoxError<bool>
 | 
				
			|||||||
        .exec_count()? > 0)
 | 
					        .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
 | 
					/// Set whether a user is following a conversation or not
 | 
				
			||||||
pub fn set_following(user_id: UserID, conv_id: u64, following: bool) -> ResultBoxError<()> {
 | 
					pub fn set_following(user_id: UserID, conv_id: u64, following: bool) -> ResultBoxError<()> {
 | 
				
			||||||
    database::UpdateInfo::new(CONV_USERS_TABLE)
 | 
					    database::UpdateInfo::new(CONV_USERS_TABLE)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user