api!: Contact::get_color(): Preserve address-based color hue for SELF

4010c60e7b "feat: use key fingerprints for color generation" changes
colors for contacts including SELF. Even if an avatar is set, the self-color is visible in
e.g. replies to outgoing messages.

This adds `Config::Selfcolor` and sets it in a migration. This doesn't preserve the old
address-based color accurately because the old code generating colors is already dropped, so this
only preserves the color angle (hue).
This commit is contained in:
iequidoo
2025-08-27 07:20:52 -03:00
parent 0bbd910883
commit 0dab21007d
13 changed files with 66 additions and 15 deletions

View File

@@ -32,7 +32,10 @@ impl Account {
let addr = ctx.get_config(Config::Addr).await?;
let profile_image = ctx.get_config(Config::Selfavatar).await?;
let color = color_int_to_hex_string(
Contact::get_by_id(ctx, ContactId::SELF).await?.get_color(),
Contact::get_by_id(ctx, ContactId::SELF)
.await?
.get_color(ctx)
.await?,
);
let private_tag = ctx.get_config(Config::PrivateTag).await?;
Ok(Account::Configured {

View File

@@ -97,7 +97,7 @@ impl ContactObject {
Ok(ContactObject {
address: contact.get_addr().to_owned(),
color: color_int_to_hex_string(contact.get_color()),
color: color_int_to_hex_string(contact.get_color(context).await?),
auth_name: contact.get_authname().to_owned(),
status: contact.get_status().to_owned(),
display_name: contact.get_display_name().to_owned(),

View File

@@ -162,7 +162,9 @@ impl MessageObject {
message_id: quote.get_id().to_u32(),
chat_id: quote.get_chat_id().to_u32(),
author_display_name: quote_author.get_display_name().to_owned(),
author_display_color: color_int_to_hex_string(quote_author.get_color()),
author_display_color: color_int_to_hex_string(
quote_author.get_color(context).await?,
),
override_sender_name: quote.get_override_sender_name(),
image: if quote.get_viewtype() == Viewtype::Image
|| quote.get_viewtype() == Viewtype::Gif
@@ -581,7 +583,7 @@ impl MessageSearchResult {
id: msg_id.to_u32(),
author_profile_image: profile_image,
author_name,
author_color: color_int_to_hex_string(sender.get_color()),
author_color: color_int_to_hex_string(sender.get_color(context).await?),
author_id: sender.id.to_u32(),
chat_id: chat.id.to_u32(),
chat_name: chat.get_name().to_owned(),