binwiederhier / ntfy

Send push notifications to your phone or desktop using PUT/POST
https://ntfy.sh
Apache License 2.0
18.66k stars 734 forks source link

Overseerr JSON Fails with webook field email in payload body #1010

Open undaunt opened 10 months ago

undaunt commented 10 months ago

:lady_beetle: Describe the bug When attempting to test notifications from Overseerr to ntfy, if the line "email": "{{notifyuser_email}}", is included in the webhook template, ntfy responds with an error that email notifications are not enabled.

:computer: Components impacted ntfy server

:bulb: Screenshots and/or logs Error sending webhook notification {"type":"TEST_NOTIFICATION","subject":"Test Notification","errorMessage":"Request failed with status code 400","response":{"code":40001,"http":400,"error":"e-mail notifications are not enabled","link":"https://ntfy.sh/docs/config/#e-mail-notifications"}}

:crystal_ball: Additional context If I modify the template from the following:

{
    "topic": "mytopic",
    "notification_type": "{{notification_type}}",
    "subject": "{{subject}}",
    "message": "{{message}}",
    "image": "{{image}}",
    "email": "{{notifyuser_email}}",
    "username": "{{notifyuser_username}}",
    "avatar": "{{notifyuser_avatar}}",
    "{{media}}": {
        "media_type": "{{media_type}}",
        "tmdbId": "{{media_tmdbid}}",
        "imdbId": "{{media_imdbid}}",
        "tvdbId": "{{media_tvdbid}}",
        "status": "{{media_status}}",
        "status4k": "{{media_status4k}}"
    },
    "{{extra}}": []
}

to this

{
    "topic": "mytopic",
    "notification_type": "{{notification_type}}",
    "subject": "{{subject}}",
    "message": "{{message}}",
    "image": "{{image}}",
    "username": "{{notifyuser_username}}",
    "avatar": "{{notifyuser_avatar}}",
    "{{media}}": {
        "media_type": "{{media_type}}",
        "tmdbId": "{{media_tmdbid}}",
        "imdbId": "{{media_imdbid}}",
        "tvdbId": "{{media_tvdbid}}",
        "status": "{{media_status}}",
        "status4k": "{{media_status4k}}"
    },
    "{{extra}}": []
}

then it works without issue. For reference, my URL is https://ntfy.domain.com/?auth=bearertoken

wunter8 commented 10 months ago

It sounds like you didn't enable email notifications on your server

https://docs.ntfy.sh/config/#e-mail-notifications

undaunt commented 10 months ago

@wunter8 I'm attempting to post a JSON webhook to ntfy from Overseerr, nothing to do with emails. The templated email line above refers to the fact that my user record in Overseerr has an email. That's why I'm wondering if there's something in the code that makes ntfy think I want to send/receive an email when I do not, based on the JSON payload field name.

wunter8 commented 10 months ago

Since you're including an "email" field in the JSON body, ntfy thinks you want to forward the notification to that email address

I would expect both of the JSON bodies you posted above to fail, though, because right now ntfy will reject unknown fields (such as notification_type, username, avatar, etc.)