jellyfin / jellyfin-plugin-webhook

GNU General Public License v3.0
148 stars 46 forks source link

Authentication Failure Discord Notification Type overwrites the {{Username}} Variable #276

Open Nicsena opened 1 month ago

Nicsena commented 1 month ago

I am using the Discord Destination Option in Jellyfin Webhook with Authentication Success, and Authentication Failure Notification Types. I am using Jellyfin Server Version: v10.9.6 with Webhook Plugin 14.0.0.0 (from the Stable Jellyfin Repo).

When Authentication Failure occurs, the {{Username}} variable shows the Webhook Username that was specified in settings instead of a user's username.

My template:

{
    "content": "{{MentionType}}",
    "username": "{{BotUsername}}",
    "embeds": [
        {
            {{#if_equals NotificationType 'AuthenticationSuccess'}}
                "title": "User - New Login",
            {{else}}
                {{#if_equals NotificationType 'AuthenticationFailure'}}
                    "title": "User - Login Failed",
                {{else}}
                    "title": "Unsupported Notification Type",
                {{/if_equals}}
            {{/if_equals}}

            {{#if_equals NotificationType 'AuthenticationSuccess'}}
                "description": "User Authentication - Success",
            {{else}}
                {{#if_equals NotificationType 'AuthenticationFailure'}}
                    "description": "User Authentication - Failed",
                {{else}}
                    "description": "Unsupported Notification Type",
                {{/if_equals}}
            {{/if_equals}}

            {{#if_equals NotificationType 'AuthenticationSuccess'}}
            "fields": [
                    {
                        "name": "Username",
                        "value": "{{NotificationUsername}}",
                        "inline": false
                    },
                    {
                        "name": "Last Login",
                        "value": "{{LastLoginDate}}",
                        "inline": true
                    },
                    {
                        "name": "Last Activity",
                        "value": "{{LastActivityDate}}",
                        "inline": true
                    }
                ],
            {{else}}
                {{#if_equals NotificationType "AuthenticationFailure"}}
                    "fields": [
                        {
                            "name": "Username",
                            "value": "{{Username}}",
                            "inline": false
                        }
                    ],
                {{/if_equals}}
            {{/if_equals}}
            "color": {{#if_equals NotificationType 'AuthenticationSuccess'}} 3329857 {{else}} {{#if_equals NotificationType "AuthenticationFailure" }} 15286079 {{else}} {{EmbedColor}} {{/if_equals}} {{/if_equals}},
            "footer": {
                "text": "{{ServerName}} | Jellyfin Server v{{ServerVersion}}"
            }
        }
    ]
}

Images:

Webhook Settings Screen:

Screenshot 2024-09-05 at 7 45 17 PM

Login Screen:

Screenshot 2024-09-05 at 7 37 34 PM

Discord Notification is not showing the username (user), but instead is showing the specified Webhook Username.

Screenshot 2024-09-05 at 7 33 19 PM
crobibero commented 1 month ago

Yeah I had realized that a while back so "NotificationUsername" was added. See if that works for you

Nicsena commented 1 month ago

Yeah I had realized that a while back so "NotificationUsername" was added. See if that works for you

It doesn't work. {{NotificationUsername}} returns blank when Authentication Failure occurs.

I also tried this with a new Jellyfin server installation that's running on my main computer just for this github issue.

image

nylimited commented 1 month ago

Yeah I had realized that a while back so "NotificationUsername" was added. See if that works for you

Thanks for that! Will try it here also. As far as you know, is there a comprehensive list of these variables someplace that I could reference and have no located yet?

crobibero commented 1 month ago

All variables are listed in the repo readme.

nylimited commented 1 month ago

All variables are listed in the repo readme.

Thanks you. I obviously missed it somehow... my bad.