Skip to content

Commit 5c6a8fa

Browse files
committed
feat(src/bridge/linear): attribute comments to the Discord author
Pass createAsUser (display name) and displayIconUrl (avatar) on comments so they render as the external Discord author once the bridge uses an OAuth app token. Personal API keys ignore these fields, so the author name stays in the comment body for now.
1 parent b1dd1d5 commit 5c6a8fa

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

‎src/bridge/linear/api.ts‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,20 @@ export async function upsertThreadAttachment(
9191
});
9292
}
9393

94-
export async function addComment(issueId: string, body: string): Promise<void> {
95-
await linear().createComment({ issueId, body });
94+
export async function addComment(
95+
issueId: string,
96+
body: string,
97+
author?: { name: string; iconUrl?: string },
98+
): Promise<void> {
99+
await linear().createComment({
100+
issueId,
101+
body,
102+
// Attributes the comment to an external (non-Linear) author. Only takes
103+
// effect when authenticated as an OAuth application; ignored for personal
104+
// API keys.
105+
createAsUser: author?.name,
106+
displayIconUrl: author?.iconUrl,
107+
});
96108
}
97109

98110
// Moves an issue to the first workflow state of the given type in the team.

‎src/bridge/linear/index.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,15 @@ export class LinearMirror {
4646
if (!content) return;
4747

4848
const name = message.member?.displayName ?? message.author.username;
49-
const author = isTeam ? `${name} (Coder team)` : name;
49+
const iconUrl =
50+
message.member?.displayAvatarURL() ?? message.author.displayAvatarURL();
51+
const label = isTeam ? `${name} (Coder team)` : name;
5052

5153
const issueId = await this.ensureIssue();
52-
await linear.addComment(issueId, `**${author}**\n\n${content}`);
54+
await linear.addComment(issueId, `**${label}**\n\n${content}`, {
55+
name,
56+
iconUrl,
57+
});
5358
}
5459

5560
// Refreshes the attachment metadata and labels, and moves the issue's

0 commit comments

Comments
 (0)