Skip to content

[It broke]: NTFY notifications #183

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

Closed
mgrimace opened this issue May 21, 2024 · 12 comments
Closed

[It broke]: NTFY notifications #183

mgrimace opened this issue May 21, 2024 · 12 comments
Assignees
Labels
bug Something isn't working

Comments

@mgrimace
Copy link

What is broken?

Two issues with NTFY:

  1. when I enter the url and my auth, I'm able to send a test message. However, after I hit 'apply', then try to test again, it never sends anything
  2. before hitting 'apply' my successful test notifcations appear as 'json' and not the actual expected formatting (see screenshot).

Screenshot 2024-05-21 at 1 00 38 PM

Log-output

[05/21/2024 13:31:11.653]          Ntfy | Creating notificationConnector Ntfy
[05/21/2024 13:31:11.653]          Ntfy | Sending notification: Tranga Test - This is Test-Notification.
[05/21/2024 13:31:11.801]          Ntfy | InternalServerError: {"code":50001,"http":500,"error":"internal server error"}

Additional stuff

No response

@mgrimace mgrimace added the bug Something isn't working label May 21, 2024
@C9Glax C9Glax self-assigned this May 22, 2024
@C9Glax
Copy link
Owner

C9Glax commented Jun 1, 2024

Okay from what I can see the notification is successfully pushed to the NTFY-Server, however the NTFY-Server has trouble parsing the message.
As URL, did you send the root URI of your NTFY-Server? e.g. https://ntfy.sh/ (correct), and not to https://ntfy.sh/mytopic (incorrect). (reference)
Additionally, can you check your NTFY-Server logs (reference), error 500 means that an internal error occured.

@C9Glax
Copy link
Owner

C9Glax commented Jun 1, 2024

As URL, did you send the root URI of your NTFY-Server? e.g. https://ntfy.sh/ (correct), and not to https://ntfy.sh/mytopic (incorrect). (reference)

Gonna add code to set your own topic.

@mgrimace
Copy link
Author

mgrimace commented Jun 1, 2024

Hi, ok, I don't 100% remember what I ended up using but I'll try again with a few combinations.
I believe I did use the /manga topic, and what I don't recall is whether I used basic auth, token, or webhook which is all-in the url AFAIK (e.g., https://ntfy.mydomain.com/manga/publish?auth=...). NTFY has a few strange requirements for base64 and doublebase64 encoded user:pass authorization depending on the method. I'll report back if I can replicate.

@C9Glax
Copy link
Owner

C9Glax commented Jun 1, 2024

From #186 (comment)
[{"notificationConnectorType":2,"endpoint":"https://ntfy.mydomain.com/manga"}]
It would seem that my suspicion on the base URI thing was correct as you had /manga set as topic, which I failed to handle in my code correctly. For the json publish to work, you had to push to the base URI.

ebe3012 should fix that. If you set the topic via /manga now, it should automatically set the topic correctly. (I now see another issue, gonna fix that real quick... don't update yet)

@mgrimace
Copy link
Author

mgrimace commented Jun 1, 2024

From #186 (comment) [{"notificationConnectorType":2,"endpoint":"https://ntfy.mydomain.com/manga"}] It would seem that my suspicion on the base URI thing was correct as you had /manga set as topic, which I failed to handle in my code correctly. For the json publish to work, you had to push to the base URI.

ebe3012 should fix that. If you set the topic via /manga now, it should automatically set the topic correctly. (I now see another issue, gonna fix that real quick... don't update yet)

Amazing, I'll test out the updates when they're ready and report back, no rush at all.

@mgrimace
Copy link
Author

mgrimace commented Jun 1, 2024

and I'm using Docker, what should I set the tags to (for tranga-api and tranga-website I'm currently on latest)?

@C9Glax
Copy link
Owner

C9Glax commented Jun 1, 2024

Okay it is building the image right now, you should be able to setup NTFY with
URL containing your NTFY-Server URL in the format http(s)://ntfy.server.url/<optional topic, default is tranga> and
Auth containing the base64 authParam.

authHeader = "Basic " + base64(username + ":" + password) // -> Basic dGVzdHVzZXI6ZmFrZXBhc3N3b3Jk
authParam  = base64_raw(authHeader) // -> QmFzaWMgZEdWemRIVnpaWEk2Wm1GclpYQmhjM04zYjNKaw (no trailing =)

Which is quite clunky right now admit, will open a seperate issue, to make that easier...

I recommend using cuttingedge as tag, as most issues are fixed on there.

@mgrimace
Copy link
Author

mgrimace commented Jun 1, 2024

Thanks again! As far as I can tell I broke the formatting through an accidental work-around by using the webhook url (which embeds the topic and auth). I hadn't gotten the right combination of no-topic and authparam authentication to get it working otherwise.

I tested it out with the no-topic (e.g., https://ntfy.mydomain.com) and the correct authparam authorization, and it's working as expected at /tranga. I'll test the custom topic once the image is up! Thanks also for making the login easier with #187 , it's difficult for a lay-person to understand the encoding (at least for me), and entering the user/pass should improve usability. Thanks so much for your work!

@mgrimace mgrimace closed this as completed Jun 1, 2024
@C9Glax
Copy link
Owner

C9Glax commented Jun 1, 2024

Image should be up for a few minutes already, so custom topic should also work 👍🏼

@mgrimace
Copy link
Author

mgrimace commented Jun 1, 2024

Image should be up for a few minutes already, so custom topic should also work 👍🏼

Confirmed working on my end at /manga!

@C9Glax
Copy link
Owner

C9Glax commented Jun 1, 2024

As a final favor, can you restart you container to see if the notificationConnectors.json file is working?

@HerrFrutti
Copy link

For me the Website never wrote to the notificationConnectors.json. After tinkering for ever I got it working, by creating the notificationConnectors.json manually:

[{"notificationConnectorType":2,"endpoint":"https://ntfy","auth":"authToken","topic":"topic"}]

I got my token using this (from: https://docs.ntfy.sh/publish/#query-param

echo -n "Basic `echo -n 'testuser:fakepassword' | base64`" | base64 | tr -d '='

and used the first string of the output.


This may be a problem with not modifying or creating the notificationConnectors.json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants