]>
Commit | Line | Data |
---|---|---|
7ad9b984 C |
1 | import { sequelizeTypescript } from '../initializers' |
2 | import { AccountBlocklistModel } from '../models/account/account-blocklist' | |
3 | import { ServerBlocklistModel } from '../models/server/server-blocklist' | |
453e83ea | 4 | import { MAccountBlocklist, MServerBlocklist } from '@server/typings/models' |
7ad9b984 C |
5 | |
6 | function addAccountInBlocklist (byAccountId: number, targetAccountId: number) { | |
7 | return sequelizeTypescript.transaction(async t => { | |
af5767ff | 8 | return AccountBlocklistModel.upsert({ |
7ad9b984 C |
9 | accountId: byAccountId, |
10 | targetAccountId: targetAccountId | |
11 | }, { transaction: t }) | |
12 | }) | |
13 | } | |
14 | ||
15 | function addServerInBlocklist (byAccountId: number, targetServerId: number) { | |
16 | return sequelizeTypescript.transaction(async t => { | |
af5767ff | 17 | return ServerBlocklistModel.upsert({ |
7ad9b984 C |
18 | accountId: byAccountId, |
19 | targetServerId | |
20 | }, { transaction: t }) | |
21 | }) | |
22 | } | |
23 | ||
453e83ea | 24 | function removeAccountFromBlocklist (accountBlock: MAccountBlocklist) { |
7ad9b984 C |
25 | return sequelizeTypescript.transaction(async t => { |
26 | return accountBlock.destroy({ transaction: t }) | |
27 | }) | |
28 | } | |
29 | ||
453e83ea | 30 | function removeServerFromBlocklist (serverBlock: MServerBlocklist) { |
7ad9b984 C |
31 | return sequelizeTypescript.transaction(async t => { |
32 | return serverBlock.destroy({ transaction: t }) | |
33 | }) | |
34 | } | |
35 | ||
36 | export { | |
37 | addAccountInBlocklist, | |
38 | addServerInBlocklist, | |
39 | removeAccountFromBlocklist, | |
40 | removeServerFromBlocklist | |
41 | } |