1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-06-21 00:45:18 +00:00

Can set conversation image

This commit is contained in:
2021-03-07 15:06:44 +01:00
parent b43453651f
commit 385a800b7a
5 changed files with 55 additions and 4 deletions

View File

@ -462,6 +462,28 @@ pub fn is_message_owner(user_id: &UserID, message_id: u64) -> ResultBoxError<boo
.map(|r| r > 0)
}
/// Remove conversation image
pub fn remove_conversation_image(conv: &Conversation) -> Res {
if let Some(image) = &conv.logo {
delete_user_data_file_if_exists(image)?;
database::UpdateInfo::new(CONV_LIST_TABLE)
.cond_conv_id("id", conv.id)
.set_opt_str("logo", None)
.exec()?;
}
Ok(())
}
/// Set a new conversation image
pub fn set_conversation_image(conv: &Conversation, new_image: &str) -> Res {
database::UpdateInfo::new(CONV_LIST_TABLE)
.cond_conv_id("id", conv.id)
.set_opt_str("logo", Some(new_image.to_string()))
.exec()
}
/// Turn a database entry into a ConversationInfo object
fn db_to_conversation_info(row: &database::RowResult) -> ResultBoxError<Conversation> {
let conv_id = row.get_conv_id("id")?;