fix: preserve newlines when forwarding comments to Discord #1

Merged
perny merged 7 commits from claw/flight-attendant:fix/preserve-comment-newlines into main 2026-02-02 18:11:19 +02:00
Contributor

Problem

comment_stripped loses line breaks from HTML content, causing multiline comments to appear as a single line in Discord.

Solution

Added htmlToDiscordText() helper that converts comment_html to Discord-friendly text:

  • </p><p> → double newline
  • <br> → newline
  • <li> → bullet points
  • Strips remaining HTML tags
  • Decodes HTML entities (&amp;, &nbsp;, etc.)

Falls back to comment_stripped if HTML is unavailable.

## Problem `comment_stripped` loses line breaks from HTML content, causing multiline comments to appear as a single line in Discord. ## Solution Added `htmlToDiscordText()` helper that converts `comment_html` to Discord-friendly text: - `</p><p>` → double newline - `<br>` → newline - `<li>` → bullet points - Strips remaining HTML tags - Decodes HTML entities (`&amp;`, `&nbsp;`, etc.) Falls back to `comment_stripped` if HTML is unavailable.
comment_stripped loses line breaks from HTML content.
Now uses comment_html with proper conversion:
- </p><p> → double newline
- <br> → newline
- <li> → bullet points
- Strips remaining HTML, decodes entities

Falls back to comment_stripped if HTML unavailable.
Images in comment_html are now converted to their URLs,
which Discord will automatically embed as previews.
Plane attachment URLs require authentication, so Discord can't
embed them directly. Now:

- Parses comment_html to categorize images
- Plane asset URLs: fetched with API key, uploaded as Discord attachments
- External URLs (e.g. Unsplash): kept as-is for Discord auto-embed

Added:
- fetchPlaneAttachment() in plane.ts
- WebhookAttachment type in discord.ts
- parseCommentHtml() replaces htmlToDiscordText()
app.plane.so asset URLs return HTML (login page) even with API key.
The API endpoint at api.plane.so properly returns the binary content.

Converts asset URL path:
  /api/assets/v2/workspaces/{slug}/projects/{pid}/issues/{iid}/attachments/{aid}/
To API endpoint:
  https://api.plane.so/api/v1/workspaces/{slug}/projects/{pid}/issues/{iid}/issue-attachments/{aid}/

Tested: Successfully fetches 70-byte PNG with correct headers.
perny merged commit 4bb15a5dca into main 2026-02-02 18:11:19 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
perny/flight-attendant!1
No description provided.