C9Glax / tranga

Docker-Container to monitor (Manga) Scanlation-Sites for download new chapters.
GNU General Public License v3.0
108 stars 10 forks source link

[It broke]: NTFY notifications #183

Closed mgrimace closed 3 weeks ago

mgrimace commented 1 month ago

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

C9Glax commented 3 weeks ago

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 commented 3 weeks ago

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 commented 3 weeks ago

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 commented 3 weeks ago

From https://github.com/C9Glax/tranga/issues/186#issuecomment-2143609208 [{"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.

https://github.com/C9Glax/tranga/commit/ebe3012c694ea1006b2fae995007f90287e87c8c 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 commented 3 weeks ago

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 commented 3 weeks ago

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

C9Glax commented 3 weeks ago

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 commented 3 weeks ago

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!

C9Glax commented 3 weeks ago

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

mgrimace commented 3 weeks ago

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

Confirmed working on my end at /manga!

C9Glax commented 3 weeks ago

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