Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions scripts/ExtendSubject.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export async function ExtendSubject() {
const getOrgHeader = (name) => {
let rv = [];
for (let [hName, hValue] of Object.entries(data.headers)) {
if (name == hName) {
rv.push(...hValue);
}
}
return rv;
}

let { relatedMessageId } = await this.compose.getComposeDetails();
let data = await this.messages.getFull(relatedMessageId);

let subject = getOrgHeader("subject")
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you pass in data as well, so we do not rely on global variables?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getOrgHeader() returns an array, but its return value is used as a string, please join the array entries or pick the first.

let Prefix = this.quicktext.variables[0];
let FullSubject = Prefix + " " + subject;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use template strings:

let FullSubject = `${Prefix} ${subject}`;

await this.compose.setComposeDetails({ subject: FullSubject });
}