diff options
Diffstat (limited to 'server/models/server/server.ts')
-rw-r--r-- | server/models/server/server.ts | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/server/models/server/server.ts b/server/models/server/server.ts index 300d70938..1d211f1e0 100644 --- a/server/models/server/server.ts +++ b/server/models/server/server.ts | |||
@@ -2,6 +2,8 @@ import { AllowNull, Column, CreatedAt, Default, HasMany, Is, Model, Table, Updat | |||
2 | import { isHostValid } from '../../helpers/custom-validators/servers' | 2 | import { isHostValid } from '../../helpers/custom-validators/servers' |
3 | import { ActorModel } from '../activitypub/actor' | 3 | import { ActorModel } from '../activitypub/actor' |
4 | import { throwIfNotValid } from '../utils' | 4 | import { throwIfNotValid } from '../utils' |
5 | import { AccountBlocklistModel } from '../account/account-blocklist' | ||
6 | import { ServerBlocklistModel } from './server-blocklist' | ||
5 | 7 | ||
6 | @Table({ | 8 | @Table({ |
7 | tableName: 'server', | 9 | tableName: 'server', |
@@ -40,6 +42,14 @@ export class ServerModel extends Model<ServerModel> { | |||
40 | }) | 42 | }) |
41 | Actors: ActorModel[] | 43 | Actors: ActorModel[] |
42 | 44 | ||
45 | @HasMany(() => ServerBlocklistModel, { | ||
46 | foreignKey: { | ||
47 | allowNull: false | ||
48 | }, | ||
49 | onDelete: 'CASCADE' | ||
50 | }) | ||
51 | BlockedByAccounts: ServerBlocklistModel[] | ||
52 | |||
43 | static loadByHost (host: string) { | 53 | static loadByHost (host: string) { |
44 | const query = { | 54 | const query = { |
45 | where: { | 55 | where: { |
@@ -50,6 +60,10 @@ export class ServerModel extends Model<ServerModel> { | |||
50 | return ServerModel.findOne(query) | 60 | return ServerModel.findOne(query) |
51 | } | 61 | } |
52 | 62 | ||
63 | isBlocked () { | ||
64 | return this.BlockedByAccounts && this.BlockedByAccounts.length !== 0 | ||
65 | } | ||
66 | |||
53 | toFormattedJSON () { | 67 | toFormattedJSON () { |
54 | return { | 68 | return { |
55 | host: this.host | 69 | host: this.host |