mirror of
https://github.com/sct/overseerr.git
synced 2025-09-17 17:24:35 +02:00
feat(notif): include requested season numbers in notifications (#1211)
This commit is contained in:
@@ -179,7 +179,7 @@ export class MediaRequest {
|
|||||||
subject: movie.title,
|
subject: movie.title,
|
||||||
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: autoApproved ? undefined : this.requestedBy,
|
||||||
media,
|
media,
|
||||||
request: this,
|
request: this,
|
||||||
}
|
}
|
||||||
@@ -444,15 +444,10 @@ export class MediaRequest {
|
|||||||
label: 'Media Request',
|
label: 'Media Request',
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
const userRepository = getRepository(User);
|
|
||||||
const admin = await userRepository.findOneOrFail({
|
|
||||||
select: ['id', 'plexToken'],
|
|
||||||
order: { id: 'ASC' },
|
|
||||||
});
|
|
||||||
notificationManager.sendNotification(Notification.MEDIA_FAILED, {
|
notificationManager.sendNotification(Notification.MEDIA_FAILED, {
|
||||||
subject: movie.title,
|
subject: movie.title,
|
||||||
message: 'Movie failed to add to Radarr',
|
message: movie.overview,
|
||||||
notifyUser: admin,
|
|
||||||
media,
|
media,
|
||||||
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}`,
|
||||||
request: this,
|
request: this,
|
||||||
@@ -641,14 +636,10 @@ export class MediaRequest {
|
|||||||
label: 'Media Request',
|
label: 'Media Request',
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
const userRepository = getRepository(User);
|
|
||||||
const admin = await userRepository.findOneOrFail({
|
|
||||||
order: { id: 'ASC' },
|
|
||||||
});
|
|
||||||
notificationManager.sendNotification(Notification.MEDIA_FAILED, {
|
notificationManager.sendNotification(Notification.MEDIA_FAILED, {
|
||||||
subject: series.name,
|
subject: series.name,
|
||||||
message: 'Series failed to add to Sonarr',
|
message: series.overview,
|
||||||
notifyUser: admin,
|
|
||||||
image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${series.poster_path}`,
|
image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${series.poster_path}`,
|
||||||
media,
|
media,
|
||||||
extra: [
|
extra: [
|
||||||
|
@@ -6,7 +6,7 @@ import { NotificationAgentConfig } from '../../settings';
|
|||||||
|
|
||||||
export interface NotificationPayload {
|
export interface NotificationPayload {
|
||||||
subject: string;
|
subject: string;
|
||||||
notifyUser: User;
|
notifyUser?: User;
|
||||||
media?: Media;
|
media?: Media;
|
||||||
image?: string;
|
image?: string;
|
||||||
message?: string;
|
message?: string;
|
||||||
@@ -21,15 +21,9 @@ export abstract class BaseAgent<T extends NotificationAgentConfig> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected abstract getSettings(): T;
|
protected abstract getSettings(): T;
|
||||||
|
|
||||||
protected userNotificationTypes: Notification[] = [
|
|
||||||
Notification.MEDIA_APPROVED,
|
|
||||||
Notification.MEDIA_DECLINED,
|
|
||||||
Notification.MEDIA_AVAILABLE,
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface NotificationAgent {
|
export interface NotificationAgent {
|
||||||
shouldSend(type: Notification, payload: NotificationPayload): boolean;
|
shouldSend(type: Notification): boolean;
|
||||||
send(type: Notification, payload: NotificationPayload): Promise<boolean>;
|
send(type: Notification, payload: NotificationPayload): Promise<boolean>;
|
||||||
}
|
}
|
||||||
|
@@ -107,7 +107,7 @@ class DiscordAgent
|
|||||||
if (payload.request) {
|
if (payload.request) {
|
||||||
fields.push({
|
fields.push({
|
||||||
name: 'Requested By',
|
name: 'Requested By',
|
||||||
value: payload.notifyUser.displayName ?? '',
|
value: payload.request?.requestedBy.displayName ?? '',
|
||||||
inline: true,
|
inline: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -217,7 +217,7 @@ class DiscordAgent
|
|||||||
let content = undefined;
|
let content = undefined;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
this.userNotificationTypes.includes(type) &&
|
payload.notifyUser &&
|
||||||
payload.notifyUser.settings?.enableNotifications &&
|
payload.notifyUser.settings?.enableNotifications &&
|
||||||
payload.notifyUser.settings?.discordId
|
payload.notifyUser.settings?.discordId
|
||||||
) {
|
) {
|
||||||
|
@@ -22,13 +22,12 @@ class EmailAgent
|
|||||||
return settings.notifications.agents.email;
|
return settings.notifications.agents.email;
|
||||||
}
|
}
|
||||||
|
|
||||||
public shouldSend(type: Notification, payload: NotificationPayload): boolean {
|
public shouldSend(type: Notification): boolean {
|
||||||
const settings = this.getSettings();
|
const settings = this.getSettings();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
settings.enabled &&
|
settings.enabled &&
|
||||||
hasNotificationType(type, this.getSettings().types) &&
|
hasNotificationType(type, this.getSettings().types)
|
||||||
(payload.notifyUser.settings?.enableNotifications ?? true)
|
|
||||||
) {
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -45,9 +44,13 @@ class EmailAgent
|
|||||||
|
|
||||||
// Send to all users with the manage requests permission (or admins)
|
// Send to all users with the manage requests permission (or admins)
|
||||||
users
|
users
|
||||||
.filter((user) => user.hasPermission(Permission.MANAGE_REQUESTS))
|
.filter(
|
||||||
|
(user) =>
|
||||||
|
user.hasPermission(Permission.MANAGE_REQUESTS) &&
|
||||||
|
(user.settings?.enableNotifications ?? true)
|
||||||
|
)
|
||||||
.forEach((user) => {
|
.forEach((user) => {
|
||||||
const email = new PreparedEmail(payload.notifyUser.settings?.pgpKey);
|
const email = new PreparedEmail(user.settings?.pgpKey);
|
||||||
|
|
||||||
email.send({
|
email.send({
|
||||||
template: path.join(
|
template: path.join(
|
||||||
@@ -62,9 +65,11 @@ class EmailAgent
|
|||||||
payload.media?.mediaType === MediaType.TV ? 'series' : 'movie'
|
payload.media?.mediaType === MediaType.TV ? 'series' : 'movie'
|
||||||
}!`,
|
}!`,
|
||||||
mediaName: payload.subject,
|
mediaName: payload.subject,
|
||||||
|
mediaPlot: payload.message,
|
||||||
|
mediaExtra: payload.extra ?? [],
|
||||||
imageUrl: payload.image,
|
imageUrl: payload.image,
|
||||||
timestamp: new Date().toTimeString(),
|
timestamp: new Date().toTimeString(),
|
||||||
requestedBy: payload.notifyUser.displayName,
|
requestedBy: payload.request?.requestedBy.displayName,
|
||||||
actionUrl: applicationUrl
|
actionUrl: applicationUrl
|
||||||
? `${applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}`
|
? `${applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}`
|
||||||
: undefined,
|
: undefined,
|
||||||
@@ -95,9 +100,13 @@ class EmailAgent
|
|||||||
|
|
||||||
// Send to all users with the manage requests permission (or admins)
|
// Send to all users with the manage requests permission (or admins)
|
||||||
users
|
users
|
||||||
.filter((user) => user.hasPermission(Permission.MANAGE_REQUESTS))
|
.filter(
|
||||||
|
(user) =>
|
||||||
|
user.hasPermission(Permission.MANAGE_REQUESTS) &&
|
||||||
|
(user.settings?.enableNotifications ?? true)
|
||||||
|
)
|
||||||
.forEach((user) => {
|
.forEach((user) => {
|
||||||
const email = new PreparedEmail(payload.notifyUser.settings?.pgpKey);
|
const email = new PreparedEmail(user.settings?.pgpKey);
|
||||||
|
|
||||||
email.send({
|
email.send({
|
||||||
template: path.join(
|
template: path.join(
|
||||||
@@ -112,11 +121,12 @@ class EmailAgent
|
|||||||
payload.media?.mediaType === MediaType.TV ? 'series' : 'movie'
|
payload.media?.mediaType === MediaType.TV ? 'series' : 'movie'
|
||||||
} could not be added to ${
|
} could not be added to ${
|
||||||
payload.media?.mediaType === MediaType.TV ? 'Sonarr' : 'Radarr'
|
payload.media?.mediaType === MediaType.TV ? 'Sonarr' : 'Radarr'
|
||||||
}`,
|
}:`,
|
||||||
mediaName: payload.subject,
|
mediaName: payload.subject,
|
||||||
|
mediaPlot: payload.message,
|
||||||
imageUrl: payload.image,
|
imageUrl: payload.image,
|
||||||
timestamp: new Date().toTimeString(),
|
timestamp: new Date().toTimeString(),
|
||||||
requestedBy: payload.notifyUser.displayName,
|
requestedBy: payload.request?.requestedBy.displayName,
|
||||||
actionUrl: applicationUrl
|
actionUrl: applicationUrl
|
||||||
? `${applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}`
|
? `${applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}`
|
||||||
: undefined,
|
: undefined,
|
||||||
@@ -142,34 +152,41 @@ class EmailAgent
|
|||||||
// This is getting main settings for the whole app
|
// This is getting main settings for the whole app
|
||||||
const { applicationUrl, applicationTitle } = getSettings().main;
|
const { applicationUrl, applicationTitle } = getSettings().main;
|
||||||
try {
|
try {
|
||||||
const email = new PreparedEmail(payload.notifyUser.settings?.pgpKey);
|
if (
|
||||||
|
payload.notifyUser &&
|
||||||
|
payload.notifyUser.settings?.enableNotifications
|
||||||
|
) {
|
||||||
|
const email = new PreparedEmail(payload.notifyUser.settings?.pgpKey);
|
||||||
|
|
||||||
|
await email.send({
|
||||||
|
template: path.join(
|
||||||
|
__dirname,
|
||||||
|
'../../../templates/email/media-request'
|
||||||
|
),
|
||||||
|
message: {
|
||||||
|
to: payload.notifyUser.email,
|
||||||
|
},
|
||||||
|
locals: {
|
||||||
|
body: `Your request for the following ${
|
||||||
|
payload.media?.mediaType === MediaType.TV ? 'series' : 'movie'
|
||||||
|
} has been approved:`,
|
||||||
|
mediaName: payload.subject,
|
||||||
|
mediaExtra: payload.extra ?? [],
|
||||||
|
imageUrl: payload.image,
|
||||||
|
timestamp: new Date().toTimeString(),
|
||||||
|
requestedBy: payload.request?.requestedBy.displayName,
|
||||||
|
actionUrl: applicationUrl
|
||||||
|
? `${applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}`
|
||||||
|
: undefined,
|
||||||
|
applicationUrl,
|
||||||
|
applicationTitle,
|
||||||
|
requestType: `${
|
||||||
|
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
||||||
|
} Request Approved`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
await email.send({
|
|
||||||
template: path.join(
|
|
||||||
__dirname,
|
|
||||||
'../../../templates/email/media-request'
|
|
||||||
),
|
|
||||||
message: {
|
|
||||||
to: payload.notifyUser.email,
|
|
||||||
},
|
|
||||||
locals: {
|
|
||||||
body: `Your request for the following ${
|
|
||||||
payload.media?.mediaType === MediaType.TV ? 'series' : 'movie'
|
|
||||||
} has been approved:`,
|
|
||||||
mediaName: payload.subject,
|
|
||||||
imageUrl: payload.image,
|
|
||||||
timestamp: new Date().toTimeString(),
|
|
||||||
requestedBy: payload.notifyUser.displayName,
|
|
||||||
actionUrl: applicationUrl
|
|
||||||
? `${applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}`
|
|
||||||
: undefined,
|
|
||||||
applicationUrl,
|
|
||||||
applicationTitle,
|
|
||||||
requestType: `${
|
|
||||||
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
|
||||||
} Request Approved`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error('Email notification failed to send', {
|
logger.error('Email notification failed to send', {
|
||||||
@@ -189,7 +206,11 @@ class EmailAgent
|
|||||||
|
|
||||||
// Send to all users with the manage requests permission (or admins)
|
// Send to all users with the manage requests permission (or admins)
|
||||||
users
|
users
|
||||||
.filter((user) => user.hasPermission(Permission.MANAGE_REQUESTS))
|
.filter(
|
||||||
|
(user) =>
|
||||||
|
user.hasPermission(Permission.MANAGE_REQUESTS) &&
|
||||||
|
(user.settings?.enableNotifications ?? true)
|
||||||
|
)
|
||||||
.forEach((user) => {
|
.forEach((user) => {
|
||||||
const email = new PreparedEmail();
|
const email = new PreparedEmail();
|
||||||
|
|
||||||
@@ -206,9 +227,10 @@ class EmailAgent
|
|||||||
payload.media?.mediaType === MediaType.TV ? 'series' : 'movie'
|
payload.media?.mediaType === MediaType.TV ? 'series' : 'movie'
|
||||||
} has been automatically approved:`,
|
} has been automatically approved:`,
|
||||||
mediaName: payload.subject,
|
mediaName: payload.subject,
|
||||||
|
mediaExtra: payload.extra ?? [],
|
||||||
imageUrl: payload.image,
|
imageUrl: payload.image,
|
||||||
timestamp: new Date().toTimeString(),
|
timestamp: new Date().toTimeString(),
|
||||||
requestedBy: payload.notifyUser.displayName,
|
requestedBy: payload.request?.requestedBy.displayName,
|
||||||
actionUrl: applicationUrl
|
actionUrl: applicationUrl
|
||||||
? `${applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}`
|
? `${applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}`
|
||||||
: undefined,
|
: undefined,
|
||||||
@@ -234,34 +256,41 @@ class EmailAgent
|
|||||||
// This is getting main settings for the whole app
|
// This is getting main settings for the whole app
|
||||||
const { applicationUrl, applicationTitle } = getSettings().main;
|
const { applicationUrl, applicationTitle } = getSettings().main;
|
||||||
try {
|
try {
|
||||||
const email = new PreparedEmail(payload.notifyUser.settings?.pgpKey);
|
if (
|
||||||
|
payload.notifyUser &&
|
||||||
|
payload.notifyUser.settings?.enableNotifications
|
||||||
|
) {
|
||||||
|
const email = new PreparedEmail(payload.notifyUser.settings?.pgpKey);
|
||||||
|
|
||||||
|
await email.send({
|
||||||
|
template: path.join(
|
||||||
|
__dirname,
|
||||||
|
'../../../templates/email/media-request'
|
||||||
|
),
|
||||||
|
message: {
|
||||||
|
to: payload.notifyUser.email,
|
||||||
|
},
|
||||||
|
locals: {
|
||||||
|
body: `Your request for the following ${
|
||||||
|
payload.media?.mediaType === MediaType.TV ? 'series' : 'movie'
|
||||||
|
} was declined:`,
|
||||||
|
mediaName: payload.subject,
|
||||||
|
mediaExtra: payload.extra ?? [],
|
||||||
|
imageUrl: payload.image,
|
||||||
|
timestamp: new Date().toTimeString(),
|
||||||
|
requestedBy: payload.request?.requestedBy.displayName,
|
||||||
|
actionUrl: applicationUrl
|
||||||
|
? `${applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}`
|
||||||
|
: undefined,
|
||||||
|
applicationUrl,
|
||||||
|
applicationTitle,
|
||||||
|
requestType: `${
|
||||||
|
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
||||||
|
} Request Declined`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
await email.send({
|
|
||||||
template: path.join(
|
|
||||||
__dirname,
|
|
||||||
'../../../templates/email/media-request'
|
|
||||||
),
|
|
||||||
message: {
|
|
||||||
to: payload.notifyUser.email,
|
|
||||||
},
|
|
||||||
locals: {
|
|
||||||
body: `Your request for the following ${
|
|
||||||
payload.media?.mediaType === MediaType.TV ? 'series' : 'movie'
|
|
||||||
} was declined:`,
|
|
||||||
mediaName: payload.subject,
|
|
||||||
imageUrl: payload.image,
|
|
||||||
timestamp: new Date().toTimeString(),
|
|
||||||
requestedBy: payload.notifyUser.displayName,
|
|
||||||
actionUrl: applicationUrl
|
|
||||||
? `${applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}`
|
|
||||||
: undefined,
|
|
||||||
applicationUrl,
|
|
||||||
applicationTitle,
|
|
||||||
requestType: `${
|
|
||||||
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
|
||||||
} Request Declined`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error('Email notification failed to send', {
|
logger.error('Email notification failed to send', {
|
||||||
@@ -276,34 +305,41 @@ class EmailAgent
|
|||||||
// This is getting main settings for the whole app
|
// This is getting main settings for the whole app
|
||||||
const { applicationUrl, applicationTitle } = getSettings().main;
|
const { applicationUrl, applicationTitle } = getSettings().main;
|
||||||
try {
|
try {
|
||||||
const email = new PreparedEmail(payload.notifyUser.settings?.pgpKey);
|
if (
|
||||||
|
payload.notifyUser &&
|
||||||
|
payload.notifyUser.settings?.enableNotifications
|
||||||
|
) {
|
||||||
|
const email = new PreparedEmail(payload.notifyUser.settings?.pgpKey);
|
||||||
|
|
||||||
|
await email.send({
|
||||||
|
template: path.join(
|
||||||
|
__dirname,
|
||||||
|
'../../../templates/email/media-request'
|
||||||
|
),
|
||||||
|
message: {
|
||||||
|
to: payload.notifyUser.email,
|
||||||
|
},
|
||||||
|
locals: {
|
||||||
|
body: `The following ${
|
||||||
|
payload.media?.mediaType === MediaType.TV ? 'series' : 'movie'
|
||||||
|
} you requested is now available!`,
|
||||||
|
mediaName: payload.subject,
|
||||||
|
mediaExtra: payload.extra ?? [],
|
||||||
|
imageUrl: payload.image,
|
||||||
|
timestamp: new Date().toTimeString(),
|
||||||
|
requestedBy: payload.request?.requestedBy.displayName,
|
||||||
|
actionUrl: applicationUrl
|
||||||
|
? `${applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}`
|
||||||
|
: undefined,
|
||||||
|
applicationUrl,
|
||||||
|
applicationTitle,
|
||||||
|
requestType: `${
|
||||||
|
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
||||||
|
} Now Available`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
await email.send({
|
|
||||||
template: path.join(
|
|
||||||
__dirname,
|
|
||||||
'../../../templates/email/media-request'
|
|
||||||
),
|
|
||||||
message: {
|
|
||||||
to: payload.notifyUser.email,
|
|
||||||
},
|
|
||||||
locals: {
|
|
||||||
body: `The following ${
|
|
||||||
payload.media?.mediaType === MediaType.TV ? 'series' : 'movie'
|
|
||||||
} you requested is now available!`,
|
|
||||||
mediaName: payload.subject,
|
|
||||||
imageUrl: payload.image,
|
|
||||||
timestamp: new Date().toTimeString(),
|
|
||||||
requestedBy: payload.notifyUser.displayName,
|
|
||||||
actionUrl: applicationUrl
|
|
||||||
? `${applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}`
|
|
||||||
: undefined,
|
|
||||||
applicationUrl,
|
|
||||||
applicationTitle,
|
|
||||||
requestType: `${
|
|
||||||
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
|
||||||
} Now Available`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error('Email notification failed to send', {
|
logger.error('Email notification failed to send', {
|
||||||
@@ -318,19 +354,22 @@ class EmailAgent
|
|||||||
// This is getting main settings for the whole app
|
// This is getting main settings for the whole app
|
||||||
const { applicationUrl, applicationTitle } = getSettings().main;
|
const { applicationUrl, applicationTitle } = getSettings().main;
|
||||||
try {
|
try {
|
||||||
const email = new PreparedEmail(payload.notifyUser.settings?.pgpKey);
|
if (payload.notifyUser) {
|
||||||
|
const email = new PreparedEmail(payload.notifyUser.settings?.pgpKey);
|
||||||
|
|
||||||
|
await email.send({
|
||||||
|
template: path.join(__dirname, '../../../templates/email/test-email'),
|
||||||
|
message: {
|
||||||
|
to: payload.notifyUser.email,
|
||||||
|
},
|
||||||
|
locals: {
|
||||||
|
body: payload.message,
|
||||||
|
applicationUrl,
|
||||||
|
applicationTitle,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
await email.send({
|
|
||||||
template: path.join(__dirname, '../../../templates/email/test-email'),
|
|
||||||
message: {
|
|
||||||
to: payload.notifyUser.email,
|
|
||||||
},
|
|
||||||
locals: {
|
|
||||||
body: payload.message,
|
|
||||||
applicationUrl,
|
|
||||||
applicationTitle,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error('Email notification failed to send', {
|
logger.error('Email notification failed to send', {
|
||||||
|
@@ -47,7 +47,7 @@ class PushbulletAgent
|
|||||||
|
|
||||||
const title = payload.subject;
|
const title = payload.subject;
|
||||||
const plot = payload.message;
|
const plot = payload.message;
|
||||||
const username = payload.notifyUser.displayName;
|
const username = payload.request?.requestedBy.displayName;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Notification.MEDIA_PENDING:
|
case Notification.MEDIA_PENDING:
|
||||||
@@ -122,6 +122,10 @@ class PushbulletAgent
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const extra of payload.extra ?? []) {
|
||||||
|
message += `\n${extra.name}: ${extra.value}`;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: messageTitle,
|
title: messageTitle,
|
||||||
body: message,
|
body: message,
|
||||||
|
@@ -61,7 +61,7 @@ class PushoverAgent
|
|||||||
|
|
||||||
const title = payload.subject;
|
const title = payload.subject;
|
||||||
const plot = payload.message;
|
const plot = payload.message;
|
||||||
const username = payload.notifyUser.displayName;
|
const username = payload.request?.requestedBy.displayName;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Notification.MEDIA_PENDING:
|
case Notification.MEDIA_PENDING:
|
||||||
@@ -70,10 +70,10 @@ class PushoverAgent
|
|||||||
} Request`;
|
} Request`;
|
||||||
message += `<b>${title}</b>`;
|
message += `<b>${title}</b>`;
|
||||||
if (plot) {
|
if (plot) {
|
||||||
message += `\n${plot}`;
|
message += `<small>\n${plot}</small>`;
|
||||||
}
|
}
|
||||||
message += `\n\n<b>Requested By</b>\n${username}`;
|
message += `<small>\n\n<b>Requested By</b>\n${username}</small>`;
|
||||||
message += `\n\n<b>Status</b>\nPending Approval`;
|
message += `<small>\n\n<b>Status</b>\nPending Approval</small>`;
|
||||||
break;
|
break;
|
||||||
case Notification.MEDIA_APPROVED:
|
case Notification.MEDIA_APPROVED:
|
||||||
messageTitle = `${
|
messageTitle = `${
|
||||||
@@ -81,10 +81,10 @@ class PushoverAgent
|
|||||||
} Request Approved`;
|
} Request Approved`;
|
||||||
message += `<b>${title}</b>`;
|
message += `<b>${title}</b>`;
|
||||||
if (plot) {
|
if (plot) {
|
||||||
message += `\n${plot}`;
|
message += `<small>\n${plot}</small>`;
|
||||||
}
|
}
|
||||||
message += `\n\n<b>Requested By</b>\n${username}`;
|
message += `<small>\n\n<b>Requested By</b>\n${username}</small>`;
|
||||||
message += `\n\n<b>Status</b>\nProcessing`;
|
message += `<small>\n\n<b>Status</b>\nProcessing</small>`;
|
||||||
break;
|
break;
|
||||||
case Notification.MEDIA_AUTO_APPROVED:
|
case Notification.MEDIA_AUTO_APPROVED:
|
||||||
messageTitle = `${
|
messageTitle = `${
|
||||||
@@ -92,10 +92,10 @@ class PushoverAgent
|
|||||||
} Request Automatically Approved`;
|
} Request Automatically Approved`;
|
||||||
message += `<b>${title}</b>`;
|
message += `<b>${title}</b>`;
|
||||||
if (plot) {
|
if (plot) {
|
||||||
message += `\n${plot}`;
|
message += `<small>\n${plot}</small>`;
|
||||||
}
|
}
|
||||||
message += `\n\n<b>Requested By</b>\n${username}`;
|
message += `<small>\n\n<b>Requested By</b>\n${username}</small>`;
|
||||||
message += `\n\n<b>Status</b>\nProcessing`;
|
message += `<small>\n\n<b>Status</b>\nProcessing</small>`;
|
||||||
break;
|
break;
|
||||||
case Notification.MEDIA_AVAILABLE:
|
case Notification.MEDIA_AVAILABLE:
|
||||||
messageTitle = `${
|
messageTitle = `${
|
||||||
@@ -103,10 +103,10 @@ class PushoverAgent
|
|||||||
} Now Available`;
|
} Now Available`;
|
||||||
message += `<b>${title}</b>`;
|
message += `<b>${title}</b>`;
|
||||||
if (plot) {
|
if (plot) {
|
||||||
message += `\n${plot}`;
|
message += `<small>\n${plot}</small>`;
|
||||||
}
|
}
|
||||||
message += `\n\n<b>Requested By</b>\n${username}`;
|
message += `<small>\n\n<b>Requested By</b>\n${username}</small>`;
|
||||||
message += `\n\n<b>Status</b>\nAvailable`;
|
message += `<small>\n\n<b>Status</b>\nAvailable</small>`;
|
||||||
break;
|
break;
|
||||||
case Notification.MEDIA_DECLINED:
|
case Notification.MEDIA_DECLINED:
|
||||||
messageTitle = `${
|
messageTitle = `${
|
||||||
@@ -114,10 +114,10 @@ class PushoverAgent
|
|||||||
} Request Declined`;
|
} Request Declined`;
|
||||||
message += `<b>${title}</b>`;
|
message += `<b>${title}</b>`;
|
||||||
if (plot) {
|
if (plot) {
|
||||||
message += `\n${plot}`;
|
message += `<small>\n${plot}</small>`;
|
||||||
}
|
}
|
||||||
message += `\n\n<b>Requested By</b>\n${username}`;
|
message += `<small>\n\n<b>Requested By</b>\n${username}</small>`;
|
||||||
message += `\n\n<b>Status</b>\nDeclined`;
|
message += `<small>\n\n<b>Status</b>\nDeclined</small>`;
|
||||||
priority = 1;
|
priority = 1;
|
||||||
break;
|
break;
|
||||||
case Notification.MEDIA_FAILED:
|
case Notification.MEDIA_FAILED:
|
||||||
@@ -126,18 +126,22 @@ class PushoverAgent
|
|||||||
} Request`;
|
} Request`;
|
||||||
message += `<b>${title}</b>`;
|
message += `<b>${title}</b>`;
|
||||||
if (plot) {
|
if (plot) {
|
||||||
message += `\n${plot}`;
|
message += `<small>\n${plot}</small>`;
|
||||||
}
|
}
|
||||||
message += `\n\n<b>Requested By</b>\n${username}`;
|
message += `<small>\n\n<b>Requested By</b>\n${username}</small>`;
|
||||||
message += `\n\n<b>Status</b>\nFailed`;
|
message += `<small>\n\n<b>Status</b>\nFailed</small>`;
|
||||||
priority = 1;
|
priority = 1;
|
||||||
break;
|
break;
|
||||||
case Notification.TEST_NOTIFICATION:
|
case Notification.TEST_NOTIFICATION:
|
||||||
messageTitle = 'Test Notification';
|
messageTitle = 'Test Notification';
|
||||||
message += `${plot}`;
|
message += `<small>${plot}</small>`;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const extra of payload.extra ?? []) {
|
||||||
|
message += `<small>\n\n<b>${extra.name}</b>\n${extra.value}</small>`;
|
||||||
|
}
|
||||||
|
|
||||||
if (settings.main.applicationUrl && payload.media) {
|
if (settings.main.applicationUrl && payload.media) {
|
||||||
url = `${settings.main.applicationUrl}/${payload.media.mediaType}/${payload.media.tmdbId}`;
|
url = `${settings.main.applicationUrl}/${payload.media.mediaType}/${payload.media.tmdbId}`;
|
||||||
url_title = `Open in ${settings.main.applicationTitle}`;
|
url_title = `Open in ${settings.main.applicationTitle}`;
|
||||||
|
@@ -67,7 +67,9 @@ class SlackAgent
|
|||||||
if (payload.request) {
|
if (payload.request) {
|
||||||
fields.push({
|
fields.push({
|
||||||
type: 'mrkdwn',
|
type: 'mrkdwn',
|
||||||
text: `*Requested By*\n${payload.notifyUser.displayName ?? ''}`,
|
text: `*Requested By*\n${
|
||||||
|
payload.request?.requestedBy.displayName ?? ''
|
||||||
|
}`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,6 +133,13 @@ class SlackAgent
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const extra of payload.extra ?? []) {
|
||||||
|
fields.push({
|
||||||
|
type: 'mrkdwn',
|
||||||
|
text: `*${extra.name}*\n${extra.value}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (settings.main.applicationUrl && payload.media) {
|
if (settings.main.applicationUrl && payload.media) {
|
||||||
actionUrl = `${settings.main.applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}`;
|
actionUrl = `${settings.main.applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}`;
|
||||||
}
|
}
|
||||||
|
@@ -61,7 +61,7 @@ class TelegramAgent
|
|||||||
|
|
||||||
const title = this.escapeText(payload.subject);
|
const title = this.escapeText(payload.subject);
|
||||||
const plot = this.escapeText(payload.message);
|
const plot = this.escapeText(payload.message);
|
||||||
const user = this.escapeText(payload.notifyUser.displayName);
|
const user = this.escapeText(payload.request?.requestedBy.displayName);
|
||||||
const applicationTitle = this.escapeText(settings.main.applicationTitle);
|
const applicationTitle = this.escapeText(settings.main.applicationTitle);
|
||||||
|
|
||||||
/* eslint-disable no-useless-escape */
|
/* eslint-disable no-useless-escape */
|
||||||
@@ -138,6 +138,10 @@ class TelegramAgent
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const extra of payload.extra ?? []) {
|
||||||
|
message += `\n\n\*${extra.name}\*\n${extra.value}`;
|
||||||
|
}
|
||||||
|
|
||||||
if (settings.main.applicationUrl && payload.media) {
|
if (settings.main.applicationUrl && payload.media) {
|
||||||
const actionUrl = `${settings.main.applicationUrl}/${payload.media.mediaType}/${payload.media.tmdbId}`;
|
const actionUrl = `${settings.main.applicationUrl}/${payload.media.mediaType}/${payload.media.tmdbId}`;
|
||||||
message += `\n\n\[Open in ${applicationTitle}\]\(${actionUrl}\)`;
|
message += `\n\n\[Open in ${applicationTitle}\]\(${actionUrl}\)`;
|
||||||
@@ -175,7 +179,7 @@ class TelegramAgent
|
|||||||
|
|
||||||
// Send user notification
|
// Send user notification
|
||||||
if (
|
if (
|
||||||
this.userNotificationTypes.includes(type) &&
|
payload.notifyUser &&
|
||||||
payload.notifyUser.settings?.enableNotifications &&
|
payload.notifyUser.settings?.enableNotifications &&
|
||||||
payload.notifyUser.settings?.telegramChatId &&
|
payload.notifyUser.settings?.telegramChatId &&
|
||||||
payload.notifyUser.settings?.telegramChatId !==
|
payload.notifyUser.settings?.telegramChatId !==
|
||||||
|
@@ -50,7 +50,7 @@ class NotificationManager {
|
|||||||
label: 'Notifications',
|
label: 'Notifications',
|
||||||
});
|
});
|
||||||
this.activeAgents.forEach((agent) => {
|
this.activeAgents.forEach((agent) => {
|
||||||
if (settings.enabled && agent.shouldSend(type, payload)) {
|
if (settings.enabled && agent.shouldSend(type)) {
|
||||||
agent.send(type, payload);
|
agent.send(type, payload);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -42,7 +42,6 @@ div(role='article' aria-roledescription='email' aria-label='' lang='en')
|
|||||||
table(style='width: 100%' width='100%' cellpadding='0' cellspacing='0' role='presentation')
|
table(style='width: 100%' width='100%' cellpadding='0' cellspacing='0' role='presentation')
|
||||||
tr
|
tr
|
||||||
td(align='center' style='\
|
td(align='center' style='\
|
||||||
font-size: 16px;\
|
|
||||||
padding-top: 25px;\
|
padding-top: 25px;\
|
||||||
padding-bottom: 25px;\
|
padding-bottom: 25px;\
|
||||||
text-align: center;\
|
text-align: center;\
|
||||||
@@ -50,7 +49,7 @@ div(role='article' aria-roledescription='email' aria-label='' lang='en')
|
|||||||
a(href=applicationUrl 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: 24px;\
|
||||||
color: #a8aaaf;\
|
color: #a8aaaf;\
|
||||||
text-decoration: none;\
|
text-decoration: none;\
|
||||||
')
|
')
|
||||||
@@ -70,13 +69,17 @@ div(role='article' aria-roledescription='email' aria-label='' lang='en')
|
|||||||
br
|
br
|
||||||
br
|
br
|
||||||
p(style='margin-top: 4px; text-align: center')
|
p(style='margin-top: 4px; text-align: center')
|
||||||
| #{mediaName}
|
b
|
||||||
table(cellpadding='0' cellspacing='0' role='presentation')
|
| #{mediaName}
|
||||||
|
each extra in mediaExtra
|
||||||
|
br
|
||||||
|
| #{extra.name}:
|
||||||
|
| #{extra.value}
|
||||||
|
table(align='center' cellpadding='0' cellspacing='0' role='presentation')
|
||||||
tr
|
tr
|
||||||
td
|
td
|
||||||
table(cellpadding='0' cellspacing='0' role='presentation')
|
a(href=actionUrl style='color: #3869d4')
|
||||||
a(href=actionUrl style='color: #3869d4')
|
img(src=imageUrl alt='')
|
||||||
img(src=imageUrl alt='')
|
|
||||||
p(style='\
|
p(style='\
|
||||||
font-size: 16px;\
|
font-size: 16px;\
|
||||||
line-height: 24px;\
|
line-height: 24px;\
|
||||||
|
Reference in New Issue
Block a user