From 38c76b55e0039c489cb6a4a0a298aa6385406db4 Mon Sep 17 00:00:00 2001 From: TheCatLady <52870424+TheCatLady@users.noreply.github.com> Date: Thu, 4 Feb 2021 21:15:57 -0500 Subject: [PATCH] fix(notif/ui): Use custom application title in notifications & sign-in page (#849) --- server/api/plexapi.ts | 2 +- server/lib/notifications/agents/email.ts | 18 +- server/lib/notifications/agents/pushover.ts | 5 +- server/lib/notifications/agents/slack.ts | 2 +- server/lib/notifications/agents/telegram.ts | 2 +- server/templates/email/media-request/html.pug | 6 +- .../email/media-request/media-request.html | 224 ------------------ .../templates/email/media-request/subject.pug | 2 +- server/templates/email/password/html.pug | 6 +- server/templates/email/password/subject.pug | 2 +- server/templates/email/test-email/html.pug | 6 +- server/templates/email/test-email/subject.pug | 2 +- src/components/Login/index.tsx | 7 +- src/i18n/locale/en.json | 2 +- 14 files changed, 35 insertions(+), 251 deletions(-) delete mode 100644 server/templates/email/media-request/media-request.html diff --git a/server/api/plexapi.ts b/server/api/plexapi.ts index b87dc342..f920a5b3 100644 --- a/server/api/plexapi.ts +++ b/server/api/plexapi.ts @@ -118,7 +118,7 @@ class PlexAPI { options: { identifier: settings.clientId, product: 'Overseerr', - deviceName: 'Overseerr', + deviceName: settings.main.applicationTitle, platform: 'Overseerr', }, }); diff --git a/server/lib/notifications/agents/email.ts b/server/lib/notifications/agents/email.ts index ccb42802..c5c2fe83 100644 --- a/server/lib/notifications/agents/email.ts +++ b/server/lib/notifications/agents/email.ts @@ -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(); @@ -65,6 +65,7 @@ class EmailAgent ? `${applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}` : undefined, applicationUrl, + applicationTitle, requestType: 'New Request', }, }); @@ -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(); @@ -111,6 +112,7 @@ class EmailAgent ? `${applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}` : undefined, applicationUrl, + applicationTitle, requestType: 'Failed Request', }, }); @@ -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(); @@ -149,6 +151,7 @@ class EmailAgent ? `${applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}` : undefined, applicationUrl, + applicationTitle, requestType: 'Request Approved', }, }); @@ -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(); @@ -186,6 +189,7 @@ class EmailAgent ? `${applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}` : undefined, applicationUrl, + applicationTitle, requestType: 'Request Declined', }, }); @@ -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(); @@ -223,6 +227,7 @@ class EmailAgent ? `${applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}` : undefined, applicationUrl, + applicationTitle, requestType: 'Now Available', }, }); @@ -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(); @@ -250,6 +255,7 @@ class EmailAgent locals: { body: payload.message, applicationUrl, + applicationTitle, }, }); return true; diff --git a/server/lib/notifications/agents/pushover.ts b/server/lib/notifications/agents/pushover.ts index 5b7713b0..52f538aa 100644 --- a/server/lib/notifications/agents/pushover.ts +++ b/server/lib/notifications/agents/pushover.ts @@ -66,7 +66,7 @@ class PushoverAgent message += `Status\nProcessing Request\n`; break; case Notification.MEDIA_AVAILABLE: - messageTitle = 'Now available!'; + messageTitle = 'Now Available'; message += `${title}\n\n`; message += `${plot}\n\n`; message += `Requested By\n${username}\n\n`; @@ -81,7 +81,6 @@ class PushoverAgent break; case Notification.TEST_NOTIFICATION: messageTitle = 'Test Notification'; - message += `${title}\n\n`; message += `${plot}\n\n`; message += `Requested By\n${username}\n`; break; @@ -89,7 +88,7 @@ class PushoverAgent if (settings.main.applicationUrl && payload.media) { const actionUrl = `${settings.main.applicationUrl}/${payload.media.mediaType}/${payload.media.tmdbId}`; - message += `Open in Overseerr`; + message += `Open in ${settings.main.applicationTitle}`; } return { title: messageTitle, message }; diff --git a/server/lib/notifications/agents/slack.ts b/server/lib/notifications/agents/slack.ts index 269ab667..318bbfeb 100644 --- a/server/lib/notifications/agents/slack.ts +++ b/server/lib/notifications/agents/slack.ts @@ -191,7 +191,7 @@ class SlackAgent value: 'open_overseerr', text: { type: 'plain_text', - text: 'Open Overseerr', + text: `Open ${settings.main.applicationTitle}`, }, }, ], diff --git a/server/lib/notifications/agents/telegram.ts b/server/lib/notifications/agents/telegram.ts index a2b09c1c..2e08cbdf 100644 --- a/server/lib/notifications/agents/telegram.ts +++ b/server/lib/notifications/agents/telegram.ts @@ -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 */ diff --git a/server/templates/email/media-request/html.pug b/server/templates/email/media-request/html.pug index e2c0931d..814fcab0 100644 --- a/server/templates/email/media-request/html.pug +++ b/server/templates/email/media-request/html.pug @@ -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='\ @@ -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='\ @@ -111,4 +111,4 @@ tr text-align: center;\ color: #a8aaaf;\ ') - | Overseerr. + | #{applicationTitle} diff --git a/server/templates/email/media-request/media-request.html b/server/templates/email/media-request/media-request.html deleted file mode 100644 index 3f38d04b..00000000 --- a/server/templates/email/media-request/media-request.html +++ /dev/null @@ -1,224 +0,0 @@ - - - - - - - - - - - - - - -
- - - - -
- - - - - - - -
- - Overseerr - -
- - - - - -
-

- Requested by {{requester_name}} at {{timestamp}} -

-

- Open detail page -

-
-
- - - - - - - - - - - diff --git a/server/templates/email/media-request/subject.pug b/server/templates/email/media-request/subject.pug index 02046bd5..e1c43065 100644 --- a/server/templates/email/media-request/subject.pug +++ b/server/templates/email/media-request/subject.pug @@ -1 +1 @@ -= `${requestType}: ${mediaName} - Overseerr` += `${requestType}: ${mediaName} - ${applicationTitle}` diff --git a/server/templates/email/password/html.pug b/server/templates/email/password/html.pug index afa2cdb8..1fa4713f 100644 --- a/server/templates/email/password/html.pug +++ b/server/templates/email/password/html.pug @@ -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='\ @@ -76,7 +76,7 @@ div(role='article' aria-roledescription='email' aria-label='' lang='en') margin-bottom: 20px;\ color: #51545e;\ ') - a(href=applicationUrl style='color: #3869d4') Open Overseerr + a(href=applicationUrl style='color: #3869d4') Open #{applicationTitle} tr td table.sm-w-full(align='center' style='\ @@ -95,4 +95,4 @@ tr text-align: center;\ color: #a8aaaf;\ ') - | Overseerr. + | #{applicationTitle} diff --git a/server/templates/email/password/subject.pug b/server/templates/email/password/subject.pug index 51196b1d..e9135b7e 100644 --- a/server/templates/email/password/subject.pug +++ b/server/templates/email/password/subject.pug @@ -1 +1 @@ -= `Password reset - Overseerr` += `Password Reset - ${applicationTitle}` diff --git a/server/templates/email/test-email/html.pug b/server/templates/email/test-email/html.pug index d9f6063d..b4abfebb 100644 --- a/server/templates/email/test-email/html.pug +++ b/server/templates/email/test-email/html.pug @@ -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='\ @@ -74,7 +74,7 @@ div(role='article' aria-roledescription='email' aria-label='' lang='en') margin-bottom: 20px;\ color: #51545e;\ ') - a(href=applicationUrl style='color: #3869d4') Open Overseerr + a(href=applicationUrl style='color: #3869d4') Open #{applicationTitle} tr td table.sm-w-full(align='center' style='\ @@ -93,4 +93,4 @@ tr text-align: center;\ color: #a8aaaf;\ ') - | Overseerr. + | #{applicationTitle} diff --git a/server/templates/email/test-email/subject.pug b/server/templates/email/test-email/subject.pug index 6e50c1b5..c138fe15 100644 --- a/server/templates/email/test-email/subject.pug +++ b/server/templates/email/test-email/subject.pug @@ -1 +1 @@ -= `Test Notification - Overseerr` += `Test Notification - ${applicationTitle}` diff --git a/src/components/Login/index.tsx b/src/components/Login/index.tsx index c4fd93a6..f46cea19 100644 --- a/src/components/Login/index.tsx +++ b/src/components/Login/index.tsx @@ -16,7 +16,7 @@ const messages = defineMessages({ signin: 'Sign In', signinheader: 'Sign in to continue', signinwithplex: 'Use your Plex account', - signinwithoverseerr: 'Use your Overseerr account', + signinwithoverseerr: 'Use your {applicationTitle} account', }); const Login: React.FC = () => { @@ -154,7 +154,10 @@ const Login: React.FC = () => { }`} onClick={() => handleClick(1)} > - {intl.formatMessage(messages.signinwithoverseerr)} + {intl.formatMessage(messages.signinwithoverseerr, { + applicationTitle: + settings.currentSettings.applicationTitle, + })}
diff --git a/src/i18n/locale/en.json b/src/i18n/locale/en.json index c6fb2656..bcf61ed1 100644 --- a/src/i18n/locale/en.json +++ b/src/i18n/locale/en.json @@ -36,7 +36,7 @@ "components.Login.signin": "Sign In", "components.Login.signingin": "Signing in…", "components.Login.signinheader": "Sign in to continue", - "components.Login.signinwithoverseerr": "Use your Overseerr account", + "components.Login.signinwithoverseerr": "Use your {applicationTitle} account", "components.Login.signinwithplex": "Use your Plex account", "components.Login.validationemailrequired": "Not a valid email address", "components.Login.validationpasswordrequired": "Password required",