fix(notifications): correctly send notifications for users that do not have any user settings yet

fixes #1324
pull/1303/head
sct 4 years ago
parent a908c07670
commit d3a25b935a
No known key found for this signature in database
GPG Key ID: 06A50468C67E272F

@ -218,7 +218,7 @@ class DiscordAgent
if (
payload.notifyUser &&
payload.notifyUser.settings?.enableNotifications &&
(payload.notifyUser.settings?.enableNotifications ?? true) &&
payload.notifyUser.settings?.discordId
) {
mentionedUsers.push(payload.notifyUser.settings.discordId);

@ -1,13 +1,13 @@
import { BaseAgent, NotificationAgent, NotificationPayload } from './agent';
import { hasNotificationType, Notification } from '..';
import path from 'path';
import { getSettings, NotificationAgentEmail } from '../../settings';
import logger from '../../../logger';
import { getRepository } from 'typeorm';
import { hasNotificationType, Notification } from '..';
import { MediaType } from '../../../constants/media';
import { User } from '../../../entity/User';
import { Permission } from '../../permissions';
import logger from '../../../logger';
import PreparedEmail from '../../email';
import { MediaType } from '../../../constants/media';
import { Permission } from '../../permissions';
import { getSettings, NotificationAgentEmail } from '../../settings';
import { BaseAgent, NotificationAgent, NotificationPayload } from './agent';
class EmailAgent
extends BaseAgent<NotificationAgentEmail>
@ -154,7 +154,7 @@ class EmailAgent
try {
if (
payload.notifyUser &&
payload.notifyUser.settings?.enableNotifications
(payload.notifyUser.settings?.enableNotifications ?? true)
) {
const email = new PreparedEmail(payload.notifyUser.settings?.pgpKey);
@ -258,7 +258,7 @@ class EmailAgent
try {
if (
payload.notifyUser &&
payload.notifyUser.settings?.enableNotifications
(payload.notifyUser.settings?.enableNotifications ?? true)
) {
const email = new PreparedEmail(payload.notifyUser.settings?.pgpKey);
@ -307,7 +307,7 @@ class EmailAgent
try {
if (
payload.notifyUser &&
payload.notifyUser.settings?.enableNotifications
(payload.notifyUser.settings?.enableNotifications ?? true)
) {
const email = new PreparedEmail(payload.notifyUser.settings?.pgpKey);

@ -1,8 +1,8 @@
import axios from 'axios';
import { hasNotificationType, Notification } from '..';
import { MediaType } from '../../../constants/media';
import logger from '../../../logger';
import { getSettings, NotificationAgentTelegram } from '../../settings';
import { MediaType } from '../../../constants/media';
import { BaseAgent, NotificationAgent, NotificationPayload } from './agent';
interface TelegramMessagePayload {
@ -180,7 +180,7 @@ class TelegramAgent
// Send user notification
if (
payload.notifyUser &&
payload.notifyUser.settings?.enableNotifications &&
(payload.notifyUser.settings?.enableNotifications ?? true) &&
payload.notifyUser.settings?.telegramChatId &&
payload.notifyUser.settings?.telegramChatId !==
this.getSettings().options.chatId

Loading…
Cancel
Save