mirror of
				https://gitlab.com/comunic/comunicapiv3
				synced 2025-10-30 23:24:42 +00:00 
			
		
		
		
	Can check if a user is a moderator of a conversation or not
This commit is contained in:
		| @@ -63,5 +63,10 @@ pub fn get_single(r: &mut HttpRequestHandler) -> RequestResult { | ||||
|  | ||||
| /// Update the settings of a conversation | ||||
| pub fn update_settings(r: &mut HttpRequestHandler) -> RequestResult { | ||||
|     let conv_id = r.post_conv_id("conversationID")?; | ||||
|     let is_moderator = conversations_helper::is_user_moderator(r.user_id()?, conv_id)?; | ||||
|  | ||||
|     println!("conv id: {} / is moderator: {}", conv_id, is_moderator); | ||||
|  | ||||
|     r.success("implement it") | ||||
| } | ||||
| @@ -107,6 +107,14 @@ pub fn does_user_belongs_to(user_id: UserID, conv_id: u64) -> ResultBoxError<boo | ||||
|         .exec_count()? > 0) | ||||
| } | ||||
|  | ||||
| /// Check out wheter a user is the moderator of a conversation or not | ||||
| pub fn is_user_moderator(user_id: UserID, conv_id: u64) -> ResultBoxError<bool> { | ||||
|     Ok(database::QueryInfo::new(CONV_LIST_TABLE) | ||||
|         .cond_u64("id", conv_id) | ||||
|         .cond_user_id("user_id", user_id) | ||||
|         .exec_count()? > 0) | ||||
| } | ||||
|  | ||||
| /// 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")?; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user