Closed Bug 1658657 Opened 4 years ago Closed 4 years ago

compose API function beginForward ignores ComposeDetails

Categories

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

defect

Tracking

(thunderbird_esr78 fixed)

RESOLVED FIXED
84 Branch
Tracking Status
thunderbird_esr78 --- fixed

People

(Reporter: janek, Assigned: darktrojan)

Details

Attachments

(1 file)

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

Steps to reproduce:

A call to
browser.compose.beginForward(msg.id,
"forwardInline",
{ "identityId": identityId });

ignores the identityId. In a

Actual results:

Composer is opened with the default identity selected as sender

Expected results:

The composer should open with the sender that corresponds to the id given in the ComposeDetails param.

The issue is this code in mail/components/extensions/parent/ext-compose.js:

if (type == Ci.nsIMsgCompType.ForwardInline) {
let msgHdr = null;
let msgURI = null;
let hdrIdentity = null;
if (relatedMessageId) {
msgHdr = messageTracker.getMessage(relatedMessageId);
msgURI = msgHdr.folder.getUriForMsg(msgHdr);
}
let newWindowPromise = waitForWindow();
MailServices.compose.OpenComposeWindow(
null,
msgHdr,
msgURI,
type,
0,
hdrIdentity,
null,
null
);

return newWindowPromise;

Instead of assigning null to hdrIdentity in line 73 (let hdrIdentity = null;) it should use resolve the identity for details.identityId and use that:

if (details.identityId !== null) {
if (!extension.hasPermission("accountsRead")) {
throw new ExtensionError(
'Using identities requires the "accountsRead" permission'
);
}

  let identity = MailServices.accounts.allIdentities.find(
    i => i.key == details.identityId
  );
  if (!identity) {
    throw new ExtensionError(`Identity not found: ${details.identityId}`);
  }

  let hdrIdentity = identity;

Yeah, that's broken. I've tried to patch it up but some things just aren't possible at the moment.

Status: UNCONFIRMED → RESOLVED
Closed: 4 years ago
Resolution: --- → DUPLICATE

I've come up with a reasonable work-around, so I'm going to recycle this bug and put it here, since bug numbers are finite and we shouldn't waste them. ;-)

Also I've just realised I didn't read the original message properly and you offered a partial solution. Sorry about that.

Status: RESOLVED → REOPENED
Ever confirmed: true
Resolution: DUPLICATE → ---
Summary: compose API function beginForward ignores identityId from ComposeDetails → compose API function beginForward ignores ComposeDetails
Assignee: nobody → geoff

Pushed by geoff@darktrojan.net:
https://hg.mozilla.org/comm-central/rev/b8d5b08f8fa6
Fix forwarding inline via API by setting details after the compose window opens. r=mkmelin

Status: REOPENED → RESOLVED
Closed: 4 years ago4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 84 Branch

Comment on attachment 9182833 [details]
Bug 1658657 - Fix forwarding inline via API by setting details after the compose window opens. r?mkmelin

[Approval Request Comment]
User impact if declined:
In general: Add-on developers can not use the latest fixes and improvements of our WebExtension API.
Specifically this bug: Bug 1658132 (which is an API fix) needs this bug to be uplifted as well.

Testing completed (on c-c, etc.):
https://treeherder.mozilla.org/jobs?repo=try-comm-central&revision=3cdff293d5d1bd77777f5da371caaa02c4b05de3

Risk to taking this patch (and alternatives if risky):
I hope none

Remark:
The provided try run includes all bugs I want to uplift for TB 78.7 and shows a working patch order.
Bug 1680653 is the first one, who does not have a bug number in the commit message.
This is the second one.

Attachment #9182833 - Flags: approval-comm-esr78?

Comment on attachment 9182833 [details]
Bug 1658657 - Fix forwarding inline via API by setting details after the compose window opens. r?mkmelin

[Triage Comment]
Approved for esr78

Attachment #9182833 - Flags: approval-comm-esr78? → approval-comm-esr78+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: