mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2024-12-01 12:59:15 -06:00
2e401e8575
* store uploaded video filename closes #4731 * dont crash if videos channel exist * migration: use raw query * video source: fixes after code review * cleanup * bump migration * updates after code review * refactor: use checkUserCanManageVideo * videoSource: add openapi doc * test(check-params/video-source): fix timeout * Styling * Correctly set original filename as source Co-authored-by: Chocobozzz <me@florianbigard.com>
56 lines
927 B
TypeScript
56 lines
927 B
TypeScript
import { Op } from 'sequelize'
|
|
import {
|
|
AllowNull,
|
|
BelongsTo,
|
|
Column,
|
|
CreatedAt,
|
|
ForeignKey,
|
|
Model,
|
|
Table,
|
|
UpdatedAt
|
|
} from 'sequelize-typescript'
|
|
import { AttributesOnly } from '@shared/typescript-utils'
|
|
import { VideoModel } from './video'
|
|
|
|
@Table({
|
|
tableName: 'videoSource',
|
|
indexes: [
|
|
{
|
|
fields: [ 'videoId' ],
|
|
where: {
|
|
videoId: {
|
|
[Op.ne]: null
|
|
}
|
|
}
|
|
}
|
|
]
|
|
})
|
|
export class VideoSourceModel extends Model<Partial<AttributesOnly<VideoSourceModel>>> {
|
|
@CreatedAt
|
|
createdAt: Date
|
|
|
|
@UpdatedAt
|
|
updatedAt: Date
|
|
|
|
@AllowNull(false)
|
|
@Column
|
|
filename: string
|
|
|
|
@ForeignKey(() => VideoModel)
|
|
@Column
|
|
videoId: number
|
|
|
|
@BelongsTo(() => VideoModel)
|
|
Video: VideoModel
|
|
|
|
static loadByVideoId (videoId) {
|
|
return VideoSourceModel.findOne({ where: { videoId } })
|
|
}
|
|
|
|
toFormattedJSON () {
|
|
return {
|
|
filename: this.filename
|
|
}
|
|
}
|
|
}
|