Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom json issue #541

Closed
bitching opened this issue Mar 13, 2022 · 10 comments
Closed

custom json issue #541

bitching opened this issue Mar 13, 2022 · 10 comments
Labels

Comments

@bitching
Copy link

bitching commented Mar 13, 2022

Question
i'm using changedetection.io which uses apprise as notification backend.
i noticed custom json is sent in a fixed structure like this:

{
   "version": "1.0",
   "title": "Some Title",
   "message": "Some Message",
   "type": "info"
}

my question is:
Can i send a custom json structure?
Please tell me how if yes.

like this:

{
   "title": "Some Title",
   "body": "Some Body",
   "device_key": "Some Key",
   "level": "Some Level",
   "sound": "Some Sound",
   "group": "Some Group",
   "isArchive": true
   maybe some more custom k/v bla.. bla.. bla...
}
@dgtlmoon
Copy link
Contributor

I already told you in our forums about this, you just set it in the request body

@caronc please close this imho

@bitching
Copy link
Author

I already told you in our forums about this, you just set it in the request body

@caronc please close this imho

i actually did.
but it's packed in "message"
sdfsdf

@caronc
Copy link
Owner

caronc commented Mar 13, 2022

I don't mind adding support for this if you like.
If you see this here, i did something similar for the FORM posting.

Basically if you're URL looked like this (leveraging colon (:) as the key to create your own entry, you could define it's key/value setup.

e.g:

  • json://localhost/?:key=value&:sound=chime would pass:
    { 
       "title": "<title from payload>",
       "message": "<message from payload>",
       "sound": "chime",
       "key": "value"
       ...
       }

If you were to specify a value used by the system... such as ?title=new-title you would over-ride the one that was otherwise passed in via the payload of the notification.

Would something like that be useful at all to you? Whatever you define is somewhat static; the variable paramters are still title, type, and message at the end of the day, but this way gets you the ability to add to the payload being pushed upstream from the Apprise URL you define.

@bitching

This comment was marked as outdated.

@bitching
Copy link
Author

Would something like that be useful at all to you? Whatever you define is somewhat static; the variable paramters are still title, type, and message at the end of the day, but this way gets you the ability to add to the payload being pushed upstream from the Apprise URL you define.

Hi, maybe take a look at this:
https://github.com/Finb/bark-server/blob/master/docs/API_V2.md
https://apps.apple.com/app/id1403753865

Bark is a secure & privacy-protected push tool, it's kinda popular in china.
it allows you to push customed notifications to your iPhone.
and it can be self-hosted, so the content are exposed only to the self-hosted server and Apple's APNS server.

so in changedetection.io
title can be Notification Title
body can be Notification Body

@caronc
Copy link
Owner

caronc commented Mar 20, 2022

Custom Payload has been implemented; maybe you could just test it out for me? The instructions on how to use (including test) it are in the Pull request itself.

As per your Bark Notifications reference; that's a bit off topic from this particular branch, but i went ahead and created a separate ticket for you regarding that.

@EsEnZeT
Copy link

EsEnZeT commented Apr 3, 2022

@caronc

Tested using custom build of changedetection.io (included link to git for apprise in requirements.txt) and it works, but in my case i'ts not solving problem because I need to send structure like this:

'{"version": "1.0", "title": "blah_and_other_apprise_params", "message": "blah", "number": "+22555443322", "recipients": [ "+22555443322" ]}'

and by using the new apprise implementation it's sending it like this:
2022-04-03 22:25:48,232 - DEBUG - JSON Payload: {'version': '1.0', 'title': 'ChangeDetection.io Notification - Test from changedetection.io!', 'message': 'blah', 'attachments': [], 'type': 'info', 'number': '+22555443322', 'recipients': '["+22555443322"]'}

Notice how 'recipients' array is incorrectly parsed as string.

Any ideas how to pass parameters properly?

I'm sending request like this:

json://signal:8080/v2/send/?:number=%2B22555443322&:recipients=%5B%22%2B22555443322%22%5D

From what I understood this would need slight change to code to be able to parse [] properly and don't quote them as a string.

@caronc
Copy link
Owner

caronc commented Apr 10, 2022

The payload that you pass in was never intended to be converted into a JSON Array; just like the payload can't convert the word 'false' to an actual JSON False variable or null. Numerical input is also just passed as a string too.

To accommodate this request, I'd almost have to add a ?kwargs_format=json or something as an additional variable so that after it parses your GET Parameters, it passes it through a JSON parser. I'd have to think more about your request here unfortunately.

@caronc
Copy link
Owner

caronc commented Apr 28, 2022

I'm kind of siding with @dgtlmoon at this point. I'm not sure how much more granular we should get here. Apprise meant to relay data to any end-point you want.

The custom JSON endpoint is already pretty feature rich now; especially with the last merge request that allows you to complete mangle the payload. I don't think what you're pitching is a terrible idea, but i don't see value in focusing in on it because i just don't see anyone getting value out of it but you 😉 . Unless there is actually more demand, i think we should leave this very extend customization i already added as your solution. If you want to make PR to enhance it, i certainly will entertain it.

@caronc
Copy link
Owner

caronc commented May 1, 2022

Closing this issue off; will focus on Bark Notification Support next

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants