jellyfin / jellyfin-plugin-webhook

GNU General Public License v3.0
141 stars 45 forks source link

Adding Discord webhook overrides Username in POST #239

Open r3d007 opened 4 months ago

r3d007 commented 4 months ago

Hi!

When enabling a Discord webhook for NotificationType 'AuthenticationFailure', you get an incorrect Username from the server. When User: zzz uses an incorrect password, the Username from the Discord Webhook ("Webhook Username") shows up in the POST from the server.

[23:16:47] [WRN] [17] Jellyfin.Plugin.Webhook.Destinations.Generic.GenericClient: Notification failed with POST request to https://api.telegram.org/XXX/sendMessage: {"ServerId":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","ServerName":"vetinari","ServerVersion":"10.9.1","ServerUrl":"https://my.server.com","NotificationType":"AuthenticationFailure","App":"Jellyfin Web","Username":"Jellyfin Bot","UserId":"00000000000000000000000000000000","AppVersion":"10.9.1","DeviceId":".....","DeviceName":"Chrome","MentionType":"","EmbedColor":697804,"AvatarUrl":"xxx","BotUsername":"Jellyfin `Bot","chat_id":"XXX"}

image

Is the NotificationType 'AuthenticationFailure' deactivated in the Discord Webhook, the POST from the server looks like this. (What is correct, username is 'zzz')

[23:17:18] [WRN] [44] Jellyfin.Plugin.Webhook.Destinations.Generic.GenericClient: Notification failed with POST request to https://api.telegram.org/XXX/sendMessage: {"ServerId":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","ServerName":"vetinari","ServerVersion":"10.9.1","ServerUrl":"https://my.server.com","NotificationType":"AuthenticationFailure","App":"Jellyfin Web","Username":"zzz","UserId":"00000000000000000000000000000000","AppVersion":"10.9.1","DeviceId":".....","DeviceName":"Chrome","chat_id":"XXX"}

image

I use a Telegram Webhook for testing, thats why it is in the log.

crobibero commented 4 months ago

Please provide the template that you are using

r3d007 commented 4 months ago
{
    "content": "{{MentionType}}",
    "avatar_url": "{{AvatarUrl}}",
    "username": "{{BotUsername}}",
    "embeds": [
        {
            "author": { 
                {{#if_equals NotificationType 'AuthenticationFailure'}}
                   "name": "!!!PASSWORD!!!",
                {{/if_equals}}
                "url": "{{ServerUrl}}/web/"
            },

            "description": "{{#if_equals NotificationType 'AuthenticationFailure'}}>User: {{Username}} entered incorrect password.\nApp: {{App}}\nDevice: {{DeviceName}}{{/if_equals}}",
            "color": "3394611",
            "footer": {
                "text": "{{ServerName}}",
                "icon_url": "{{AvatarUrl}}"
            },

            "timestamp": "{{Timestamp}}"
        }
    ]
}

This template works when using in a generic webhook configured to use Discord.