Skip to content

Commit 4bc4b3e

Browse files
committed
notifiers: make url param optional
- note NotifierService.sendNotification() signature already declared 'url' param as optional, but this change fixes some of the implementations that didn't respect the optionality.
1 parent a5c7626 commit 4bc4b3e

File tree

8 files changed

+19
-15
lines changed

8 files changed

+19
-15
lines changed

src/notifiers/discord.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class DiscordNotifier extends NotifierService {
4242
},
4343
],
4444
title: 'Click to proceed',
45-
url,
45+
...(url ? { url } : {}),
4646
},
4747
],
4848
},

src/notifiers/email.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class EmailNotifier extends NotifierService {
3636
to: this.config.emailRecipientAddress,
3737
subject: `Epic Games free games needs an action performed`,
3838
html: `<p><b>epicgames-freegames-node</b>, reason: ${reason}, account: ${account}.</p>
39-
<p>Link: <a href="${url}">${url}</a></p>`,
39+
${url ? `<p>Link: <a href="${url}">${url}</a></p>` : ''}`,
4040
textEncoding: 'base64', // Some email clients don't like the '=' in the URL when using quoted-printable?
4141
});
4242
L.debug(

src/notifiers/gotify.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,26 @@ export class GotifyNotifier extends NotifierService {
1818
const jsonPayload = {
1919
title: `Epic Games free games needs an action performed`,
2020
/**
21-
* ATTENTION: these are markdown, to make it breaking lines correctly, there is two spaces at the end of line and before the retrun
21+
* ATTENTION: these are markdown; to make lines break correctly, there
22+
* are two spaces at the end of line and before the retrun
2223
*/
2324
message: `* Reason: ${reason}
2425
* Account: ${account}
25-
* URL: [${url}](${url})`,
26+
${url ? `* URL: [${url}](${url})` : ''}`,
2627
priority: this.config.priority,
2728
extras: {
2829
'client::display': {
2930
contentType: 'text/markdown',
3031
},
31-
'client::notification': {
32-
click: {
33-
url,
34-
},
35-
},
32+
...(url
33+
? {
34+
'client::notification': {
35+
click: {
36+
url,
37+
},
38+
}
39+
}
40+
: {}),
3641
},
3742
};
3843

src/notifiers/homeassistant.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ export class HomeassistantNotifier extends NotifierService {
2323
title: `Action request from Epic Games`,
2424
message: `epicgames needs an action performed. Reason: ${reason} {{ '\n' -}} Link: ${url}`,
2525
data: {
26-
url,
27-
clickAction: url,
26+
...(url ? { url, clickAction: url } : {}),
2827
...(this.config.customData ?? {}),
2928
},
3029
},

src/notifiers/ntfy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ export class NtfyNotifier extends NotifierService {
2525
Title: 'epicgames-freegames-node needs an action performed',
2626
Priority: this.config.priority,
2727
Tags: 'closed_lock_with_key',
28-
Click: url,
2928
Authorization: `Bearer ${this.config.token}`,
29+
...(url ? { Click: url } : {}),
3030
},
3131
responseType: 'text',
3232
},

src/notifiers/pushover.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class PushoverNotifier extends NotifierService {
2323
token: this.config.token,
2424
user: this.config.userKey,
2525
message: `epicgames-freegames-node needs an action performed. Reason: ${reason}`,
26-
url,
26+
...(url ? { url } : {}),
2727
},
2828
{
2929
responseType: 'json',

src/notifiers/slack.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class SlackNotifier extends NotifierService {
2020
await axios.post(
2121
this.config.webhookUrl,
2222
{
23-
text: `epicgames-freegames-node needs an action performed. \nReason: ${reason} \nAccount: ${account} \nURL: ${url}`,
23+
text: `epicgames-freegames-node needs an action performed. \nReason: ${reason} \nAccount: ${account}${url ? ` \nURL: ${url}` : ''}`,
2424
},
2525
{
2626
responseType: 'text',

src/notifiers/webhook.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class WebhookNotifier extends NotifierService {
2222
{
2323
account,
2424
reason,
25-
url,
25+
...(url ? { url } : {}),
2626
},
2727
{
2828
responseType: 'json',

0 commit comments

Comments
 (0)