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:
@ -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")?;
|
||||
|
Reference in New Issue
Block a user