aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video-share.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video/video-share.ts')
-rw-r--r--server/models/video/video-share.ts15
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 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2import { BelongsTo, Column, CreatedAt, ForeignKey, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript' 2import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Is, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript'
3import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc'
4import { CONSTRAINTS_FIELDS } from '../../initializers'
3import { AccountModel } from '../account/account' 5import { AccountModel } from '../account/account'
4import { ActorModel } from '../activitypub/actor' 6import { ActorModel } from '../activitypub/actor'
7import { throwIfNotValid } from '../utils'
5import { VideoModel } from './video' 8import { VideoModel } from './video'
6import { VideoChannelModel } from './video-channel' 9import { 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})
46export class VideoShareModel extends Model<VideoShareModel> { 53export 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