diff --git a/server/entity/MediaRequest.ts b/server/entity/MediaRequest.ts index e5c993679..09a806804 100644 --- a/server/entity/MediaRequest.ts +++ b/server/entity/MediaRequest.ts @@ -88,6 +88,7 @@ export class MediaRequest { message: movie.overview, image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${movie.poster_path}`, notifyUser: this.requestedBy, + media, }); } @@ -98,6 +99,7 @@ export class MediaRequest { message: tv.overview, image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${tv.poster_path}`, notifyUser: this.requestedBy, + media, extra: [ { name: 'Seasons', @@ -136,6 +138,7 @@ export class MediaRequest { message: movie.overview, image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${movie.poster_path}`, notifyUser: this.requestedBy, + media, }); } else if (this.media.mediaType === MediaType.TV) { const tv = await tmdb.getTvShow({ tvId: this.media.tmdbId }); @@ -144,6 +147,7 @@ export class MediaRequest { message: tv.overview, image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${tv.poster_path}`, notifyUser: this.requestedBy, + media, extra: [ { name: 'Seasons', diff --git a/server/lib/notifications/agents/agent.ts b/server/lib/notifications/agents/agent.ts index d04cabf08..98daf106d 100644 --- a/server/lib/notifications/agents/agent.ts +++ b/server/lib/notifications/agents/agent.ts @@ -1,10 +1,12 @@ import { Notification } from '..'; +import Media from '../../../entity/Media'; import { User } from '../../../entity/User'; import { NotificationAgentConfig } from '../../settings'; export interface NotificationPayload { subject: string; notifyUser: User; + media?: Media; image?: string; message?: string; extra?: { name: string; value: string }[]; diff --git a/server/lib/notifications/agents/discord.ts b/server/lib/notifications/agents/discord.ts index 08239980e..a0df2c4c3 100644 --- a/server/lib/notifications/agents/discord.ts +++ b/server/lib/notifications/agents/discord.ts @@ -93,7 +93,8 @@ class DiscordAgent type: Notification, payload: NotificationPayload ): DiscordRichEmbed { - let color = EmbedColors.DEFAULT; + const settings = getSettings(); + let color = EmbedColors.DARK_PURPLE; const fields: Field[] = []; @@ -112,6 +113,13 @@ class DiscordAgent inline: true, } ); + + if (settings.main.applicationUrl) { + fields.push({ + name: 'View Media', + value: `${settings.main.applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}`, + }); + } break; case Notification.MEDIA_APPROVED: color = EmbedColors.PURPLE; @@ -127,6 +135,13 @@ class DiscordAgent inline: true, } ); + + if (settings.main.applicationUrl) { + fields.push({ + name: 'View Media', + value: `${settings.main.applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}`, + }); + } break; case Notification.MEDIA_AVAILABLE: color = EmbedColors.GREEN; @@ -142,6 +157,13 @@ class DiscordAgent inline: true, } ); + + if (settings.main.applicationUrl) { + fields.push({ + name: 'View Media', + value: `${settings.main.applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}`, + }); + } break; } @@ -150,7 +172,7 @@ class DiscordAgent description: payload.message, color, timestamp: new Date().toISOString(), - author: { name: 'Overseerr' }, + author: { name: 'Overseerr', url: settings.main.applicationUrl }, fields: [ ...fields, // If we have extra data, map it to fields for discord notifications diff --git a/server/lib/notifications/agents/email.ts b/server/lib/notifications/agents/email.ts index 354a5150e..6af5b37c7 100644 --- a/server/lib/notifications/agents/email.ts +++ b/server/lib/notifications/agents/email.ts @@ -89,7 +89,10 @@ class EmailAgent imageUrl: payload.image, timestamp: new Date().toTimeString(), requestedBy: payload.notifyUser.username, - actionUrl: applicationUrl, + actionUrl: applicationUrl + ? `${applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}` + : undefined, + applicationUrl, requestType: 'New Request', }, }); @@ -124,7 +127,10 @@ class EmailAgent imageUrl: payload.image, timestamp: new Date().toTimeString(), requestedBy: payload.notifyUser.username, - actionUrl: applicationUrl, + actionUrl: applicationUrl + ? `${applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}` + : undefined, + applicationUrl, requestType: 'Request Approved', }, }); @@ -158,7 +164,10 @@ class EmailAgent imageUrl: payload.image, timestamp: new Date().toTimeString(), requestedBy: payload.notifyUser.username, - actionUrl: applicationUrl, + actionUrl: applicationUrl + ? `${applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}` + : undefined, + applicationUrl, requestType: 'Now Available', }, }); @@ -185,7 +194,7 @@ class EmailAgent }, locals: { body: payload.message, - actionUrl: applicationUrl, + applicationUrl, }, }); return true; diff --git a/server/subscriber/MediaSubscriber.ts b/server/subscriber/MediaSubscriber.ts index f63b14f64..fe826284c 100644 --- a/server/subscriber/MediaSubscriber.ts +++ b/server/subscriber/MediaSubscriber.ts @@ -29,6 +29,7 @@ export class MediaSubscriber implements EntitySubscriberInterface { notifyUser: request.requestedBy, subject: movie.title, message: movie.overview, + media: entity, image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${movie.poster_path}`, }); }); @@ -79,6 +80,7 @@ export class MediaSubscriber implements EntitySubscriberInterface { message: tv.overview, notifyUser: request.requestedBy, image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${tv.poster_path}`, + media: entity, extra: [ { name: 'Seasons', diff --git a/server/templates/email/media-request/html.pug b/server/templates/email/media-request/html.pug index f87537d63..5304d41b0 100644 --- a/server/templates/email/media-request/html.pug +++ b/server/templates/email/media-request/html.pug @@ -47,7 +47,7 @@ div(role='article' aria-roledescription='email' aria-label='' lang='en') padding-bottom: 25px;\ text-align: center;\ ') - a(href=actionUrl style='\ + a(href=applicationUrl style='\ text-shadow: 0 1px 0 #ffffff;\ font-weight: 700;\ font-size: 16px;\ @@ -92,7 +92,7 @@ div(role='article' aria-roledescription='email' aria-label='' lang='en') margin-bottom: 20px;\ color: #51545e;\ ') - a(href=actionUrl style='color: #3869d4') Open Overseerr + a(href=actionUrl style='color: #3869d4') Open Media in Overseerr tr td table.sm-w-full(align='center' style='\ diff --git a/server/templates/email/test-email/html.pug b/server/templates/email/test-email/html.pug index 46f4ca2cb..d9f6063db 100644 --- a/server/templates/email/test-email/html.pug +++ b/server/templates/email/test-email/html.pug @@ -47,7 +47,7 @@ div(role='article' aria-roledescription='email' aria-label='' lang='en') padding-bottom: 25px;\ text-align: center;\ ') - a(href=actionUrl style='\ + a(href=applicationUrl style='\ text-shadow: 0 1px 0 #ffffff;\ font-weight: 700;\ font-size: 16px;\ @@ -74,7 +74,7 @@ div(role='article' aria-roledescription='email' aria-label='' lang='en') margin-bottom: 20px;\ color: #51545e;\ ') - a(href=actionUrl style='color: #3869d4') Open Overseerr + a(href=applicationUrl style='color: #3869d4') Open Overseerr tr td table.sm-w-full(align='center' style='\