From ea3674d04dd0a67962224073256dc7d4173527a5 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 18 Nov 2020 11:13:01 +0100 Subject: Remove notifications of muted accounts/servers --- server/controllers/api/users/my-blocklist.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'server/controllers/api/users/my-blocklist.ts') diff --git a/server/controllers/api/users/my-blocklist.ts b/server/controllers/api/users/my-blocklist.ts index 3a44376f2..6eba22d52 100644 --- a/server/controllers/api/users/my-blocklist.ts +++ b/server/controllers/api/users/my-blocklist.ts @@ -20,6 +20,8 @@ import { import { AccountBlocklistModel } from '../../../models/account/account-blocklist' import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist, removeServerFromBlocklist } from '../../../lib/blocklist' import { ServerBlocklistModel } from '../../../models/server/server-blocklist' +import { UserNotificationModel } from '@server/models/account/user-notification' +import { logger } from '@server/helpers/logger' const myBlocklistRouter = express.Router() @@ -91,6 +93,12 @@ async function blockAccount (req: express.Request, res: express.Response) { await addAccountInBlocklist(user.Account.id, accountToBlock.id) + UserNotificationModel.removeNotificationsOf({ + id: accountToBlock.id, + type: 'account', + forUserId: user.id + }).catch(err => logger.error('Cannot remove notifications after an account mute.', { err })) + return res.status(204).end() } @@ -122,6 +130,12 @@ async function blockServer (req: express.Request, res: express.Response) { await addServerInBlocklist(user.Account.id, serverToBlock.id) + UserNotificationModel.removeNotificationsOf({ + id: serverToBlock.id, + type: 'server', + forUserId: user.id + }).catch(err => logger.error('Cannot remove notifications after a server mute.', { err })) + return res.status(204).end() } -- cgit v1.2.3