1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-06-21 17:05:16 +00:00

Can check if a user is a moderator of a conversation or not

This commit is contained in:
2020-06-12 11:26:12 +02:00
parent f3a96ffad1
commit fad9300771
2 changed files with 13 additions and 0 deletions

View File

@ -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")?;