diff options
Diffstat (limited to 'server/controllers/api/users/my-blocklist.ts')
-rw-r--r-- | server/controllers/api/users/my-blocklist.ts | 14 |
1 files changed, 14 insertions, 0 deletions
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 { | |||
20 | import { AccountBlocklistModel } from '../../../models/account/account-blocklist' | 20 | import { AccountBlocklistModel } from '../../../models/account/account-blocklist' |
21 | import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist, removeServerFromBlocklist } from '../../../lib/blocklist' | 21 | import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist, removeServerFromBlocklist } from '../../../lib/blocklist' |
22 | import { ServerBlocklistModel } from '../../../models/server/server-blocklist' | 22 | import { ServerBlocklistModel } from '../../../models/server/server-blocklist' |
23 | import { UserNotificationModel } from '@server/models/account/user-notification' | ||
24 | import { logger } from '@server/helpers/logger' | ||
23 | 25 | ||
24 | const myBlocklistRouter = express.Router() | 26 | const myBlocklistRouter = express.Router() |
25 | 27 | ||
@@ -91,6 +93,12 @@ async function blockAccount (req: express.Request, res: express.Response) { | |||
91 | 93 | ||
92 | await addAccountInBlocklist(user.Account.id, accountToBlock.id) | 94 | await addAccountInBlocklist(user.Account.id, accountToBlock.id) |
93 | 95 | ||
96 | UserNotificationModel.removeNotificationsOf({ | ||
97 | id: accountToBlock.id, | ||
98 | type: 'account', | ||
99 | forUserId: user.id | ||
100 | }).catch(err => logger.error('Cannot remove notifications after an account mute.', { err })) | ||
101 | |||
94 | return res.status(204).end() | 102 | return res.status(204).end() |
95 | } | 103 | } |
96 | 104 | ||
@@ -122,6 +130,12 @@ async function blockServer (req: express.Request, res: express.Response) { | |||
122 | 130 | ||
123 | await addServerInBlocklist(user.Account.id, serverToBlock.id) | 131 | await addServerInBlocklist(user.Account.id, serverToBlock.id) |
124 | 132 | ||
133 | UserNotificationModel.removeNotificationsOf({ | ||
134 | id: serverToBlock.id, | ||
135 | type: 'server', | ||
136 | forUserId: user.id | ||
137 | }).catch(err => logger.error('Cannot remove notifications after a server mute.', { err })) | ||
138 | |||
125 | return res.status(204).end() | 139 | return res.status(204).end() |
126 | } | 140 | } |
127 | 141 | ||