MVideoPlaylistElementFormattable,
MVideoPlaylistElementVideoUrlPlaylistPrivacy,
MVideoPlaylistVideoThumbnail
-} from '@server/typings/models/video/video-playlist-element'
-import { MUserAccountId } from '@server/typings/models'
+} from '@server/types/models/video/video-playlist-element'
+import { MUserAccountId } from '@server/types/models'
@Table({
tableName: 'videoPlaylistElement',
{
fields: [ 'videoId' ]
},
- {
- fields: [ 'videoPlaylistId', 'videoId' ],
- unique: true
- },
{
fields: [ 'url' ],
unique: true
@UpdatedAt
updatedAt: Date
- @AllowNull(false)
- @Is('VideoPlaylistUrl', value => throwIfNotValid(value, isActivityPubUrlValid, 'url'))
+ @AllowNull(true)
+ @Is('VideoPlaylistUrl', value => throwIfNotValid(value, isActivityPubUrlValid, 'url', true))
@Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_PLAYLISTS.URL.max))
url: string
}
static listForApi (options: {
- start: number,
- count: number,
- videoPlaylistId: number,
- serverAccount: AccountModel,
+ start: number
+ count: number
+ videoPlaylistId: number
+ serverAccount: AccountModel
user?: MUserAccountId
}) {
const accountIds = [ options.serverAccount.id ]
return VideoPlaylistElementModel.findByPk(playlistElementId)
}
- static loadByPlaylistAndVideoForAP (
+ static loadByPlaylistAndElementIdForAP (
playlistId: number | string,
- videoId: number | string
+ playlistElementId: number
): Bluebird<MVideoPlaylistElementVideoUrlPlaylistPrivacy> {
const playlistWhere = validator.isUUID('' + playlistId) ? { uuid: playlistId } : { id: playlistId }
- const videoWhere = validator.isUUID('' + videoId) ? { uuid: videoId } : { id: videoId }
const query = {
include: [
},
{
attributes: [ 'url' ],
- model: VideoModel.unscoped(),
- where: videoWhere
+ model: VideoModel.unscoped()
}
- ]
+ ],
+ where: {
+ id: playlistElementId
+ }
}
return VideoPlaylistElementModel.findOne(query)
// Owned video, don't filter it
if (accountId && video.VideoChannel.Account.id === accountId) return VideoPlaylistElementType.REGULAR
- if (video.privacy === VideoPrivacy.PRIVATE) return VideoPlaylistElementType.PRIVATE
+ // Internal video?
+ if (video.privacy === VideoPrivacy.INTERNAL && accountId) return VideoPlaylistElementType.REGULAR
+
+ if (video.privacy === VideoPrivacy.PRIVATE || video.privacy === VideoPrivacy.INTERNAL) return VideoPlaylistElementType.PRIVATE
if (video.isBlacklisted() || video.isBlocked()) return VideoPlaylistElementType.UNAVAILABLE
if (video.nsfw === true && displayNSFW === false) return VideoPlaylistElementType.UNAVAILABLE