Skip to content

Commit

Permalink
fix(notif/ui): Use custom application title in notifications & sign-i…
Browse files Browse the repository at this point in the history
…n page (#849)
  • Loading branch information
TheCatLady committed Feb 5, 2021
1 parent eedadb8 commit 38c76b5
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 251 deletions.
2 changes: 1 addition & 1 deletion server/api/plexapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class PlexAPI {
options: {
identifier: settings.clientId,
product: 'Overseerr',
deviceName: 'Overseerr',
deviceName: settings.main.applicationTitle,
platform: 'Overseerr',
},
});
Expand Down
18 changes: 12 additions & 6 deletions server/lib/notifications/agents/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class EmailAgent

private async sendMediaRequestEmail(payload: NotificationPayload) {
// This is getting main settings for the whole app
const applicationUrl = getSettings().main.applicationUrl;
const { applicationUrl, applicationTitle } = getSettings().main;
try {
const userRepository = getRepository(User);
const users = await userRepository.find();
Expand Down Expand Up @@ -65,6 +65,7 @@ class EmailAgent
? `${applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}`
: undefined,
applicationUrl,
applicationTitle,
requestType: 'New Request',
},
});
Expand All @@ -81,7 +82,7 @@ class EmailAgent

private async sendMediaFailedEmail(payload: NotificationPayload) {
// This is getting main settings for the whole app
const applicationUrl = getSettings().main.applicationUrl;
const { applicationUrl, applicationTitle } = getSettings().main;
try {
const userRepository = getRepository(User);
const users = await userRepository.find();
Expand Down Expand Up @@ -111,6 +112,7 @@ class EmailAgent
? `${applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}`
: undefined,
applicationUrl,
applicationTitle,
requestType: 'Failed Request',
},
});
Expand All @@ -127,7 +129,7 @@ class EmailAgent

private async sendMediaApprovedEmail(payload: NotificationPayload) {
// This is getting main settings for the whole app
const applicationUrl = getSettings().main.applicationUrl;
const { applicationUrl, applicationTitle } = getSettings().main;
try {
const email = new PreparedEmail();

Expand All @@ -149,6 +151,7 @@ class EmailAgent
? `${applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}`
: undefined,
applicationUrl,
applicationTitle,
requestType: 'Request Approved',
},
});
Expand All @@ -164,7 +167,7 @@ class EmailAgent

private async sendMediaDeclinedEmail(payload: NotificationPayload) {
// This is getting main settings for the whole app
const applicationUrl = getSettings().main.applicationUrl;
const { applicationUrl, applicationTitle } = getSettings().main;
try {
const email = new PreparedEmail();

Expand All @@ -186,6 +189,7 @@ class EmailAgent
? `${applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}`
: undefined,
applicationUrl,
applicationTitle,
requestType: 'Request Declined',
},
});
Expand All @@ -201,7 +205,7 @@ class EmailAgent

private async sendMediaAvailableEmail(payload: NotificationPayload) {
// This is getting main settings for the whole app
const applicationUrl = getSettings().main.applicationUrl;
const { applicationUrl, applicationTitle } = getSettings().main;
try {
const email = new PreparedEmail();

Expand All @@ -223,6 +227,7 @@ class EmailAgent
? `${applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}`
: undefined,
applicationUrl,
applicationTitle,
requestType: 'Now Available',
},
});
Expand All @@ -238,7 +243,7 @@ class EmailAgent

private async sendTestEmail(payload: NotificationPayload) {
// This is getting main settings for the whole app
const applicationUrl = getSettings().main.applicationUrl;
const { applicationUrl, applicationTitle } = getSettings().main;
try {
const email = new PreparedEmail();

Expand All @@ -250,6 +255,7 @@ class EmailAgent
locals: {
body: payload.message,
applicationUrl,
applicationTitle,
},
});
return true;
Expand Down
5 changes: 2 additions & 3 deletions server/lib/notifications/agents/pushover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class PushoverAgent
message += `<b>Status</b>\nProcessing Request\n`;
break;
case Notification.MEDIA_AVAILABLE:
messageTitle = 'Now available!';
messageTitle = 'Now Available';
message += `${title}\n\n`;
message += `${plot}\n\n`;
message += `<b>Requested By</b>\n${username}\n\n`;
Expand All @@ -81,15 +81,14 @@ class PushoverAgent
break;
case Notification.TEST_NOTIFICATION:
messageTitle = 'Test Notification';
message += `${title}\n\n`;
message += `${plot}\n\n`;
message += `<b>Requested By</b>\n${username}\n`;
break;
}

if (settings.main.applicationUrl && payload.media) {
const actionUrl = `${settings.main.applicationUrl}/${payload.media.mediaType}/${payload.media.tmdbId}`;
message += `<a href="${actionUrl}">Open in Overseerr</a>`;
message += `<a href="${actionUrl}">Open in ${settings.main.applicationTitle}</a>`;
}

return { title: messageTitle, message };
Expand Down
2 changes: 1 addition & 1 deletion server/lib/notifications/agents/slack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class SlackAgent
value: 'open_overseerr',
text: {
type: 'plain_text',
text: 'Open Overseerr',
text: `Open ${settings.main.applicationTitle}`,
},
},
],
Expand Down
2 changes: 1 addition & 1 deletion server/lib/notifications/agents/telegram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class TelegramAgent

if (settings.main.applicationUrl && payload.media) {
const actionUrl = `${settings.main.applicationUrl}/${payload.media.mediaType}/${payload.media.tmdbId}`;
message += `\[Open in Overseerr\]\(${actionUrl}\)`;
message += `\[Open in ${settings.main.applicationTitle}\]\(${actionUrl}\)`;
}
/* eslint-enable */

Expand Down
6 changes: 3 additions & 3 deletions server/templates/email/media-request/html.pug
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ div(role='article' aria-roledescription='email' aria-label='' lang='en')
color: #a8aaaf;\
text-decoration: none;\
')
| Overseerr
| #{applicationTitle}
tr
td(style='width: 100%' width='100%')
table.sm-w-full(align='center' style='\
Expand Down Expand Up @@ -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 Media in Overseerr
a(href=actionUrl style='color: #3869d4') Open in #{applicationTitle}
tr
td
table.sm-w-full(align='center' style='\
Expand All @@ -111,4 +111,4 @@ tr
text-align: center;\
color: #a8aaaf;\
')
| Overseerr.
| #{applicationTitle}

0 comments on commit 38c76b5

Please sign in to comment.