From 8015841d1aad12254602ebcefa83f65a154b21b8 Mon Sep 17 00:00:00 2001 From: Manuel <30572287+manuel-rw@users.noreply.github.com> Date: Sun, 7 Jan 2024 21:10:45 +0100 Subject: [PATCH] docs: add all in one pushover template (#212) --- .../Templates/Pushover/AllInOne.handlebars | 108 ++++++++++++++++++ .../Templates/Pushover/README.md | 55 +++++++++ 2 files changed, 163 insertions(+) create mode 100644 Jellyfin.Plugin.Webhook/Templates/Pushover/AllInOne.handlebars create mode 100644 Jellyfin.Plugin.Webhook/Templates/Pushover/README.md diff --git a/Jellyfin.Plugin.Webhook/Templates/Pushover/AllInOne.handlebars b/Jellyfin.Plugin.Webhook/Templates/Pushover/AllInOne.handlebars new file mode 100644 index 0000000..7b50e53 --- /dev/null +++ b/Jellyfin.Plugin.Webhook/Templates/Pushover/AllInOne.handlebars @@ -0,0 +1,108 @@ +{ + {{! All in one Webhook template for Jellyfin Media server }} + {{! Written by https://github.com/manuel-rw. Read instructions for usage. }} + {{! Be friendly to the API: https://pushover.net/api#friendly. Use https://webhook.site/ to debug. }} + + "token": "{{Token}}", + "user": "{{UserToken}}", + "title": "Notification from {{ServerName}} ({{ServerVersion}})", + "url": "{{ServerUrl}}/web/index.html#!/details?id={{ItemId}}&serverId={{ServerId}}", + + {{#if_equals NotificationType 'Generic'}} + "message": "{{Name}}" + {{else}} + {{#if_equals NotificationType 'ItemAdded'}} + {{#if_equals ItemType 'Season'}} + "body": "{{{SeriesName}}} {{{Name}}} has been added to {{{ServerName}}}" + {{else}} + {{#if_equals ItemType 'Episode'}} + "body": "{{{SeriesName}}} S{{SeasonNumber00}}E{{EpisodeNumber00}} {{{Name}}} has been added to {{{ServerName}}}" + {{else}} + "body": "{{{Name}}} ({{Year}}) has been added to {{{ServerName}}}" + {{/if_equals}} + {{/if_equals}} + {{else}} + {{#if_equals NotificationType 'UserPasswordChanged'}} + "message": "The password for the user '{{NotificationUsername}}' has been changed" + {{else}} + {{#if_equals NotificationType 'PlaybackStart'}} + "message": "{{NotificationUsername}} started playback of {{{SeriesName}}} S{{SeasonNumber00}}E{{EpisodeNumber00}} {{{Name}}} on {{DeviceName}} with {{ClientName}}" + {{else}} + {{#if_equals NotificationType 'PlaybackStop'}} + "message": "{{NotificationUsername}} stopped playback of {{{SeriesName}}} S{{SeasonNumber00}}E{{EpisodeNumber00}} {{{Name}}} on {{DeviceName}} with {{ClientName}}" + {{else}} + {{#if_equals NotificationType 'PlaybackProgress'}} + "message": "Playback position for client '{{ClientName}}': {{PlaybackPosition}}" + {{else}} + {{#if_equals NotificationType 'PluginInstalling'}} + "message": "Installing plugin {{PluginName}} version {{PluginVersion}}..." + {{else}} + {{#if_equals NotificationType 'PluginInstalled'}} + "message": "Plugin '{{PluginName}}' ({{PluginVersion}}) has been installed. A restart may be required" + {{else}} + {{#if_equals NotificationType 'PluginUninstalled'}} + "message": "Plugin '{{PluginName}}' ({{PluginVersion}}) has been uninstalled. A restart may be required" + {{else}} + {{#if_equals NotificationType 'PluginUpdated'}} + "message": "Plugin '{{PluginName}}' ({{PluginVersion}}) has been updated. A restart may be required" + {{else}} + {{#if_equals NotificationType 'PluginInstallationCancelled'}} + "message": "Installation of plugin '{{PluginName}}' ({{PluginVersion}}) has been cannceled." + {{else}} + {{#if_equals NotificationType 'PluginInstallationFailed'}} + "message": "Installation of plugin '{{PluginName}}' ({{PluginVersion}}) has failed: {{ExceptionMessage}}" + {{else}} + {{#if_equals NotificationType 'UserCreated'}} + "message": "A new user '{{NotificationUsername}}' was created on your server {{ServerName}}" + {{else}} + {{#if_equals NotificationType 'UserDeleted'}} + "message": "message": "The user '{{NotificationUsername}}' has been deleted on {{ServerName}}" + {{else}} + {{#if_equals NotificationType 'UserLockedOut'}} + "message": "The user '{{NotificationUsername}}' has been locked out because they exceeded the allowed incorrect login attempts." + {{else}} + {{#if_equals NotificationType 'UserPasswordChanged'}} + "message": "The password for the user '{{NotificationUsername}}' has been changed" + {{else}} + {{#if_equals NotificationType 'UserPasswordChanged'}} + "message": "The password for the user '{{NotificationUsername}}' has been changed" + {{else}} + {{#if_equals NotificationType 'AuthenticationFailure'}} + "message": "An attempt to authenticate for account '{{Username}}' has failed" + {{else}} + {{#if_equals NotificationType 'AuthenticationFailure'}} + "message": "'{{NotificationUsername}}' has authenticated successfully. Last logged in on {{LastLoginDate}}" + {{else}} + {{#if_equals NotificationType 'TaskCompleted'}} + "message": "Task '{{TaskName}}' has completed with status {{ResultStatus}}." + {{else}} + {{#if_equals NotificationType 'SessionStart'}} + "message": "Session for '{{NotificationUsername}}' has started on device {{DeviceName}}" + {{else}} + {{#if_equals NotificationType 'PendingRestart'}} + "message": "{{ServerName}} requires a restart" + {{else}} + "message": "The handlebars template received an unknown notification with type '{{NotificationType}}'. An administrator may need to remove this notification type or adjust the template." + {{/if_equals}} + {{/if_equals}} + {{/if_equals}} + {{/if_equals}} + {{/if_equals}} + {{/if_equals}} + {{/if_equals}} + {{/if_equals}} + {{/if_equals}} + {{/if_equals}} + {{/if_equals}} + {{/if_equals}} + {{/if_equals}} + {{/if_equals}} + {{/if_equals}} + {{/if_equals}} + {{/if_equals}} + {{/if_equals}} + {{/if_equals}} + {{/if_equals}} + {{/if_equals}} + {{/if_equals}} +} \ No newline at end of file diff --git a/Jellyfin.Plugin.Webhook/Templates/Pushover/README.md b/Jellyfin.Plugin.Webhook/Templates/Pushover/README.md new file mode 100644 index 0000000..3382a34 --- /dev/null +++ b/Jellyfin.Plugin.Webhook/Templates/Pushover/README.md @@ -0,0 +1,55 @@ +# Pushover Templates + +## Supported notification types + +- Authentication Failure +- Authentication Success +- Generic +- Item added +- Pending restart +- Playback progress +- Playback start +- Playback stop +- Plugin installation cancelled +- Plugin installation failed +- Plugin installed +- Plugin installing +- Plugin uninstalled +- Plugin updated +- Session started +- Task completed +- User created +- User deleted +- User locked out +- User password changed + +## Usage + +1. Click on the Webhook plugin +2. Click on ``Add Generic`` +3. Enter a name +4. Enter https://api.pushover.net/1/messages.json as a Webhook URL +5. Check your desired notification types +6. Paste the desired template (recommended is [All in One](./AllInOne.handlebars)) +7. Add request header (Key: ``Content-Type``, Value: ``application/json``) +8. Add field (Key: ``Token``, Value: **Your Pushover application token**) +9. Add field (Key: ``UserToken``, Value: **Your Pushover user key**) +10. Click ``Save`` + +## Debug +To debug, you can use https://webhook.site. Ensure that the server can resolve the hostname. + +1. Go to https://webhook.site. **Never leave this page during debugging**. +2. Copy the webhook URL, ending with a random UID +3. Replace the ``Webhook URL`` to this URL +4. Press ``Save`` +5. (Optional): Set up XHR Redirec to Pushover (can help with validation problems): + - Go to your webhook debugging page again. + - Click ``Settings...`` besides ``XHR Redirect`` in the top navigation bar + - Enter ``https://api.pushover.net/1/messages.json`` as the target + - Enter ``application/json`` as the content type + - Select ``POST`` as the ``HTTP Method`` + - Press ``Close`` + - Ensure that ``XHR Redirect`` in the navbar is checked + - Press ``CTRL`` + ``SHIFT`` + ``I``, click on ``Network`` and enter ``api.pushover`` in the filter field. + - Any failed / successful notifications will appear here now. Your client will be used as the XHR redirect.