fix(jsonrpc): Use Core's logic for computing VcardContact.color (#7294)

Before, the color was computed from the address, but as we've switched to fingerprint-based contact
colors, this logic became stale. Now `deltachat::contact::get_color()` is used. A test would be nice
to have, but as now all the logic is in Core, this isn't critical as there are Core tests at least.
This commit is contained in:
iequidoo
2025-10-13 01:26:39 -03:00
committed by iequidoo
parent caf5f1f619
commit 377f57f1c3
4 changed files with 39 additions and 16 deletions

View File

@@ -753,6 +753,14 @@ pub(crate) fn buf_decompress(buf: &[u8]) -> Result<Vec<u8>> {
Ok(mem::take(decompressor.get_mut()))
}
/// Returns the given `&str` if already lowercased to avoid allocation, otherwise lowercases it.
pub(crate) fn to_lowercase(s: &str) -> Cow<'_, str> {
match s.chars().all(char::is_lowercase) {
true => Cow::Borrowed(s),
false => Cow::Owned(s.to_lowercase()),
}
}
/// Increments `*t` and checks that it equals to `expected` after that.
pub(crate) fn inc_and_check<T: PrimInt + AddAssign + std::fmt::Debug>(
t: &mut T,