Repository navigation
PLAT-39405 connector: turn Reddit @username text into Matrix mentions - #18
Conversation
Reddit sends mentions as plain "@username" text with no m.mentions or formatted body, so they arrived in Beeper as plain text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
2 potential issues found:
↑ Select any checkbox above to have Indent auto-fix the issue
All CI checks passed on
Select any unchecked box below to run or rerun that agent. Full resultsIndent Review Agent
|
| } | ||
| target := beeperMXID(redditMXID) | ||
| formatted.WriteString(plainToHTML(body[last:start])) | ||
| _, _ = fmt.Fprintf(&formatted, `<a href="%s">%s</a>`, target.URI().MatrixToURL(), html.EscapeString(body[start:end])) |
There was a problem hiding this comment.
| "maunium.net/go/mautrix/id" | ||
| ) | ||
|
|
||
| var mentionPattern = regexp.MustCompile(`(?:^|[^\w@/])(@[\w-]{3,20})`) |
There was a problem hiding this comment.
⚪️ Nit · Usernames longer than 20 chars can be linked by their prefix
(@[\w-]{3,20}) has no trailing boundary. For @some_user_name_that_is_long the first 20 chars are captured, and if a member's name equals that prefix they get linked and pinged while the rest of the token stays plain text. Reddit usernames max out at 20 chars, so a longer token is never a real mention. Require a non-username char or end of string after the capture.
Found by Indent Review Agent
|
Live-tested at this head (b944020, build 7990356): mentions picked in reddit.com/chat's composer arrive with an HTML pill and |
Reddit sends a mention as plain
@usernametext, with nom.mentions,formatted_bodyor user reference (captured from reddit.com/chat's composer), so mentions reached Beeper as plain text. Incoming text that names a member of the room as@usernamenow gets a matrix.to pill andm.mentionsfor that member's ghost, or for the user when they're the one mentioned.🤖 Generated with Claude Code