mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2026-09-03 20:53:09 -05:00
Fix checking collaborated playlists
This commit is contained in:
@@ -75,21 +75,14 @@ my-timestamp-input {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.optional-row-icon {
|
.optional-row-icon {
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
font-size: 14px;
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
@include margin-left(0.5rem);
|
@include margin-left(0.5rem);
|
||||||
|
|
||||||
my-global-icon {
|
my-global-icon {
|
||||||
position: relative;
|
|
||||||
top: 1px;
|
|
||||||
width: 19px;
|
|
||||||
height: 19px;
|
|
||||||
color: pvar(--fg-400);
|
color: pvar(--fg-400);
|
||||||
|
|
||||||
@include margin-right(0);
|
@include global-icon-size(19px);
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
|
|||||||
@@ -1123,42 +1123,45 @@ describe('Test video playlists', function () {
|
|||||||
43000,
|
43000,
|
||||||
servers[0].store.videos[4].id
|
servers[0].store.videos[4].id
|
||||||
]
|
]
|
||||||
const obj = await commands[0].videosExist({ videoIds })
|
|
||||||
|
|
||||||
{
|
for (const token of [ editorToken, servers[0].accessToken ]) {
|
||||||
const elem = obj[servers[0].store.videos[0].id]
|
const obj = await commands[0].videosExist({ videoIds, token })
|
||||||
expect(elem).to.have.lengthOf(1)
|
|
||||||
expect(elem[0].playlistElementId).to.exist
|
{
|
||||||
expect(elem[0].playlistDisplayName).to.equal(playlistServer1DisplayName)
|
const elem = obj[servers[0].store.videos[0].id]
|
||||||
expect(elem[0].playlistShortUUID).to.equal(uuidToShort(playlistServer1UUID))
|
expect(elem).to.have.lengthOf(1)
|
||||||
expect(elem[0].playlistId).to.equal(playlistServer1Id)
|
expect(elem[0].playlistElementId).to.exist
|
||||||
expect(elem[0].startTimestamp).to.equal(15)
|
expect(elem[0].playlistDisplayName).to.equal(playlistServer1DisplayName)
|
||||||
expect(elem[0].stopTimestamp).to.equal(28)
|
expect(elem[0].playlistShortUUID).to.equal(uuidToShort(playlistServer1UUID))
|
||||||
|
expect(elem[0].playlistId).to.equal(playlistServer1Id)
|
||||||
|
expect(elem[0].startTimestamp).to.equal(15)
|
||||||
|
expect(elem[0].stopTimestamp).to.equal(28)
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const elem = obj[servers[0].store.videos[3].id]
|
||||||
|
expect(elem).to.have.lengthOf(1)
|
||||||
|
expect(elem[0].playlistElementId).to.equal(playlistElementServer1Video4)
|
||||||
|
expect(elem[0].playlistDisplayName).to.equal(playlistServer1DisplayName)
|
||||||
|
expect(elem[0].playlistShortUUID).to.equal(uuidToShort(playlistServer1UUID))
|
||||||
|
expect(elem[0].playlistId).to.equal(playlistServer1Id)
|
||||||
|
expect(elem[0].startTimestamp).to.equal(1)
|
||||||
|
expect(elem[0].stopTimestamp).to.equal(35)
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const elem = obj[servers[0].store.videos[4].id]
|
||||||
|
expect(elem).to.have.lengthOf(1)
|
||||||
|
expect(elem[0].playlistId).to.equal(playlistServer1Id)
|
||||||
|
expect(elem[0].playlistDisplayName).to.equal(playlistServer1DisplayName)
|
||||||
|
expect(elem[0].playlistShortUUID).to.equal(uuidToShort(playlistServer1UUID))
|
||||||
|
expect(elem[0].startTimestamp).to.equal(45)
|
||||||
|
expect(elem[0].stopTimestamp).to.equal(null)
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(obj[42000]).to.have.lengthOf(0)
|
||||||
|
expect(obj[43000]).to.have.lengthOf(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
const elem = obj[servers[0].store.videos[3].id]
|
|
||||||
expect(elem).to.have.lengthOf(1)
|
|
||||||
expect(elem[0].playlistElementId).to.equal(playlistElementServer1Video4)
|
|
||||||
expect(elem[0].playlistDisplayName).to.equal(playlistServer1DisplayName)
|
|
||||||
expect(elem[0].playlistShortUUID).to.equal(uuidToShort(playlistServer1UUID))
|
|
||||||
expect(elem[0].playlistId).to.equal(playlistServer1Id)
|
|
||||||
expect(elem[0].startTimestamp).to.equal(1)
|
|
||||||
expect(elem[0].stopTimestamp).to.equal(35)
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
const elem = obj[servers[0].store.videos[4].id]
|
|
||||||
expect(elem).to.have.lengthOf(1)
|
|
||||||
expect(elem[0].playlistId).to.equal(playlistServer1Id)
|
|
||||||
expect(elem[0].playlistDisplayName).to.equal(playlistServer1DisplayName)
|
|
||||||
expect(elem[0].playlistShortUUID).to.equal(uuidToShort(playlistServer1UUID))
|
|
||||||
expect(elem[0].startTimestamp).to.equal(45)
|
|
||||||
expect(elem[0].stopTimestamp).to.equal(null)
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(obj[42000]).to.have.lengthOf(0)
|
|
||||||
expect(obj[43000]).to.have.lengthOf(0)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should automatically update updatedAt field of playlists', async function () {
|
it('Should automatically update updatedAt field of playlists', async function () {
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ export class VideoChannelModel extends SequelizeModel<VideoChannelModel> {
|
|||||||
declare VideoPlaylists: Awaited<VideoPlaylistModel>[]
|
declare VideoPlaylists: Awaited<VideoPlaylistModel>[]
|
||||||
|
|
||||||
@HasMany(() => VideoChannelCollaboratorModel, {
|
@HasMany(() => VideoChannelCollaboratorModel, {
|
||||||
foreignKey: 'accountId',
|
foreignKey: 'channelId',
|
||||||
onDelete: 'CASCADE'
|
onDelete: 'CASCADE'
|
||||||
})
|
})
|
||||||
declare VideoChannelCollaborators: Awaited<VideoChannelCollaboratorModel>[]
|
declare VideoChannelCollaborators: Awaited<VideoChannelCollaboratorModel>[]
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ import { ListVideoPlaylistsOptions, VideoPlaylistListQueryBuilder } from './sql/
|
|||||||
import { ThumbnailModel } from './thumbnail.js'
|
import { ThumbnailModel } from './thumbnail.js'
|
||||||
import { VideoChannelModel, ScopeNames as VideoChannelScopeNames } from './video-channel.js'
|
import { VideoChannelModel, ScopeNames as VideoChannelScopeNames } from './video-channel.js'
|
||||||
import { VideoPlaylistElementModel } from './video-playlist-element.js'
|
import { VideoPlaylistElementModel } from './video-playlist-element.js'
|
||||||
|
import { VideoChannelCollaboratorModel } from './video-channel-collaborator.js'
|
||||||
|
|
||||||
enum ScopeNames {
|
enum ScopeNames {
|
||||||
WITH_VIDEOS_LENGTH = 'WITH_VIDEOS_LENGTH',
|
WITH_VIDEOS_LENGTH = 'WITH_VIDEOS_LENGTH',
|
||||||
@@ -313,27 +314,48 @@ export class VideoPlaylistModel extends SequelizeModel<VideoPlaylistModel> {
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
static listPlaylistSummariesOf (accountId: number, videoIds: number[]): Promise<MVideoPlaylistSummaryWithElements[]> {
|
static async listPlaylistSummariesOf (accountId: number, videoIds: number[]): Promise<MVideoPlaylistSummaryWithElements[]> {
|
||||||
const query = {
|
const elementsInclude = {
|
||||||
attributes: [ 'id', 'name', 'uuid' ],
|
attributes: [ 'id', 'videoId', 'startTimestamp', 'stopTimestamp' ],
|
||||||
|
model: VideoPlaylistElementModel.unscoped(),
|
||||||
where: {
|
where: {
|
||||||
ownerAccountId: accountId
|
videoId: {
|
||||||
},
|
[Op.in]: videoIds
|
||||||
include: [
|
|
||||||
{
|
|
||||||
attributes: [ 'id', 'videoId', 'startTimestamp', 'stopTimestamp' ],
|
|
||||||
model: VideoPlaylistElementModel.unscoped(),
|
|
||||||
where: {
|
|
||||||
videoId: {
|
|
||||||
[Op.in]: videoIds
|
|
||||||
}
|
|
||||||
},
|
|
||||||
required: true
|
|
||||||
}
|
}
|
||||||
]
|
},
|
||||||
|
required: true
|
||||||
}
|
}
|
||||||
|
|
||||||
return VideoPlaylistModel.findAll(query)
|
const attributes = [ 'id', 'name', 'uuid' ]
|
||||||
|
|
||||||
|
const owned = await VideoPlaylistModel.findAll({
|
||||||
|
attributes,
|
||||||
|
where: { ownerAccountId: accountId },
|
||||||
|
include: [ elementsInclude ]
|
||||||
|
})
|
||||||
|
|
||||||
|
const collaborations = await VideoPlaylistModel.findAll({
|
||||||
|
attributes,
|
||||||
|
include: [
|
||||||
|
elementsInclude,
|
||||||
|
|
||||||
|
{
|
||||||
|
model: VideoChannelModel.unscoped(),
|
||||||
|
required: true,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
model: VideoChannelCollaboratorModel.unscoped(),
|
||||||
|
required: true,
|
||||||
|
where: {
|
||||||
|
accountId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
return [ ...owned, ...collaborations ]
|
||||||
}
|
}
|
||||||
|
|
||||||
static listPlaylistForExport (accountId: number): Promise<MVideoPlaylistFull[]> {
|
static listPlaylistForExport (accountId: number): Promise<MVideoPlaylistFull[]> {
|
||||||
|
|||||||
Reference in New Issue
Block a user