-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix support for Conversations add-on in Thunderbird 115 and later (#395)
- Loading branch information
Showing
4 changed files
with
40 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
"accountsRead", | ||
"downloads", | ||
"messagesRead", | ||
"management", | ||
"notifications", | ||
"storage", | ||
"tabs" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/** | ||
* Push the authentication result to the Conversation add-on. | ||
* Push the authentication result to the Conversations add-on. | ||
* | ||
* Copyright (c) 2021-2023 Philippe Lieser | ||
* | ||
|
@@ -35,7 +35,7 @@ const log = Logging.getLogger("Conversation"); | |
let port = null; | ||
|
||
/** | ||
* Add a pill in Conversation. | ||
* Add a pill in Conversations. | ||
* | ||
* @param {number} msgId | ||
* @param {Severity|undefined} severity | ||
|
@@ -57,7 +57,7 @@ function addPill(msgId, severity, icon, message, tooltip) { | |
if (!port) { | ||
port = browser.runtime.connect("[email protected]"); | ||
port.onDisconnect.addListener((p) => { | ||
log.debug("Port to Conversation was disconnected", p.error); | ||
log.debug("Port to Conversations was disconnected", p.error); | ||
port = null; | ||
}); | ||
} | ||
|
@@ -67,12 +67,38 @@ function addPill(msgId, severity, icon, message, tooltip) { | |
const verifier = new AuthVerifier(); | ||
|
||
/** | ||
* Verify a message and display the result in Conversation. | ||
* Detect if a Tab shows message in Conversations message view style. | ||
* | ||
* @param {browser.tabs.Tab} tab | ||
* @returns {Promise<boolean>} | ||
*/ | ||
export async function isConversationView(tab) { | ||
if (tab.url?.startsWith("chrome://conversations/")) { | ||
// TB < 115 | ||
return true; | ||
} | ||
// Messages opened in Thunderbirds main 3pane tab have type "mail", | ||
// and are shown in Conversations message view style (if Conversations add-on is installed). | ||
// Single messages opened in a tab or windows have type "messageDisplay", | ||
// and are always shown in Thunderbird's normal message view style. | ||
if (tab.type === "mail") { | ||
try { | ||
const conversationsInfo = await browser.management.get("[email protected]"); | ||
return conversationsInfo.enabled; | ||
} catch (error) { | ||
// Conversations not installed | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* Verify a message and display the result in Conversations. | ||
* | ||
* @param {browser.messages.MessageHeader} MessageHeader | ||
* @returns {Promise<void>} | ||
*/ | ||
export default async function verifyMessage(MessageHeader) { | ||
export async function verifyMessage(MessageHeader) { | ||
const res = await verifier.verify(MessageHeader); | ||
if (!res.dkim[0]) { | ||
throw new Error("Result does not contain a DKIM result."); | ||
|