Closed Bug 1662015 Opened 2 years ago Closed 2 years ago

Add/remove/update attachment functions don't work in onBeforeSend listener

Categories

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

Tracking

(thunderbird_esr78+ fixed, thunderbird81 affected)

RESOLVED FIXED
82 Branch
Tracking Status
thunderbird_esr78 + fixed
thunderbird81 --- affected

People

(Reporter: darktrojan, Assigned: darktrojan)

References

(Blocks 1 open bug)

Details

(Whiteboard: [TB 78.4.0])

Attachments

(1 file)

This should work, but it doesn't appear to:

browser.compose.onBeforeSend.addListener((tab, details) =>
  browser.compose.addAttachment(tab.id, { file: new File(["foo bar"], "foobar.txt") })
)

I tested this by manually applying the patch, but it does not work. Also the workaround suggested in the topicbox thread does not work. Not in TB78 and also not in tip. This is the used background.js:

function listener (tab, details) {
  console.log(tab);
  console.log(details);
  let file = new File(["Some example text."], "test.txt");
  browser.compose.addAttachment(tab.id, { file });
  
  return {  details: {}  };
}

browser.compose.onBeforeSend.addListener(listener);

The attachment is added to the tab, I can see it, but it is not send.

See Also: → 1662018

browser.compose.addAttachment(tab.id, { file });

You didn't await this. The listener's returning immediately and sending continues.

Ouch. Making the listener an async function and awaiting addAttachmant indeed works. The patch than of course also works in tip and the attachment is added without the need to return an empty details obj.

Pushed by geoff@darktrojan.net:
https://hg.mozilla.org/comm-central/rev/bb4a328d217e
Fix modification of attachments from a onBeforeSend listener. r=john.bieling

Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 82 Branch

Comment on attachment 9173254 [details]
Bug 1662015 - Fix modification of attachments from a onBeforeSend listener. r?mkmelin

[Approval Request Comment]
WX API correctness fix. Should go to 78 at some point.

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

(In reply to Magnus Melin [:mkmelin] from comment #6)

WX API correctness fix. Should go to 78 at some point.

needs to go with bug 1662018

Comment on attachment 9173254 [details]
Bug 1662015 - Fix modification of attachments from a onBeforeSend listener. r?mkmelin

[Triage Comment]
Approved for esr78

needs to go with bug 1662018

Flags: needinfo?(rob)
Attachment #9173254 - Flags: approval-comm-esr78? → approval-comm-esr78+
Flags: needinfo?(rob)
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Whiteboard: [TB 78.4.0]

Resetting this bug to fixed so that it shows in uplift queries again.

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