Code Monkey home page Code Monkey logo

Comments (9)

wunter8 avatar wunter8 commented on June 8, 2024

What would be the goal of this? Why not just send a custom JSON string as the body of the notification?

from ntfy.

tka85 avatar tka85 commented on June 8, 2024

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, title etc.

This is the relevant discussion with @binwiederhier .

from ntfy.

wunter8 avatar wunter8 commented on June 8, 2024

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:

{ 
   "id":"fajyTv5FQ0iM",
   "time":1690985276,
   "expires":1691028476,
   "event":"message",
   "topic":"test",
   "message":"testing"
}

You want to change it to this:

{ 
   "id":"fajyTv5FQ0iM",
   "time":1690985276,
   "expires":1691028476,
   "event":"message",
   "topic":"test",
   "message":"testing"
    "extras": {
        "customField": "value"
    }
}

Then, after data = resp.json(), you could access the custom value at data.extras.customField

Why not do this?

{ 
   "id":"fajyTv5FQ0iM",
   "time":1690985276,
   "expires":1691028476,
   "event":"message",
   "topic":"test",
   "message":"\"{\"message\": \"testing\", \"customField\": \"value\"}\""
}

Then, after data = resp.json().message.json(), you could access the custom value at data.customField, right?

from ntfy.

tka85 avatar tka85 commented on June 8, 2024

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 message that has very specific semantics, is a hackey workaround.

from ntfy.

wunter8 avatar wunter8 commented on June 8, 2024

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 extras field where they can put additional information instead.

I will see if I can implement this sometime this week.

from ntfy.

tka85 avatar tka85 commented on June 8, 2024

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.

from ntfy.

tka85 avatar tka85 commented on June 8, 2024

@wunter8 I see the fix. Would it be possible to also get arrays to be allowed values inside the extras object?

from ntfy.

tka85 avatar tka85 commented on June 8, 2024

Any update on this?

from ntfy.

wunter8 avatar wunter8 commented on June 8, 2024

Nope. Sorry. I've been busy with work and haven't been able to finish the Android side of things yet

from ntfy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.