mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 10:19:35 +02:00
Add ability for users to block an account/instance on server side
This commit is contained in:
parent
dffd5d127f
commit
7ad9b9846c
33 changed files with 1344 additions and 56 deletions
40
server/lib/blocklist.ts
Normal file
40
server/lib/blocklist.ts
Normal file
|
@ -0,0 +1,40 @@
|
|||
import { sequelizeTypescript } from '../initializers'
|
||||
import { AccountBlocklistModel } from '../models/account/account-blocklist'
|
||||
import { ServerBlocklistModel } from '../models/server/server-blocklist'
|
||||
|
||||
function addAccountInBlocklist (byAccountId: number, targetAccountId: number) {
|
||||
return sequelizeTypescript.transaction(async t => {
|
||||
return AccountBlocklistModel.create({
|
||||
accountId: byAccountId,
|
||||
targetAccountId: targetAccountId
|
||||
}, { transaction: t })
|
||||
})
|
||||
}
|
||||
|
||||
function addServerInBlocklist (byAccountId: number, targetServerId: number) {
|
||||
return sequelizeTypescript.transaction(async t => {
|
||||
return ServerBlocklistModel.create({
|
||||
accountId: byAccountId,
|
||||
targetServerId
|
||||
}, { transaction: t })
|
||||
})
|
||||
}
|
||||
|
||||
function removeAccountFromBlocklist (accountBlock: AccountBlocklistModel) {
|
||||
return sequelizeTypescript.transaction(async t => {
|
||||
return accountBlock.destroy({ transaction: t })
|
||||
})
|
||||
}
|
||||
|
||||
function removeServerFromBlocklist (serverBlock: ServerBlocklistModel) {
|
||||
return sequelizeTypescript.transaction(async t => {
|
||||
return serverBlock.destroy({ transaction: t })
|
||||
})
|
||||
}
|
||||
|
||||
export {
|
||||
addAccountInBlocklist,
|
||||
addServerInBlocklist,
|
||||
removeAccountFromBlocklist,
|
||||
removeServerFromBlocklist
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue