Skip to content

Commit

Permalink
notifiers: make url param optional
Browse files Browse the repository at this point in the history
- note NotifierService.sendNotification() signature already declared
  'url' param as optional, but this change fixes some of the implementations
  that didn't respect the optionality.
  • Loading branch information
laur89 committed Feb 5, 2025
1 parent a5c7626 commit 4bc4b3e
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/notifiers/discord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class DiscordNotifier extends NotifierService {
},
],
title: 'Click to proceed',
url,
...(url ? { url } : {}),
},
],
},
Expand Down
2 changes: 1 addition & 1 deletion src/notifiers/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class EmailNotifier extends NotifierService {
to: this.config.emailRecipientAddress,
subject: `Epic Games free games needs an action performed`,
html: `<p><b>epicgames-freegames-node</b>, reason: ${reason}, account: ${account}.</p>
<p>Link: <a href="${url}">${url}</a></p>`,
${url ? `<p>Link: <a href="${url}">${url}</a></p>` : ''}`,
textEncoding: 'base64', // Some email clients don't like the '=' in the URL when using quoted-printable?
});
L.debug(
Expand Down
19 changes: 12 additions & 7 deletions src/notifiers/gotify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,26 @@ export class GotifyNotifier extends NotifierService {
const jsonPayload = {
title: `Epic Games free games needs an action performed`,
/**
* ATTENTION: these are markdown, to make it breaking lines correctly, there is two spaces at the end of line and before the retrun
* ATTENTION: these are markdown; to make lines break correctly, there
* are two spaces at the end of line and before the retrun
*/
message: `* Reason: ${reason}
* Account: ${account}
* URL: [${url}](${url})`,
${url ? `* URL: [${url}](${url})` : ''}`,
priority: this.config.priority,
extras: {
'client::display': {
contentType: 'text/markdown',
},
'client::notification': {
click: {
url,
},
},
...(url
? {
'client::notification': {
click: {
url,
},
}

Check failure on line 38 in src/notifiers/gotify.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `,`
}
: {}),
},
};

Expand Down
3 changes: 1 addition & 2 deletions src/notifiers/homeassistant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ export class HomeassistantNotifier extends NotifierService {
title: `Action request from Epic Games`,
message: `epicgames needs an action performed. Reason: ${reason} {{ '\n' -}} Link: ${url}`,
data: {
url,
clickAction: url,
...(url ? { url, clickAction: url } : {}),
...(this.config.customData ?? {}),
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/notifiers/ntfy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export class NtfyNotifier extends NotifierService {
Title: 'epicgames-freegames-node needs an action performed',
Priority: this.config.priority,
Tags: 'closed_lock_with_key',
Click: url,
Authorization: `Bearer ${this.config.token}`,
...(url ? { Click: url } : {}),
},
responseType: 'text',
},
Expand Down
2 changes: 1 addition & 1 deletion src/notifiers/pushover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class PushoverNotifier extends NotifierService {
token: this.config.token,
user: this.config.userKey,
message: `epicgames-freegames-node needs an action performed. Reason: ${reason}`,
url,
...(url ? { url } : {}),
},
{
responseType: 'json',
Expand Down
2 changes: 1 addition & 1 deletion src/notifiers/slack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class SlackNotifier extends NotifierService {
await axios.post(
this.config.webhookUrl,
{
text: `epicgames-freegames-node needs an action performed. \nReason: ${reason} \nAccount: ${account} \nURL: ${url}`,
text: `epicgames-freegames-node needs an action performed. \nReason: ${reason} \nAccount: ${account}${url ? ` \nURL: ${url}` : ''}`,
},
{
responseType: 'text',
Expand Down
2 changes: 1 addition & 1 deletion src/notifiers/webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class WebhookNotifier extends NotifierService {
{
account,
reason,
url,
...(url ? { url } : {}),
},
{
responseType: 'json',
Expand Down

0 comments on commit 4bc4b3e

Please sign in to comment.