Closed Bug 1529785 Opened 7 months ago Closed 3 months ago

Add "archive" to messages API


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

Not set


(Not tracked)

Thunderbird 68.0


(Reporter: brummolix, Assigned: darktrojan)


(Blocks 1 open bug)



(2 files, 1 obsolete file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0

Steps to reproduce:

It would be nice to have a "archive" function in the messages API

As I see in "" there seem to be a copy and move function.
The archive function would be similar, expect that it would use the archive folder and archive settings.

Blocks: webext-tb

I'd like to have this, but first the archiving code will need to be extracted from the UI code and put somewhere the extensions back end can reach it. Not impossible, but not easy either.

Type: defect → enhancement
Ever confirmed: true
Attached patch 1529785-move-archive-1.diff (obsolete) — Splinter Review

Part 1 - moves a bunch of functions into MailUtils and creates a new MessageArchiver.jsm.

Assignee: nobody → geoff
Attachment #9057159 - Flags: review?(mkmelin+mozilla)

Part 2 - webextension function

Attachment #9057160 - Flags: review?(mkmelin+mozilla)

(That was less complicated than it looked.)

Comment on attachment 9057159 [details] [diff] [review]

Review of attachment 9057159 [details] [diff] [review]:

LGTM, r=mkmelin

::: mail/base/modules/MailUtils.jsm
@@ +364,5 @@
>                             this.INTER_FOLDER_PROCESSING_DELAY_MS,
>                             Ci.nsITimer.TYPE_REPEATING_SLACK);
>    },
> +
> +  // These three functions were moved here from mail/base/content/mailCommands.js.

we can remove the comment
Attachment #9057159 - Flags: review?(mkmelin+mozilla) → review+
Comment on attachment 9057160 [details] [diff] [review]

Review of attachment 9057160 [details] [diff] [review]:

::: mail/components/extensions/parent/ext-messages.js
@@ +186,5 @@
> +
> +          return new Promise((resolve) => {
> +            let archiver = new MessageArchiver();
> +            archiver.oncomplete = resolve;
> +            archiver.archiveMessages(messages);

would probably make sense to followup with this and mad archiveMessages return a Promise
Attachment #9057160 - Flags: review?(mkmelin+mozilla) → review+

Pushed by
part 1 - Move message archiving code into a module; r=mkmelin
part 2 - Add WebExtension function to archive messages; r=mkmelin

Closed: 5 months ago
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 68.0
Resolution: FIXED → ---

Okay, failure 1 was because I renamed something after the Try run.

Failure 2 was because I dismissed it in the Try run as not possibly caused by this patch, but it was.

I eliminated findDeliveredToIdentityEmail because it foolishly ties logic to the UI, and forgot to replace it.

Let's try that again.

Attachment #9057159 - Attachment is obsolete: true
Attachment #9057464 - Flags: review?(mkmelin+mozilla)
Comment on attachment 9057464 [details] [diff] [review]

Review of attachment 9057464 [details] [diff] [review]:

::: mail/base/content/mailCommands.js
@@ +49,5 @@
> +  function findDeliveredToIdentityEmail() {
> +    // This function reads from currentHeaderData, which is only useful if we're
> +    // looking at the currently-displayed message. Otherwise, just return
> +    // immediately so we don't waste time.
> +    if (hdr != gMessageDisplay.displayedMessage)

hdr looks to  be undefined when you moved it here

::: mail/base/modules/MessageArchiver.jsm
@@ +1,5 @@
> +/* This Source Code Form is subject to the terms of the Mozilla Public
> + * License, v. 2.0. If a copy of the MPL was not distributed with this
> + * file, you can obtain one at */
> +
> +// This code was moved here from mail/base/content/mailWindowOverlay.js.

please remove
Attachment #9057464 - Flags: review?(mkmelin+mozilla) → review-

It is defined by the outer function, further down. I put the inner function at the top because that's what you're supposed to do.

Surprised that works. Please pass in the hdr to the function, to remove the magic mix. r=mkmelin with that

Pushed by
part 1 - Move message archiving code into a module; r=mkmelin
part 2 - Add WebExtension function to archive messages; r=mkmelin

Closed: 5 months ago5 months ago
Resolution: --- → FIXED

I tried to use the new function in TB 680b1 on Windows.
But it says: browser.messages.archive is not a function

The output of the browser.messages object at the console gives:
​continueList: function ()
​copy: undefined
​delete: undefined
​get: function ()
​getFull: function ()
​list: function ()
​listTags: function ()
​move: undefined
​update: function ()
​<get continueList()>: function ()
​<set continueList()>: function ()
​<get copy()>: function ()
​<set copy()>: function ()
​<get delete()>: function ()
​<set delete()>: function ()
​<get get()>: function ()
​<set get()>: function ()
​<get getFull()>: function ()
​<set getFull()>: function ()
​<get listTags()>: function ()
​<set listTags()>: function ()
​<get move()>: function ()
​<set move()>: function ()
​<get update()>: function ()
​<set update()>: function ()
​<prototype>: Object { … }

Resolution: FIXED → ---

It appears your extension does not have the messagesMove permission.

Please don't reopen bugs that have been fixed for some time. Open a new one if you think something is wrong.

Closed: 5 months ago3 months ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.