diff --git a/docs/using-overseerr/notifications/webhooks.md b/docs/using-overseerr/notifications/webhooks.md index d1e912840..c99f7c0fe 100644 --- a/docs/using-overseerr/notifications/webhooks.md +++ b/docs/using-overseerr/notifications/webhooks.md @@ -31,17 +31,41 @@ Customize the JSON payload to suit your needs. Overseerr provides several [templ ### User -These variables are usually the target user of the notification. +These variables are for the target recipient of the notification. - `{{notifyuser_username}}` Target user's username. -- `{{notifyuser_email}}` Target user's email. -- `{{notifyuser_avatar}}` Target user's avatar. -- `{{notifyuser_settings_discordId}}` Target user's discord ID (if one is set). -- `{{notifyuser_settings_telegramChatId}}` Target user's telegram Chat ID (if one is set). +- `{{notifyuser_email}}` Target user's email address. +- `{{notifyuser_avatar}}` Target user's avatar URL. +- `{{notifyuser_settings_discordId}}` Target user's Discord ID (if one is set). +- `{{notifyuser_settings_telegramChatId}}` Target user's Telegram Chat ID (if one is set). -### Media +{% hint style="info" %} +The `notifyuser` variables are not set for the following notification types, as they are intended for application administrators rather than end users: + +- Media Requested +- Media Automatically Approved +- Media Failed + +On the other hand, the `notifyuser` variables _will_ be replaced with the requesting user's information for the below notification types: + +- Media Approved +- Media Declined +- Media Available + +If you would like to use the requesting user's information in your webhook, please instead include the relevant variables from the [Request](#request) section below. +{% endhint %} + +### Special + +The following variables must be used as a key in the JSON payload (e.g., `"{{extra}}": []`). -These variables are only included in media related notifications, such as requests. +- `{{request}}` This object will be `null` if there is no relevant request object for the notification. +- `{{media}}` This object will be `null` if there is no relevant media object for the notification. +- `{{extra}}` This object will contain the "extra" array of additional data for certain notifications. + +#### Media + +These `{{media}}` special variables are only included in media-related notifications, such as requests. - `{{media_type}}` Media type. Either `movie` or `tv`. - `{{media_tmdbid}}` Media's TMDb ID. @@ -50,10 +74,13 @@ These variables are only included in media related notifications, such as reques - `{{media_status}}` Media's availability status (e.g., `AVAILABLE` or `PENDING`). - `{{media_status4k}}` Media's 4K availability status (e.g., `AVAILABLE` or `PENDING`). -### Special +#### Request -The following variables must be used as a key in the JSON payload (e.g., `"{{extra}}": []`). +The `{{request}}` special variables are only included in request-related notifications. -- `{{request}}` This object will be `null` if there is no relevant request object for the notification. -- `{{media}}` This object will be `null` if there is no relevant media object for the notification. -- `{{extra}}` This object will contain the "extra" array of additional data for certain notifications. +- `{{request_id}}` Request ID. +- `{{requestedBy_username}}` Requesting user's username. +- `{{requestedBy_email}}` Requesting user's email address. +- `{{requestedBy_avatar}}` Requesting user's avatar URL. +- `{{requestedBy_settings_discordId}}` Requesting user's Discord ID (if one is set). +- `{{requestedBy_settings_telegramChatId}}` Requesting user's Telegram Chat ID (if one is set). diff --git a/server/lib/notifications/agents/webhook.ts b/server/lib/notifications/agents/webhook.ts index fa3058fe9..b5c989233 100644 --- a/server/lib/notifications/agents/webhook.ts +++ b/server/lib/notifications/agents/webhook.ts @@ -30,6 +30,12 @@ const KeyMap: Record = { media_status4k: (payload) => payload.media?.status ? MediaStatus[payload.media?.status4k] : '', request_id: 'request.id', + requestedBy_username: 'request.requestedBy.displayName', + requestedBy_email: 'request.requestedBy.email', + requestedBy_avatar: 'request.requestedBy.avatar', + requestedBy_settings_discordId: 'request.requestedBy.settings.discordId', + requestedBy_settings_telegramChatId: + 'request.requestedBy.settings.telegramChatId', }; class WebhookAgent diff --git a/server/lib/settings.ts b/server/lib/settings.ts index 6e1009c9c..bb82c7ef9 100644 --- a/server/lib/settings.ts +++ b/server/lib/settings.ts @@ -297,7 +297,7 @@ class Settings { webhookUrl: '', authHeader: '', jsonPayload: - 'IntcbiAgICBcIm5vdGlmaWNhdGlvbl90eXBlXCI6IFwie3tub3RpZmljYXRpb25fdHlwZX19XCIsXG4gICAgXCJzdWJqZWN0XCI6IFwie3tzdWJqZWN0fX1cIixcbiAgICBcIm1lc3NhZ2VcIjogXCJ7e21lc3NhZ2V9fVwiLFxuICAgIFwiaW1hZ2VcIjogXCJ7e2ltYWdlfX1cIixcbiAgICBcImVtYWlsXCI6IFwie3tub3RpZnl1c2VyX2VtYWlsfX1cIixcbiAgIC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kXCI6IFwie3ttZWRpYV9pbWRiaWR9fVwiLFxuICAgICAgICBcInR2ZGJJZFwiOiBcInt7bWVkaWFfdHZkYmlkfX1cIixcbiAgICAgICAgXCJzdGF0dXNcIjogXCJ7e21lZGlhX3N0YXR1c319XCIsXG4gICAgICAgIFwic3RhdHVzNGtcIjogXCJ7e21lZGlhX3N0YXR1czRrfX1cIlxuICAgIH0sXG4gICAgXCJ7e2V4dHJhfX1cIjogW10sXG4gICAgXCJ7e3JlcXVlc3R9fVwiOiB7XG4gICAgICAgIFwicmVxdWVzdF9pZFwiOiBcInt7cmVxdWVzdF9pZH19XCIsXG4gICAgICAgIFwicmVxdWVzdGVkQnlfZW1haWxcIjogXCJ7e3JlcXVlc3RlZEJ5X2VtYWlsfX1cIixcbiAgICAgICAgXCJyZXF1ZXN0ZWRCeV91c2VybmFtZVwiOiBcInt7cmVxdWVzdGVkQnlfdXNlcm5hbWV9fVwiLFxuICAgICAgICBcInJlcXVlc3RlZEJ5X2F2YXRhclwiOiBcInt7cmVxdWVzdGVkQnlfYXZhdGFyfX1cIlxuICAgIH1cbn0i', }, }, }, diff --git a/src/components/Settings/Notifications/NotificationsWebhook/index.tsx b/src/components/Settings/Notifications/NotificationsWebhook/index.tsx index ab71a2045..a2da3cbf8 100644 --- a/src/components/Settings/Notifications/NotificationsWebhook/index.tsx +++ b/src/components/Settings/Notifications/NotificationsWebhook/index.tsx @@ -32,6 +32,9 @@ const defaultPayload = { '{{extra}}': [], '{{request}}': { request_id: '{{request_id}}', + requestedBy_email: '{{requestedBy_email}}', + requestedBy_username: '{{requestedBy_username}}', + requestedBy_avatar: '{{requestedBy_avatar}}', }, };