mirror of
https://github.com/chatmail/core.git
synced 2026-04-26 09:56:35 +03:00
handle incoming profile-images
This commit is contained in:
committed by
holger krekel
parent
a1f496b019
commit
ca63d6ba1c
@@ -962,6 +962,23 @@ fn set_block_contact(context: &Context, contact_id: u32, new_blocking: bool) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_profile_image(
|
||||
context: &Context,
|
||||
contact_id: u32,
|
||||
profile_image: Option<String>,
|
||||
) -> Result<()> {
|
||||
// the given profile image is expected to be already in the blob directory
|
||||
// as profile images can be set only by receiving messages, this should be always the case, however.
|
||||
let mut contact = Contact::load_from_db(context, contact_id)?;
|
||||
match profile_image {
|
||||
Some(profile_image) => contact.param.set(Param::ProfileImage, profile_image),
|
||||
None => contact.param.remove(Param::ProfileImage),
|
||||
};
|
||||
contact.update_param(context)?;
|
||||
context.call_cb(Event::ContactsChanged(Some(contact_id)));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Normalize a name.
|
||||
///
|
||||
/// - Remove quotes (come from some bad MUA implementations)
|
||||
|
||||
@@ -14,7 +14,6 @@ use crate::error::Result;
|
||||
use crate::events::Event;
|
||||
use crate::headerdef::HeaderDef;
|
||||
use crate::job::*;
|
||||
use crate::location;
|
||||
use crate::message::{self, MessageState, MsgId};
|
||||
use crate::mimeparser::*;
|
||||
use crate::param::*;
|
||||
@@ -22,6 +21,7 @@ use crate::peerstate::*;
|
||||
use crate::securejoin::handle_securejoin_handshake;
|
||||
use crate::sql;
|
||||
use crate::stock::StockMessage;
|
||||
use crate::{contact, location};
|
||||
|
||||
// IndexSet is like HashSet but maintains order of insertion
|
||||
type ContactIds = indexmap::IndexSet<u32>;
|
||||
@@ -238,6 +238,19 @@ pub fn dc_receive_imf(
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(profile_image) = mime_parser.profile_image {
|
||||
match contact::set_profile_image(&context, from_id, profile_image) {
|
||||
Ok(()) => {
|
||||
context.call_cb(Event::ChatModified(chat_id));
|
||||
true
|
||||
}
|
||||
Err(err) => {
|
||||
warn!(context, "reveive_imf cannot update profile image: {}", err);
|
||||
false
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// if we delete we don't need to try moving messages
|
||||
if needs_delete_job && !created_db_entries.is_empty() {
|
||||
job_add(
|
||||
|
||||
Reference in New Issue
Block a user