diff --git a/_locales/de-DE/messages.json b/_locales/de-DE/messages.json index 675d8a9..71fdc33 100644 --- a/_locales/de-DE/messages.json +++ b/_locales/de-DE/messages.json @@ -70,6 +70,12 @@ "CorrectIdentity.replyFromRecipient": { "message": "versuchen, die Identität zu suchen und zu benutzen, die in der Empfängerliste erscheint" }, + "CorrectIdentity.keepRecipientAddress": { + "message": "keep the sender address that appears in its recipient list, even if it does not match the identity (e.g., for catch-all adresses)" + }, + "CorrectIdentity.removeSenderFromRecipients": { + "message": "remove the identity from the recipient list" + }, "CorrectIdentity.safetyCaption": { "message": "Sicherheit" }, diff --git a/_locales/en-US/messages.json b/_locales/en-US/messages.json index 08693fa..0ceb90e 100644 --- a/_locales/en-US/messages.json +++ b/_locales/en-US/messages.json @@ -71,6 +71,12 @@ "CorrectIdentity.replyFromRecipient": { "message": "attempt to find and use an identity that appears in its recipient list" }, + "CorrectIdentity.keepRecipientAddress": { + "message": "keep the sender address that appears in its recipient list, even if it does not match the identity (e.g., for catch-all adresses)" + }, + "CorrectIdentity.removeSenderFromRecipients": { + "message": "remove the identity from the recipient list" + }, "CorrectIdentity.safetyCaption": { "message": "Safety" }, diff --git a/_locales/fr-FR/messages.json b/_locales/fr-FR/messages.json index d97da43..0482378 100644 --- a/_locales/fr-FR/messages.json +++ b/_locales/fr-FR/messages.json @@ -47,6 +47,12 @@ "CorrectIdentity.replyFromRecipient": { "message": "tenter de trouver et d’utiliser une identité qui apparaîtrait dans la liste des destinataires du message." }, + "CorrectIdentity.keepRecipientAddress": { + "message": "keep the sender address that appears in its recipient list, even if it does not match the identity (e.g., for catch-all adresses)" + }, + "CorrectIdentity.removeSenderFromRecipients": { + "message": "remove the identity from the recipient list" + }, "CorrectIdentity.safetyCaption": { "message": "Sécurité" }, diff --git a/_locales/ja/messages.json b/_locales/ja/messages.json index 3c4e186..7cc3002 100644 --- a/_locales/ja/messages.json +++ b/_locales/ja/messages.json @@ -47,6 +47,12 @@ "CorrectIdentity.replyFromRecipient": { "message": "返信元のメッセージからアイデンティティの同一性を検出して適用する" }, + "CorrectIdentity.keepRecipientAddress": { + "message": "keep the sender address that appears in its recipient list, even if it does not match the identity (e.g., for catch-all adresses)" + }, + "CorrectIdentity.removeSenderFromRecipients": { + "message": "remove the identity from the recipient list" + }, "CorrectIdentity.safetyCaption": { "message": "安全" }, diff --git a/_locales/nl-NL/messages.json b/_locales/nl-NL/messages.json index a18fecb..0082c50 100644 --- a/_locales/nl-NL/messages.json +++ b/_locales/nl-NL/messages.json @@ -47,6 +47,12 @@ "CorrectIdentity.replyFromRecipient": { "message": "detecteer en gebruik de identiteit die voorkomt in de ontvangerslijst" }, + "CorrectIdentity.keepRecipientAddress": { + "message": "keep the sender address that appears in its recipient list, even if it does not match the identity (e.g., for catch-all adresses)" + }, + "CorrectIdentity.removeSenderFromRecipients": { + "message": "remove the identity from the recipient list" + }, "CorrectIdentity.safetyCaption": { "message": "Veiligheid" }, diff --git a/options.html b/options.html index a7656cd..45381d5 100644 --- a/options.html +++ b/options.html @@ -102,6 +102,12 @@

