Skip to content

Commit 595d945

Browse files
laurentftechclaude
andcommitted
Config actions now override message actions
Previously config actions were a fallback when message had no actions. Now config actions take priority, allowing local scripts/URLs to always appear regardless of what the message sender specified. Also update README with click_url documentation. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 046acc4 commit 595d945

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ servers:
180180
- `path` (required for script): Absolute path to script file
181181
- `url` (required for view): URL to open when clicked
182182

183+
**Note**: Config-defined actions override any [actions](https://docs.ntfy.sh/publish/#action-buttons) sent with the ntfy message. This lets you define your own local scripts/URLs that always appear, regardless of what the message sender specified. Message actions are only used when no config actions are defined for the topic.
184+
183185
## CLI Commands
184186

185187
### serve

Sources/NotificationManager.swift

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,16 @@ final class NotificationManager: NSObject, @unchecked Sendable {
182182
"messageId": message.id
183183
]
184184

185-
// Handle actions from message (ntfy protocol)
186-
if let messageActions = message.actions, !messageActions.isEmpty {
185+
// Handle actions: config actions override message actions
186+
if let actions = topicConfig.actions, !actions.isEmpty {
187+
// Config actions take priority - use them instead of message actions
188+
let categoryId = "topic-\(message.topic)-actions"
189+
registerCategory(categoryId: categoryId, actions: actions)
190+
content.categoryIdentifier = categoryId
191+
print("Using \(actions.count) actions from config (overriding message actions)")
192+
fflush(stdout)
193+
} else if let messageActions = message.actions, !messageActions.isEmpty {
194+
// No config actions - use message actions
187195
let categoryId = "msg-\(message.id)-actions"
188196
registerCategoryFromMessage(categoryId: categoryId, actions: messageActions)
189197
content.categoryIdentifier = categoryId
@@ -199,12 +207,6 @@ final class NotificationManager: NSObject, @unchecked Sendable {
199207
print("Registered \(messageActions.count) actions from message")
200208
fflush(stdout)
201209
}
202-
// Handle actions from config (fallback)
203-
else if let actions = topicConfig.actions, !actions.isEmpty {
204-
let categoryId = "topic-\(message.topic)-actions"
205-
registerCategory(categoryId: categoryId, actions: actions)
206-
content.categoryIdentifier = categoryId
207-
}
208210

209211
content.userInfo = userInfo
210212

0 commit comments

Comments
 (0)