Closed Bug 1529785 Opened 6 years ago Closed 6 years ago

Add "archive" to messages API

Categories

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

enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Thunderbird 68.0

People

(Reporter: brummolix, Assigned: darktrojan)

References

Details

Attachments

(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 "https://hg.mozilla.org/comm-central/file/tip/mail/components/extensions/schemas/messages.json" 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.

Status: UNCONFIRMED → NEW
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
Status: NEW → ASSIGNED
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] 1529785-move-archive-1.diff 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] 1529785-webext-archive-1.diff 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 geoff@darktrojan.net:
https://hg.mozilla.org/comm-central/rev/01f42b50676e
part 1 - Move message archiving code into a module; r=mkmelin
https://hg.mozilla.org/comm-central/rev/c9405e4f0251
part 2 - Add WebExtension function to archive messages; r=mkmelin

Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 68.0
Status: RESOLVED → REOPENED
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] 1529785-move-archive-2.diff 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 http://mozilla.org/MPL/2.0/. */ > + > +// 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 geoff@darktrojan.net:
https://hg.mozilla.org/comm-central/rev/1b5861b5c09a
part 1 - Move message archiving code into a module; r=mkmelin
https://hg.mozilla.org/comm-central/rev/ffedede7fa10
part 2 - Add WebExtension function to archive messages; r=mkmelin

Status: REOPENED → RESOLVED
Closed: 6 years ago6 years 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 { … }
​​"

Status: RESOLVED → REOPENED
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.

Status: REOPENED → RESOLVED
Closed: 6 years ago6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: