Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Wrong signature and reply action used due to case-sensitive emails #2182

Merged
merged 1 commit into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Infomaniak Mail - Android
* Copyright (C) 2022-2024 Infomaniak Network SA
* Copyright (C) 2022-2025 Infomaniak Network SA
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -30,9 +30,9 @@ interface Correspondent : Parcelable {

val initials: String

fun isMe(): Boolean = AccountUtils.currentMailboxEmail == email
fun isMe(): Boolean = AccountUtils.currentMailboxEmail?.lowercase() == email.lowercase()

fun shouldDisplayUserAvatar(): Boolean = isMe() && email == AccountUtils.currentUser?.email
fun shouldDisplayUserAvatar(): Boolean = isMe() && email.lowercase() == AccountUtils.currentUser?.email?.lowercase()

fun getNameOrEmail(): String = name.ifBlank { email }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ class NewMessageViewModel @Inject constructor(

private fun guessMostFittingSignature(message: Message, signatures: List<Signature>): Signature? {

val signatureEmailsMap = signatures.groupBy { it.senderEmail }
val signatureEmailsMap = signatures.groupBy { it.senderEmail.lowercase() }

return findSignatureInRecipients(message.to, signatureEmailsMap)
?: findSignatureInRecipients(message.from, signatureEmailsMap)
Expand All @@ -554,13 +554,13 @@ class NewMessageViewModel @Inject constructor(
signatureEmailsMap: Map<String, List<Signature>>,
): Signature? {

val matchingEmailRecipients = recipients.filter { it.email in signatureEmailsMap }
val matchingEmailRecipients = recipients.filter { it.email.lowercase() in signatureEmailsMap }
if (matchingEmailRecipients.isEmpty()) return null // If no Recipient represents us, go to next Recipients

var bestScore = NO_MATCH
var bestSignature: Signature? = null
matchingEmailRecipients.forEach { recipient ->
val signatures = signatureEmailsMap[recipient.email] ?: return@forEach
val signatures = signatureEmailsMap[recipient.email.lowercase()] ?: return@forEach
val (score, signature) = computeScore(recipient, signatures)
when (score) {
EXACT_MATCH_AND_IS_DEFAULT -> return signature
Expand Down