feat(notifications): add ntfy markdown formatting#2602
feat(notifications): add ntfy markdown formatting#2602v3DJG6GL wants to merge 9 commits intoseerr-team:developfrom
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughNtfy notification agent: added a Markdown-escaping helper, restructured message composition to use bold headers for request/comment/issue payloads, and ensures the returned payload includes Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
server/lib/notifications/agents/ntfy.ts (1)
38-41: Avoid leading blank lines when request message starts empty.On Line 41 and Line 64, unconditional newline prefixes can produce a notification body that starts with empty lines.
💡 Minimal diff
- message += `\n\n**- Requested By:** ${payload.request.requestedBy.displayName}`; + message += `${message ? '\n\n' : ''}**- Requested By:** ${payload.request.requestedBy.displayName}`; … - message += `\n**- Request Status:** ${status}`; + message += `${message ? '\n' : ''}**- Request Status:** ${status}`;Also applies to: 64-64
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@server/lib/notifications/agents/ntfy.ts` around lines 38 - 41, The message-building logic in ntfy.ts currently prepends or appends sections with unconditional "\n\n" which can produce leading blank lines when the initial message is empty; update the code that mutates the variable message (the block that sets message = `**- Description:**\n${message}` and the later append that adds `\n\n**- Requested By:** ${payload.request.requestedBy.displayName}`) to conditionally add the preceding newlines only when message is non-empty, otherwise set the section text without leading blank lines so the final notification body never starts with empty lines.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@server/lib/notifications/agents/ntfy.ts`:
- Around line 67-75: The message construction uses unescaped user-provided
metadata (payload.comment.user.displayName, payload.issue.createdBy.displayName
and similar) while ntfy is sent with markdown: true; implement and call a
sanitizing helper (e.g., escapeMarkdown) to escape markdown metacharacters for
all interpolated metadata fields before concatenation into message, but do NOT
escape the actual comment body (payload.comment.message) so its markdown remains
intact; update the places where message is built (references: message variable
assignment, payload.comment.user.displayName,
payload.issue.createdBy.displayName, IssueTypeName interpolation) to use the
sanitizer.
---
Nitpick comments:
In `@server/lib/notifications/agents/ntfy.ts`:
- Around line 38-41: The message-building logic in ntfy.ts currently prepends or
appends sections with unconditional "\n\n" which can produce leading blank lines
when the initial message is empty; update the code that mutates the variable
message (the block that sets message = `**- Description:**\n${message}` and the
later append that adds `\n\n**- Requested By:**
${payload.request.requestedBy.displayName}`) to conditionally add the preceding
newlines only when message is non-empty, otherwise set the section text without
leading blank lines so the final notification body never starts with empty
lines.
There was a problem hiding this comment.
Pull request overview
Adds Markdown-formatted message bodies for the ntfy notification agent so notifications render with labeled sections (description/request status/comment/issue metadata) in clients that support Markdown.
Changes:
- Reformats ntfy notification
messagecontent to include Markdown emphasis and labeled sections. - Enables Markdown rendering in ntfy payloads via
markdown: true.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
server/lib/notifications/agents/ntfy.ts (1)
41-45: Consider extracting a tiny section-builder helper for repeated string assembly.The same “prepend/append labeled block with conditional spacing” pattern appears in multiple branches; a helper would reduce drift in future edits.
Also applies to: 71-75, 77-83
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@server/lib/notifications/agents/ntfy.ts` around lines 41 - 45, Extract the repeated "prepend/append labeled block with conditional spacing" logic into a small helper (e.g., appendLabeledBlock(existingMessage, label, content)) inside ntfy.ts and use it wherever that pattern appears: replace the payload.request branch that manipulates message, the similar block around lines 71-75, and the block at 77-83; the helper should take the current message string, a label like "Description" or "Requested By", and the escaped content (use this.escapeMarkdown(payload.request.requestedBy.displayName) when appropriate), and return the new message string with correct spacing and formatting so callers (the code touching message and payload.request) just call the helper instead of manually concatenating.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@server/lib/notifications/agents/ntfy.ts`:
- Around line 41-45: Extract the repeated "prepend/append labeled block with
conditional spacing" logic into a small helper (e.g.,
appendLabeledBlock(existingMessage, label, content)) inside ntfy.ts and use it
wherever that pattern appears: replace the payload.request branch that
manipulates message, the similar block around lines 71-75, and the block at
77-83; the helper should take the current message string, a label like
"Description" or "Requested By", and the escaped content (use
this.escapeMarkdown(payload.request.requestedBy.displayName) when appropriate),
and return the new message string with correct spacing and formatting so callers
(the code touching message and payload.request) just call the helper instead of
manually concatenating.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Description
This PR adds markdown formatting ntfy notifications. Both server & android app support markdown formating
AI Disclosure: Claude Sonnet helped me finding relevant code & files. The final implementation and code checks however were done manually by me.
How Has This Been Tested?
I've been running these for about two months without any issues on two instances.
Movie Request Approved
Movie Request Available
New Video Issue Reported
New Comment on Video Issue
Issue resolved
Checklist:
pnpm buildpnpm i18n:extractSummary by CodeRabbit