Open Bug 1653704 Opened 5 years ago Updated 2 years ago

Add chat API, including ways to get unread chat entries

Categories

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

enhancement

Tracking

(Not tracked)

REOPENED

People

(Reporter: gyunaev, Unassigned)

Details

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0

Steps to reproduce:

I am an author of Birdtray, a Thunderbird system tray add-on which shows a system tray notification when there is unread email. https://github.com/gyunaev/birdtray

I looked at the API documentation and there seem to be no API which would allow me to:

  • Obtain the current number of unread emails in each folder (without enumerating all emails) - would be ideal if it can optionally include the subject/sender;
  • Obtain the current number of unread chats in chat window;
  • Get notified via event when the current unread count changes.

This doesn't seem to be possible with existing API at all - I don't see this info returned via https://thunderbird-webextensions.readthedocs.io/en/68/messages.html

And there seem to be no notification event, and of course enumerating all messages every second is not a good use of CPU time.

I would like to write a plugin for Birdtray to get this info from Thunderbird, and save it into the file on disk/pass it to Birdtray via socket.

You could use

messenger.messages.query({
  folder: aFolder,
  unread: true
}

to get a list of all unread emails in aFolder and thus the number of unread messages.
https://thunderbird-webextensions.readthedocs.io/en/latest/messages.html#query-queryinfo

You can listen for the messenger.messages.onNewMailReceived event to be notified on new emails.
https://thunderbird-webextensions.readthedocs.io/en/latest/messages.html#onnewmailreceived-folder-messages

We do not have a Chat API yet.

I need to correct my last comment. messages.query() only works on fully downloaded messages and not on headers of partially downloaded messages, so the unread information obtained could be wrong. messages.list() is directly asking the (header-) database and gives the correct results, but you have to check each header for read/unread.

When designing the new message database, we have to keep that in mind and make ways for adding events for changes in the db directly.

Summary: Is there a MailExtension API and event to get/be notified of the number of unread messages in each folder? → Add events for header/gloda/new message DB for property changes.

Listener for read-status change on a message has been added by bug 1627604.
Global listeners for folder status will be done by bug 1708644.

Status: UNCONFIRMED → RESOLVED
Closed: 4 years ago
Resolution: --- → DUPLICATE
Status: RESOLVED → REOPENED
Ever confirmed: true
Resolution: DUPLICATE → ---

The folder related issues are now covered in bug 1708644. I changed this bug to be about chat API only, which still has to be done.

I would like to write a plugin for Birdtray to get this info from Thunderbird, and save it into the file on disk/pass it to Birdtray via socket.

You could use native messaging for that:
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_messaging

For more question related to add-on development, you can contact us via chat or via email:
https://developer.thunderbird.net/add-ons/community

Summary: Add events for header/gloda/new message DB for property changes. → Add chat API, including ways to get unread chat entries
You need to log in before you can comment on or make changes to this bug.