mirror of
https://github.com/sct/overseerr.git
synced 2025-09-17 17:24:35 +02:00
feat(notifications): include direct links to media in notifications
closes #437
This commit is contained in:
@@ -88,6 +88,7 @@ export class MediaRequest {
|
|||||||
message: movie.overview,
|
message: movie.overview,
|
||||||
image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${movie.poster_path}`,
|
image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${movie.poster_path}`,
|
||||||
notifyUser: this.requestedBy,
|
notifyUser: this.requestedBy,
|
||||||
|
media,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,6 +99,7 @@ export class MediaRequest {
|
|||||||
message: tv.overview,
|
message: tv.overview,
|
||||||
image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${tv.poster_path}`,
|
image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${tv.poster_path}`,
|
||||||
notifyUser: this.requestedBy,
|
notifyUser: this.requestedBy,
|
||||||
|
media,
|
||||||
extra: [
|
extra: [
|
||||||
{
|
{
|
||||||
name: 'Seasons',
|
name: 'Seasons',
|
||||||
@@ -136,6 +138,7 @@ export class MediaRequest {
|
|||||||
message: movie.overview,
|
message: movie.overview,
|
||||||
image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${movie.poster_path}`,
|
image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${movie.poster_path}`,
|
||||||
notifyUser: this.requestedBy,
|
notifyUser: this.requestedBy,
|
||||||
|
media,
|
||||||
});
|
});
|
||||||
} else if (this.media.mediaType === MediaType.TV) {
|
} else if (this.media.mediaType === MediaType.TV) {
|
||||||
const tv = await tmdb.getTvShow({ tvId: this.media.tmdbId });
|
const tv = await tmdb.getTvShow({ tvId: this.media.tmdbId });
|
||||||
@@ -144,6 +147,7 @@ export class MediaRequest {
|
|||||||
message: tv.overview,
|
message: tv.overview,
|
||||||
image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${tv.poster_path}`,
|
image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${tv.poster_path}`,
|
||||||
notifyUser: this.requestedBy,
|
notifyUser: this.requestedBy,
|
||||||
|
media,
|
||||||
extra: [
|
extra: [
|
||||||
{
|
{
|
||||||
name: 'Seasons',
|
name: 'Seasons',
|
||||||
|
@@ -1,10 +1,12 @@
|
|||||||
import { Notification } from '..';
|
import { Notification } from '..';
|
||||||
|
import Media from '../../../entity/Media';
|
||||||
import { User } from '../../../entity/User';
|
import { User } from '../../../entity/User';
|
||||||
import { NotificationAgentConfig } from '../../settings';
|
import { NotificationAgentConfig } from '../../settings';
|
||||||
|
|
||||||
export interface NotificationPayload {
|
export interface NotificationPayload {
|
||||||
subject: string;
|
subject: string;
|
||||||
notifyUser: User;
|
notifyUser: User;
|
||||||
|
media?: Media;
|
||||||
image?: string;
|
image?: string;
|
||||||
message?: string;
|
message?: string;
|
||||||
extra?: { name: string; value: string }[];
|
extra?: { name: string; value: string }[];
|
||||||
|
@@ -93,7 +93,8 @@ class DiscordAgent
|
|||||||
type: Notification,
|
type: Notification,
|
||||||
payload: NotificationPayload
|
payload: NotificationPayload
|
||||||
): DiscordRichEmbed {
|
): DiscordRichEmbed {
|
||||||
let color = EmbedColors.DEFAULT;
|
const settings = getSettings();
|
||||||
|
let color = EmbedColors.DARK_PURPLE;
|
||||||
|
|
||||||
const fields: Field[] = [];
|
const fields: Field[] = [];
|
||||||
|
|
||||||
@@ -112,6 +113,13 @@ class DiscordAgent
|
|||||||
inline: true,
|
inline: true,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (settings.main.applicationUrl) {
|
||||||
|
fields.push({
|
||||||
|
name: 'View Media',
|
||||||
|
value: `${settings.main.applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case Notification.MEDIA_APPROVED:
|
case Notification.MEDIA_APPROVED:
|
||||||
color = EmbedColors.PURPLE;
|
color = EmbedColors.PURPLE;
|
||||||
@@ -127,6 +135,13 @@ class DiscordAgent
|
|||||||
inline: true,
|
inline: true,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (settings.main.applicationUrl) {
|
||||||
|
fields.push({
|
||||||
|
name: 'View Media',
|
||||||
|
value: `${settings.main.applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case Notification.MEDIA_AVAILABLE:
|
case Notification.MEDIA_AVAILABLE:
|
||||||
color = EmbedColors.GREEN;
|
color = EmbedColors.GREEN;
|
||||||
@@ -142,6 +157,13 @@ class DiscordAgent
|
|||||||
inline: true,
|
inline: true,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (settings.main.applicationUrl) {
|
||||||
|
fields.push({
|
||||||
|
name: 'View Media',
|
||||||
|
value: `${settings.main.applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,7 +172,7 @@ class DiscordAgent
|
|||||||
description: payload.message,
|
description: payload.message,
|
||||||
color,
|
color,
|
||||||
timestamp: new Date().toISOString(),
|
timestamp: new Date().toISOString(),
|
||||||
author: { name: 'Overseerr' },
|
author: { name: 'Overseerr', url: settings.main.applicationUrl },
|
||||||
fields: [
|
fields: [
|
||||||
...fields,
|
...fields,
|
||||||
// If we have extra data, map it to fields for discord notifications
|
// If we have extra data, map it to fields for discord notifications
|
||||||
|
@@ -89,7 +89,10 @@ class EmailAgent
|
|||||||
imageUrl: payload.image,
|
imageUrl: payload.image,
|
||||||
timestamp: new Date().toTimeString(),
|
timestamp: new Date().toTimeString(),
|
||||||
requestedBy: payload.notifyUser.username,
|
requestedBy: payload.notifyUser.username,
|
||||||
actionUrl: applicationUrl,
|
actionUrl: applicationUrl
|
||||||
|
? `${applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}`
|
||||||
|
: undefined,
|
||||||
|
applicationUrl,
|
||||||
requestType: 'New Request',
|
requestType: 'New Request',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -124,7 +127,10 @@ class EmailAgent
|
|||||||
imageUrl: payload.image,
|
imageUrl: payload.image,
|
||||||
timestamp: new Date().toTimeString(),
|
timestamp: new Date().toTimeString(),
|
||||||
requestedBy: payload.notifyUser.username,
|
requestedBy: payload.notifyUser.username,
|
||||||
actionUrl: applicationUrl,
|
actionUrl: applicationUrl
|
||||||
|
? `${applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}`
|
||||||
|
: undefined,
|
||||||
|
applicationUrl,
|
||||||
requestType: 'Request Approved',
|
requestType: 'Request Approved',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -158,7 +164,10 @@ class EmailAgent
|
|||||||
imageUrl: payload.image,
|
imageUrl: payload.image,
|
||||||
timestamp: new Date().toTimeString(),
|
timestamp: new Date().toTimeString(),
|
||||||
requestedBy: payload.notifyUser.username,
|
requestedBy: payload.notifyUser.username,
|
||||||
actionUrl: applicationUrl,
|
actionUrl: applicationUrl
|
||||||
|
? `${applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}`
|
||||||
|
: undefined,
|
||||||
|
applicationUrl,
|
||||||
requestType: 'Now Available',
|
requestType: 'Now Available',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -185,7 +194,7 @@ class EmailAgent
|
|||||||
},
|
},
|
||||||
locals: {
|
locals: {
|
||||||
body: payload.message,
|
body: payload.message,
|
||||||
actionUrl: applicationUrl,
|
applicationUrl,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
|
@@ -29,6 +29,7 @@ export class MediaSubscriber implements EntitySubscriberInterface {
|
|||||||
notifyUser: request.requestedBy,
|
notifyUser: request.requestedBy,
|
||||||
subject: movie.title,
|
subject: movie.title,
|
||||||
message: movie.overview,
|
message: movie.overview,
|
||||||
|
media: entity,
|
||||||
image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${movie.poster_path}`,
|
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,
|
message: tv.overview,
|
||||||
notifyUser: request.requestedBy,
|
notifyUser: request.requestedBy,
|
||||||
image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${tv.poster_path}`,
|
image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${tv.poster_path}`,
|
||||||
|
media: entity,
|
||||||
extra: [
|
extra: [
|
||||||
{
|
{
|
||||||
name: 'Seasons',
|
name: 'Seasons',
|
||||||
|
@@ -47,7 +47,7 @@ div(role='article' aria-roledescription='email' aria-label='' lang='en')
|
|||||||
padding-bottom: 25px;\
|
padding-bottom: 25px;\
|
||||||
text-align: center;\
|
text-align: center;\
|
||||||
')
|
')
|
||||||
a(href=actionUrl style='\
|
a(href=applicationUrl style='\
|
||||||
text-shadow: 0 1px 0 #ffffff;\
|
text-shadow: 0 1px 0 #ffffff;\
|
||||||
font-weight: 700;\
|
font-weight: 700;\
|
||||||
font-size: 16px;\
|
font-size: 16px;\
|
||||||
@@ -92,7 +92,7 @@ div(role='article' aria-roledescription='email' aria-label='' lang='en')
|
|||||||
margin-bottom: 20px;\
|
margin-bottom: 20px;\
|
||||||
color: #51545e;\
|
color: #51545e;\
|
||||||
')
|
')
|
||||||
a(href=actionUrl style='color: #3869d4') Open Overseerr
|
a(href=actionUrl style='color: #3869d4') Open Media in Overseerr
|
||||||
tr
|
tr
|
||||||
td
|
td
|
||||||
table.sm-w-full(align='center' style='\
|
table.sm-w-full(align='center' style='\
|
||||||
|
@@ -47,7 +47,7 @@ div(role='article' aria-roledescription='email' aria-label='' lang='en')
|
|||||||
padding-bottom: 25px;\
|
padding-bottom: 25px;\
|
||||||
text-align: center;\
|
text-align: center;\
|
||||||
')
|
')
|
||||||
a(href=actionUrl style='\
|
a(href=applicationUrl style='\
|
||||||
text-shadow: 0 1px 0 #ffffff;\
|
text-shadow: 0 1px 0 #ffffff;\
|
||||||
font-weight: 700;\
|
font-weight: 700;\
|
||||||
font-size: 16px;\
|
font-size: 16px;\
|
||||||
@@ -74,7 +74,7 @@ div(role='article' aria-roledescription='email' aria-label='' lang='en')
|
|||||||
margin-bottom: 20px;\
|
margin-bottom: 20px;\
|
||||||
color: #51545e;\
|
color: #51545e;\
|
||||||
')
|
')
|
||||||
a(href=actionUrl style='color: #3869d4') Open Overseerr
|
a(href=applicationUrl style='color: #3869d4') Open Overseerr
|
||||||
tr
|
tr
|
||||||
td
|
td
|
||||||
table.sm-w-full(align='center' style='\
|
table.sm-w-full(align='center' style='\
|
||||||
|
Reference in New Issue
Block a user