+
+
diff --git a/scripts/background-script.js b/scripts/background-script.js index a88070c..f33a49c 100644 --- a/scripts/background-script.js +++ b/scripts/background-script.js @@ -11,7 +11,7 @@ let guiState = { let settings = { accountSettings: {}, // key: accountId; values: identityMechanism, explicitIdentity, replyFromRecipient - identitySettings: {}, // key: identityId; values: detectable, detectionAliases, warningAliases + identitySettings: {}, // key: identityId; values: detectable, keepRecipientAddress, removeSenderFromRecipients, detectionAliases, warningAliases // migrate ... property will be dynamically added if old prefs were migrated additionalHeaderFields: [] }; @@ -122,6 +122,12 @@ function checkSettings(inSettings) { if (is.detectable === undefined) { is.detectable = true; } + if (is.keepRecipientAddress === undefined) { + is.keepRecipientAddress = false; + } + if (is.removeSenderFromRecipients === undefined) { + is.removeSenderFromRecipients = true; + } if (is.detectionAliases === undefined) { is.detectionAliases = ""; } @@ -608,16 +614,36 @@ async function handleComposeTabChanged(tabId, initialIdentityId, currentIdentity identityId : newIdentityId, }; - // Check if newIdentityId was in "to", "cc" or "cc". Remove it from there + // Use custom original sender address if Identity Email is not equal to Original Recipient Email (first entry of the list) + // Plus: Check if newIdentityId was in "to", "cc" or "cc". Remove it from there + // Both: If configured, respect the settings. try { let newIdentity = await messenger.identities.get(newIdentityId); let newIdentityEmail = newIdentity.email; - if (searchAndRemoveFromRecipientList(composeTabStatus[tabId].toRecipientsList, newIdentityEmail)) { - // found in "to" - details.to = composeTabStatus[tabId].toRecipientsList; - } else if (searchAndRemoveFromRecipientList(composeTabStatus[tabId].ccRecipientsList, newIdentityEmail)) { - // found in "cc" - details.cc = composeTabStatus[tabId].ccRecipientsList; + let perIdentitySettings = settings.identitySettings[newIdentityId]; + + if (perIdentitySettings.keepRecipientAddress) { + // Keep original sender address (first entry of the list) + let origRecipientEmail = origRecipientsList[0]; + if (newIdentityEmail !== origRecipientEmail) { + console.log("newIdentityEmail: ", newIdentityEmail); + console.log("origRecipientEmail: ", origRecipientEmail); + console.log("Mismatch! Setting sender email to origRecipientEmail (" + origRecipientEmail + ")"); + + details.from = newIdentity.name +' <'+ origRecipientEmail + '>'; + newIdentityEmail = origRecipientEmail; + } + } + + if (perIdentitySettings.removeSenderFromRecipients) { + // remove sender address from recipients + if (searchAndRemoveFromRecipientList(composeTabStatus[tabId].toRecipientsList, newIdentityEmail)) { + // found in "to" + details.to = composeTabStatus[tabId].toRecipientsList; + } else if (searchAndRemoveFromRecipientList(composeTabStatus[tabId].ccRecipientsList, newIdentityEmail)) { + // found in "cc" + details.cc = composeTabStatus[tabId].ccRecipientsList; + } } messenger.compose.setComposeDetails(tabId, details); diff --git a/scripts/options.js b/scripts/options.js index 9f558c2..c5a5abc 100644 --- a/scripts/options.js +++ b/scripts/options.js @@ -52,7 +52,8 @@ function getPerIdentitySettingsOrDefault(identityId) { if (perIdentitySettings === undefined) { // not found in settings, set defaults perIdentitySettings = { - detectable: true, + detectable, removeSenderFromRecipients: true, + keepRecipientAddress: false, detectionAliases: "", warningAliases: "", }; @@ -122,6 +123,10 @@ function updateGuiDetectionIdentityChanged(newDetectionIdentityId) { document.getElementById("detectable").checked = perIdentitySettings.detectable; + document.getElementById("removeSenderFromRecipients").checked = + perIdentitySettings.removeSenderFromRecipients; + document.getElementById("keepRecipientAddress").checked = + perIdentitySettings.keepRecipientAddress; document.getElementById("detectionAliases").value = perIdentitySettings.detectionAliases; } @@ -138,7 +143,7 @@ function updateAdditionalHeaderFields() { let str = ""; for (let i=0; i< settings.additionalHeaderFields.length; i++) { // key value - str = settings.additionalHeaderFields[i][0]; + str += settings.additionalHeaderFields[i][0]; // occurence value if (settings.additionalHeaderFields[i][1]) { @@ -242,6 +247,22 @@ function detectableChanged(result) { notifySettingsChanged(); } +function keepRecipientAddressChanged(result) { + let perIdentitySettings = getPerIdentitySettingsOrDefault( + guiState.currentDetectionIdentity + ); + perIdentitySettings.keepRecipientAddress = result.target.checked; + notifySettingsChanged(); +} + +function removeSenderFromRecipientsChanged(result) { + let perIdentitySettings = getPerIdentitySettingsOrDefault( + guiState.currentDetectionIdentity + ); + perIdentitySettings.removeSenderFromRecipients = result.target.checked; + notifySettingsChanged(); +} + function detectionAliasesChanged(result) { let perIdentitySettings = getPerIdentitySettingsOrDefault( guiState.currentDetectionIdentity @@ -298,6 +319,12 @@ function installConfigPageEventListners() { document .getElementById("detectable") .addEventListener("change", detectableChanged); + document + .getElementById("keepRecipientAddress") + .addEventListener("change", keepRecipientAddressChanged); + document + .getElementById("removeSenderFromRecipients") + .addEventListener("change", removeSenderFromRecipientsChanged); document .getElementById("detectionAliases") .addEventListener("change", detectionAliasesChanged);