mirror of
https://github.com/chatmail/core.git
synced 2026-05-19 23:06:32 +03:00
fix: randomize avatar blob filenames to work around caching
This commit is contained in:
@@ -11,6 +11,7 @@ use deltachat_derive::{FromSql, ToSql};
|
|||||||
use format_flowed::unformat_flowed;
|
use format_flowed::unformat_flowed;
|
||||||
use lettre_email::mime::Mime;
|
use lettre_email::mime::Mime;
|
||||||
use mailparse::{addrparse_header, DispositionType, MailHeader, MailHeaderMap, SingleInfo};
|
use mailparse::{addrparse_header, DispositionType, MailHeader, MailHeaderMap, SingleInfo};
|
||||||
|
use rand::distributions::{Alphanumeric, DistString};
|
||||||
|
|
||||||
use crate::aheader::{Aheader, EncryptPreference};
|
use crate::aheader::{Aheader, EncryptPreference};
|
||||||
use crate::blob::BlobObject;
|
use crate::blob::BlobObject;
|
||||||
@@ -785,7 +786,15 @@ impl MimeMessage {
|
|||||||
.collect::<String>()
|
.collect::<String>()
|
||||||
.strip_prefix("base64:")
|
.strip_prefix("base64:")
|
||||||
{
|
{
|
||||||
match BlobObject::store_from_base64(context, base64, "avatar").await {
|
// Add random suffix to the filename
|
||||||
|
// to prevent the UI from accidentally using
|
||||||
|
// cached "avatar.jpg".
|
||||||
|
let suffix = Alphanumeric
|
||||||
|
.sample_string(&mut rand::thread_rng(), 7)
|
||||||
|
.to_lowercase();
|
||||||
|
|
||||||
|
match BlobObject::store_from_base64(context, base64, &format!("avatar-{suffix}")).await
|
||||||
|
{
|
||||||
Ok(path) => Some(AvatarAction::Change(path)),
|
Ok(path) => Some(AvatarAction::Change(path)),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
warn!(
|
warn!(
|
||||||
|
|||||||
Reference in New Issue
Block a user