mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 01:16:31 +03:00
sync encrypted avatars only
This commit is contained in:
@@ -1100,14 +1100,19 @@ pub(crate) async fn set_profile_image(
|
|||||||
context: &Context,
|
context: &Context,
|
||||||
contact_id: u32,
|
contact_id: u32,
|
||||||
profile_image: &AvatarAction,
|
profile_image: &AvatarAction,
|
||||||
|
was_encrypted: bool,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let mut contact = Contact::load_from_db(context, contact_id).await?;
|
let mut contact = Contact::load_from_db(context, contact_id).await?;
|
||||||
let changed = match profile_image {
|
let changed = match profile_image {
|
||||||
AvatarAction::Change(profile_image) => {
|
AvatarAction::Change(profile_image) => {
|
||||||
if contact_id == DC_CONTACT_ID_SELF {
|
if contact_id == DC_CONTACT_ID_SELF {
|
||||||
|
if was_encrypted {
|
||||||
context
|
context
|
||||||
.set_config(Config::Selfavatar, Some(profile_image))
|
.set_config(Config::Selfavatar, Some(profile_image))
|
||||||
.await?;
|
.await?;
|
||||||
|
} else {
|
||||||
|
info!(context, "Do not use unencrypted selfavatar.");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
contact.param.set(Param::ProfileImage, profile_image);
|
contact.param.set(Param::ProfileImage, profile_image);
|
||||||
}
|
}
|
||||||
@@ -1115,7 +1120,11 @@ pub(crate) async fn set_profile_image(
|
|||||||
}
|
}
|
||||||
AvatarAction::Delete => {
|
AvatarAction::Delete => {
|
||||||
if contact_id == DC_CONTACT_ID_SELF {
|
if contact_id == DC_CONTACT_ID_SELF {
|
||||||
|
if was_encrypted {
|
||||||
context.set_config(Config::Selfavatar, None).await?;
|
context.set_config(Config::Selfavatar, None).await?;
|
||||||
|
} else {
|
||||||
|
info!(context, "Do not use unencrypted selfavatar deletion.");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
contact.param.remove(Param::ProfileImage);
|
contact.param.remove(Param::ProfileImage);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -197,7 +197,14 @@ pub async fn dc_receive_imf(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some(avatar_action) = &mime_parser.user_avatar {
|
if let Some(avatar_action) = &mime_parser.user_avatar {
|
||||||
match contact::set_profile_image(&context, from_id, avatar_action).await {
|
match contact::set_profile_image(
|
||||||
|
&context,
|
||||||
|
from_id,
|
||||||
|
avatar_action,
|
||||||
|
mime_parser.was_encrypted(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
{
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
context.emit_event(Event::ChatModified(chat_id));
|
context.emit_event(Event::ChatModified(chat_id));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user