if (user.Account.id === accountToBlock.id) {
res.status(409)
- .send({ error: 'You cannot block yourself.' })
- .end()
+ .json({ error: 'You cannot block yourself.' })
return
}
if (host === WEBSERVER.HOST) {
return res.status(409)
- .send({ error: 'You cannot block your own server.' })
- .end()
+ .json({ error: 'You cannot block your own server.' })
}
- let server = await ServerModel.loadByHost(host)
- if (!server) {
- server = await ServerModel.create({ host })
- }
+ const server = await ServerModel.loadOrCreateByHost(host)
res.locals.server = server
const accountBlock = await AccountBlocklistModel.loadByAccountAndTarget(accountId, targetAccountId)
if (!accountBlock) {
res.status(404)
- .send({ error: 'Account block entry not found.' })
- .end()
+ .json({ error: 'Account block entry not found.' })
return false
}
const serverBlock = await ServerBlocklistModel.loadByAccountAndHost(accountId, host)
if (!serverBlock) {
res.status(404)
- .send({ error: 'Server block entry not found.' })
- .end()
+ .json({ error: 'Server block entry not found.' })
return false
}