Closed Bug 1599380 Opened 2 years ago Closed 1 year ago

WebExtensions needs a "new mail arrived" event

Categories

(Thunderbird :: Add-Ons: Extensions API, enhancement)

enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Thunderbird 75.0

People

(Reporter: darktrojan, Assigned: darktrojan)

References

Details

Attachments

(1 file)

No description provided.

I agree on the matter. At the moment I have to use WebExtension Experiment API and to use

Cc["@mozilla.org/messenger/msgnotificationservice;1"].getService(Ci.nsIMsgFolderNotificationService)

in implementation.js in order to subscribe to the event.

It would be nice if browser.messages, for example, were extended with the events related to received / sent messages and an ability to access at least MessageHeader of the message in a callback.

P. S. Actually, after grepping comm-central, I started to use MailServices.mfn and context.extension.messageManager.convert to implement the event only and to do the rest in background.js but nonetheless.

I would be keen to get this API too.

Thanks Alexander for the workaround. I only started to have a look to Thunderbird WebExtension today so using MailServices.mfn and context.extension.messageManager.convert for me are still not clear yet but I will figure out.

Assignee: nobody → geoff
Status: NEW → ASSIGNED

I've wrapped this around nsIMsgFolderListener.msgsClassified which seems to be the most reliable way to get the messages in question (and only those messages). I started out with the various biff notifications but that just wasn't good enough for this use.

Is my description in messages.json accurate? I based it on the comments in nsIMsgFolderListener.idl but I'm not sure if I've understood it correctly.

Attachment #9131811 - Flags: review?(mkmelin+mozilla)
Comment on attachment 9131811 [details] [diff] [review]
1599380-new-mail-received-1.diff

Review of attachment 9131811 [details] [diff] [review]:
-----------------------------------------------------------------

r=mkmelin

::: mail/components/extensions/parent/ext-messages.js
@@ +64,5 @@
> +/**
> + * Listens to the folder notification service for new messages, which are
> + * passed to the onNewMailReceived event.
> + *
> + * @implements nsIMsgFolderListener

I think it should be wrapped in angle braces
@implements {nsIMsgFolderListener}
Attachment #9131811 - Flags: review?(mkmelin+mozilla) → review+

Pushed by geoff@darktrojan.net:
https://hg.mozilla.org/comm-central/rev/2679ad2daf98
WebExtensions API event for when new mail arrives. r=mkmelin

Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 75.0
You need to log in before you can comment on or make changes to this bug.