]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/models/server/server.ts
Don't send follow request if the follow is already accepted
[github/Chocobozzz/PeerTube.git] / server / models / server / server.ts
CommitLineData
f05a1c30 1import { AllowNull, Column, CreatedAt, HasMany, Is, Model, Table, UpdatedAt } from 'sequelize-typescript'
3fd3ab2d 2import { isHostValid } from '../../helpers/custom-validators/servers'
f05a1c30 3import { ActorModel } from '../activitypub/actor'
3fd3ab2d 4import { throwIfNotValid } from '../utils'
60862425 5
3fd3ab2d
C
6@Table({
7 tableName: 'server',
8 indexes: [
60862425 9 {
3fd3ab2d
C
10 fields: [ 'host' ],
11 unique: true
60862425 12 }
60862425 13 ]
3fd3ab2d
C
14})
15export class ServerModel extends Model<ServerModel> {
16
17 @AllowNull(false)
18 @Is('Host', value => throwIfNotValid(value, isHostValid, 'valid host'))
19 @Column
20 host: string
21
3fd3ab2d
C
22 @CreatedAt
23 createdAt: Date
24
25 @UpdatedAt
26 updatedAt: Date
f05a1c30
C
27
28 @HasMany(() => ActorModel, {
29 foreignKey: {
30 name: 'serverId',
31 allowNull: true
32 },
33 onDelete: 'CASCADE',
34 hooks: true
35 })
36 Actors: ActorModel[]
39445ead 37}