Add WebExtensions API to block sending message from a message composition window (mailRequest like webRequest)
Categories
(Thunderbird :: Add-Ons: Extensions API, enhancement, P2)
Tracking
(Not tracked)
People
(Reporter: yuki, Assigned: darktrojan)
References
Details
Attachments
(1 file, 2 obsolete files)
13.39 KB,
patch
|
mkmelin
:
review+
|
Details | Diff | Splinter Review |
On company use, addons to block sending of composing messages before send is required, to avoid missending. There are some know major addons for the purpose, for example:
Confirm-Address
https://addons.thunderbird.net/thunderbird/addon/confirm-address-5582/
Flex Confirm Mail
https://addons.thunderbird.net/thunderbird/addon/flex-confirm-mail/
I've looked the list of planned WebExtensions APIs on Thunderbird but I couldn't find out any API to do that, like Firefox's tabs.webRequest.onBeforeRequest
.
Local email client is still used on many companies in Japan. "How to avoid missending" is very popular topic, and sometimes it can be the core reason why they use Thunderbird. Thus I propose to add something API to do that on Thunderbird.
API draft:
function tryBlock(header, parts) {
return new Promise((resolve, reject) => {
if ([...header.recipients,
...header.ccList,
...header.bccList].every(recipient => /@mycompanydomain/.test(recipient)))
return resolve();
// show custom UI to ask the user like
// "do you really want to send this mail to these recipients?"
// with checkboxes
browser.composeAction.openPopup();
// the popup content sends a message to notify the result: granted or rejected.
const listener = (message, sender) => {
browser.runtime.onMessage.removeListener(listener);
if (message && message.result == 'granted')
resolve();
else
resolve({ cancel: true });
};
browser.runtime.onMessage.addListener(listener);
});
}
browser.compose.onBeforeSend.addListener(
tryBlock,
["blocking"]
);
How about such an API?
I know that such a blocking type API is very rare and new proposals like that are never been accepted on Firefox's WebExtensions, because Firefox has a policy avoiding performance problem. But I think that Thunderbird looks no need to concentrate at the point.
Updated•5 years ago
|
Comment 1•5 years ago
|
||
I think having such an API would be valuable, thanks for filing this bug! We could have a similar model as webRequest indeed with a few events based on the lifecycle of a message, and a blocking flag that would allow async operations.
Note that for Manifest v3, Google is removing blocking webRequest for performance and security reasons. Email is different, but this just something to keep in mind.
Comment 2•5 years ago
|
||
At the moment my add-on Mail Merge listens for the "compose-send-message" event in the Message Compose Window. See: function mailmerge.check() in /content/overlay.js in Mail Merge 6.1.0.
It checks, whether there are multiple recipients in the To field or variables in the To / Cc / Bcc / Reply / Subject / Body fields. Then it asks the user, whether to continue the send process or to cancel the send process and use Mail Merge instead.
Having an API to block sending messages is necessary for Mail Merge to prevent a user from accidentally sending a message to multiple (many!) recipients instead of using Mail Merge - which creates an individual messages for each recipient.
When you develop such an API, please keep Mail Merge and its use-case in mind, thanks!
Assignee | ||
Comment 3•5 years ago
•
|
||
I am working on this. I have enough to prove that what I want to do works, but not the exact details yet.
As it is you'll be able to listen to an event and cancel the sending outright or change some things† and continue to send. Your event listener can return an answer immediately or a Promise to do so later. Not sure how multiple send attempts will work as yet.
† For now, just the recipients and subject. We've yet to work out how we represent the message body and attachments for this and various other uses.
Assignee | ||
Comment 4•5 years ago
|
||
Before adding new functions, I wanted to add some tests of the existing browser.compose
functions, because there are none.
Assignee | ||
Comment 5•5 years ago
|
||
For now, this just has the ability to pause or block sending. I've removed the parts that allow reading and changing fields as it adds too much complexity and there are some issues I have yet to resolve.
Assignee | ||
Comment 6•5 years ago
|
||
… and of course, the moment I upload it I find a mistake.
Assignee | ||
Comment 7•5 years ago
|
||
Updated•5 years ago
|
Pushed by geoff@darktrojan.net:
https://hg.mozilla.org/comm-central/rev/f1815f2e593f
Add an API event that can block message sending from the compose window. r=mkmelin
Assignee | ||
Updated•5 years ago
|
Description
•