mirror of
https://github.com/binwiederhier/ntfy.git
synced 2026-05-09 16:35:53 +02:00
[GH-ISSUE #827] Allow sending custom properties in POSTed JSON #585
Labels
No labels
ai-generated
android-app
android-app
android-app
🪲 bug
build
build
dependencies
docs
enhancement
enhancement
🔥 HOT
in-progress 🏃
ios
prio:low
prio:low
pull-request
question
🔒 security
server
server
unified-push
web-app
website
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/ntfy#585
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @tka85 on GitHub (Aug 1, 2023).
Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/827
💡 Idea
When publishing a notification using JSON, it would be useful to allow sending additional custom properties which will be forwarded verbatim to the mobile front end (assuming one uses a self-hosted ntfy server and builds their own mobile app). These additional properties could be nested under the toplevel
"extras"property in the POSTed JSON.💻 Target components
This is a feature request for the ntfy server.
Example:
@wunter8 commented on GitHub (Aug 1, 2023):
What would be the goal of this? Why not just send a custom JSON string as the body of the notification?
@tka85 commented on GitHub (Aug 2, 2023):
The ntfy server currently only understands predefined properties in the POSTed JSON. Added custom properties do not get forwarded to the frontend. Use case is for self-hosted nfty servers with a custom frontend that needs fields beyond the known
message,titleetc.This is the relevant discussion with @binwiederhier .
@wunter8 commented on GitHub (Aug 2, 2023):
I understand what you're asking for (and I agree with binwiederhier that it'd probably be easy to implement), but I don't understand why sending an (escaped) JSON string as the body of the message doesn't work. If you're already building a custom frontend, then you don't need to use any of ntfy's existing fields (except to get your JSON string out).
The current ntfy response looks like this:
You want to change it to this:
Then, after
data = resp.json(), you could access the custom value atdata.extras.customFieldWhy not do this?
Then, after
data = resp.json().message.json(), you could access the custom value atdata.customField, right?@tka85 commented on GitHub (Aug 3, 2023):
Just opened the issue because as @binwiederhier suggested
(a) this was something he had already considered doing before and
(b) the implementation is easy
Yes, what you propose would work. I'm not saying it wouldn't.
But cannibalizing the preexisting
messagethat has very specific semantics, is a hackey workaround.@wunter8 commented on GitHub (Aug 5, 2023):
Got it. I hope you don't feel like I am dismissing the value of your proposal. I know other people have already been sending JSON strings with custom fields as the
message, so I wanted to make sure you weren't having problems with that.And I'm sure they will also be happy to have a convenient
extrasfield where they can put additional information instead.I will see if I can implement this sometime this week.
@tka85 commented on GitHub (Aug 6, 2023):
I don't feel like that at all. I completely understand you asking for justification esp. when it comes to feature requests. After all it is I who makes a request for your time and effort.
Much appreciated regardless of whether you go ahead with its implementation or not.
@tka85 commented on GitHub (Aug 20, 2023):
@wunter8 I see the fix. Would it be possible to also get arrays to be allowed values inside the
extrasobject?@tka85 commented on GitHub (Oct 25, 2023):
Any update on this?
@wunter8 commented on GitHub (Oct 25, 2023):
Nope. Sorry. I've been busy with work and haven't been able to finish the Android side of things yet
@grexe commented on GitHub (Jun 9, 2025):
I would also love to see this. I need to keep track of changes on my server and send additional information to the client.
Usually the fields are called
userdatawhich seems more specific thanextras, but it's just a name.In the meantime, I guess I'll have to abuse tags for my needs 😉