X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=server%2Fcontrollers%2Fapi%2Fusers%2Fmy-blocklist.ts;h=6eba22d52ca0e3973c66668362edfb70577774aa;hb=ea3674d04dd0a67962224073256dc7d4173527a5;hp=3a44376f2d3424ac637b9dabf4ffe72476ed5003;hpb=aa9cf3b98d5db85fefce918bb29840d0cdcb84c4;p=github%2FChocobozzz%2FPeerTube.git 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() }