mirror of
https://github.com/chatmail/core.git
synced 2026-04-18 05:56:31 +03:00
Compress avatar to below 20k (#2384)
- Currently, group images are compressed as well because it was easier to implement that way. - Currently, in the unlikely case that the avatar is compressed down to 20x20 pixels but still bigger than 20KB, the user doesn't get any indication of this, the avatar simply isn't changed (at least on Android). If we want to change this, the easiest way is probably to let `dc_set_config()` in the ffi call `error!()` if `Selfavatar` can't be set. The same might make sense for some or all other configs. BUUUUUT: At least Android doesn't show error!() toasts anymore, probably because they were used too often and too spammy. - The factor by which we scale down if the file is too big is 1.5.
This commit is contained in:
@@ -10,7 +10,7 @@ const DBVERSION: i32 = 68;
|
||||
const VERSION_CFG: &str = "dbversion";
|
||||
const TABLES: &str = include_str!("./tables.sql");
|
||||
|
||||
pub async fn run(context: &Context, sql: &Sql) -> Result<(bool, bool, bool)> {
|
||||
pub async fn run(context: &Context, sql: &Sql) -> Result<(bool, bool, bool, bool)> {
|
||||
let mut recalc_fingerprints = false;
|
||||
let mut exists_before_update = false;
|
||||
let mut dbversion_before_update = DBVERSION;
|
||||
@@ -39,6 +39,7 @@ pub async fn run(context: &Context, sql: &Sql) -> Result<(bool, bool, bool)> {
|
||||
let dbversion = dbversion_before_update;
|
||||
let mut update_icons = !exists_before_update;
|
||||
let mut disable_server_delete = false;
|
||||
let mut recode_avatar = false;
|
||||
|
||||
if dbversion < 1 {
|
||||
info!(context, "[migration] v1");
|
||||
@@ -460,8 +461,17 @@ paramsv![]
|
||||
sql.execute_migration("ALTER TABLE msgs ADD COLUMN subject TEXT DEFAULT '';", 76)
|
||||
.await?;
|
||||
}
|
||||
if dbversion < 77 {
|
||||
info!(context, "[migration] v77");
|
||||
recode_avatar = true;
|
||||
}
|
||||
|
||||
Ok((recalc_fingerprints, update_icons, disable_server_delete))
|
||||
Ok((
|
||||
recalc_fingerprints,
|
||||
update_icons,
|
||||
disable_server_delete,
|
||||
recode_avatar,
|
||||
))
|
||||
}
|
||||
|
||||
impl Sql {
|
||||
|
||||
Reference in New Issue
Block a user