diff options
Diffstat (limited to 'server/models/video/video-share.ts')
-rw-r--r-- | server/models/video/video-share.ts | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/server/models/video/video-share.ts b/server/models/video/video-share.ts index 56576f98c..48ba68a4a 100644 --- a/server/models/video/video-share.ts +++ b/server/models/video/video-share.ts | |||
@@ -1,7 +1,10 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | import { BelongsTo, Column, CreatedAt, ForeignKey, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript' | 2 | import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Is, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript' |
3 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' | ||
4 | import { CONSTRAINTS_FIELDS } from '../../initializers' | ||
3 | import { AccountModel } from '../account/account' | 5 | import { AccountModel } from '../account/account' |
4 | import { ActorModel } from '../activitypub/actor' | 6 | import { ActorModel } from '../activitypub/actor' |
7 | import { throwIfNotValid } from '../utils' | ||
5 | import { VideoModel } from './video' | 8 | import { VideoModel } from './video' |
6 | import { VideoChannelModel } from './video-channel' | 9 | import { VideoChannelModel } from './video-channel' |
7 | 10 | ||
@@ -40,10 +43,20 @@ enum ScopeNames { | |||
40 | }, | 43 | }, |
41 | { | 44 | { |
42 | fields: [ 'videoId' ] | 45 | fields: [ 'videoId' ] |
46 | }, | ||
47 | { | ||
48 | fields: [ 'url' ], | ||
49 | unique: true | ||
43 | } | 50 | } |
44 | ] | 51 | ] |
45 | }) | 52 | }) |
46 | export class VideoShareModel extends Model<VideoShareModel> { | 53 | export class VideoShareModel extends Model<VideoShareModel> { |
54 | |||
55 | @AllowNull(false) | ||
56 | @Is('VideoShareUrl', value => throwIfNotValid(value, isActivityPubUrlValid, 'url')) | ||
57 | @Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_SHARE.URL.max)) | ||
58 | url: string | ||
59 | |||
47 | @CreatedAt | 60 | @CreatedAt |
48 | createdAt: Date | 61 | createdAt: Date |
49 | 62 | ||