'/api/v1/video-channels/root_channel/videos',
'/api/v1/accounts/root/videos',
'/api/v1/videos',
- '/api/v1/search/videos'
+ '/api/v1/search/videos',
+ '/api/v1/users/me/subscriptions/videos'
]
for (const path of paths) {
it('Should list subscription videos', async function () {
{
- const body = await command.listVideos()
+ const body = await servers[0].videos.listMySubscriptionVideos()
expect(body.total).to.equal(0)
expect(body.data).to.be.an('array')
expect(body.data).to.have.lengthOf(0)
}
{
- const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' })
+ const body = await servers[0].videos.listMySubscriptionVideos({ token: users[0].accessToken, sort: 'createdAt' })
expect(body.total).to.equal(3)
const videos = body.data
expect(videos[1].name).to.equal('video 2-3')
expect(videos[2].name).to.equal('video server 3 added after follow')
}
+
+ {
+ const body = await servers[0].videos.listMySubscriptionVideos({ token: users[0].accessToken, count: 1, start: 1 })
+ expect(body.total).to.equal(3)
+
+ const videos = body.data
+ expect(videos).to.be.an('array')
+ expect(videos).to.have.lengthOf(1)
+
+ expect(videos[0].name).to.equal('video 2-3')
+ }
})
it('Should upload a video by root on server 1 and see it in the subscription videos', async function () {
await waitJobs(servers)
{
- const body = await command.listVideos()
+ const body = await servers[0].videos.listMySubscriptionVideos()
expect(body.total).to.equal(0)
expect(body.data).to.be.an('array')
expect(body.data).to.have.lengthOf(0)
}
{
- const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' })
+ const body = await servers[0].videos.listMySubscriptionVideos({ token: users[0].accessToken, sort: 'createdAt' })
expect(body.total).to.equal(4)
const videos = body.data
it('Should still list subscription videos', async function () {
{
- const body = await command.listVideos()
+ const body = await servers[0].videos.listMySubscriptionVideos()
expect(body.total).to.equal(0)
expect(body.data).to.be.an('array')
expect(body.data).to.have.lengthOf(0)
}
{
- const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' })
+ const body = await servers[0].videos.listMySubscriptionVideos({ token: users[0].accessToken, sort: 'createdAt' })
expect(body.total).to.equal(4)
const videos = body.data
await waitJobs(servers)
- const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' })
+ const body = await servers[0].videos.listMySubscriptionVideos({ token: users[0].accessToken, sort: 'createdAt' })
expect(body.data[2].name).to.equal('video server 3 added after follow updated')
})
})
})
it('Should not display its videos anymore', async function () {
- const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' })
+ const body = await servers[0].videos.listMySubscriptionVideos({ token: users[0].accessToken, sort: 'createdAt' })
expect(body.total).to.equal(1)
const videos = body.data
await waitJobs(servers)
{
- const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' })
+ const body = await servers[0].videos.listMySubscriptionVideos({ token: users[0].accessToken, sort: 'createdAt' })
expect(body.total).to.equal(3)
const videos = body.data
await waitJobs(servers)
{
- const { data } = await command.listVideos({ token: users[0].accessToken })
+ const { data } = await servers[0].videos.listMySubscriptionVideos({ token: users[0].accessToken })
expect(data.find(v => v.name === 'internal')).to.not.exist
}
})
it('Should see internal from local user', async function () {
- const { data } = await servers[2].subscriptions.listVideos({ token: servers[2].accessToken })
+ const { data } = await servers[2].videos.listMySubscriptionVideos({ token: servers[2].accessToken })
expect(data.find(v => v.name === 'internal')).to.exist
})
await waitJobs(servers)
{
- const { data } = await command.listVideos({ token: users[0].accessToken })
+ const { data } = await servers[0].videos.listMySubscriptionVideos({ token: users[0].accessToken })
expect(data.find(v => v.name === 'private')).to.not.exist
}
{
- const { data } = await servers[2].subscriptions.listVideos({ token: servers[2].accessToken })
+ const { data } = await servers[2].videos.listMySubscriptionVideos({ token: servers[2].accessToken })
expect(data.find(v => v.name === 'private')).to.not.exist
}
})
let paths: string[]
let remotePaths: string[]
+ const subscriptionVideosPath = '/api/v1/users/me/subscriptions/videos'
+
// ---------------------------------------------------------------
before(async function () {
const attributes = { name: 'private ' + server.serverNumber, privacy: VideoPrivacy.PRIVATE }
await server.videos.upload({ attributes })
}
+
+ // Subscribing to itself
+ await server.subscriptions.add({ targetUri: 'root_channel@' + server.host })
}
await doubleFollow(servers[0], servers[1])
`/api/v1/video-channels/root_channel/videos`,
`/api/v1/accounts/root/videos`,
'/api/v1/videos',
- '/api/v1/search/videos'
+ '/api/v1/search/videos',
+ subscriptionVideosPath
]
remotePaths = [
describe('Check deprecated videos filter', function () {
- async function getVideosNames (server: PeerTubeServer, token: string, filter: string, expectedStatus = HttpStatusCode.OK_200) {
+ async function getVideosNames (options: {
+ server: PeerTubeServer
+ token: string
+ filter: string
+ skipSubscription?: boolean
+ expectedStatus?: HttpStatusCode
+ }) {
+ const { server, token, filter, skipSubscription = false, expectedStatus = HttpStatusCode.OK_200 } = options
+
const videosResults: Video[][] = []
for (const path of paths) {
+ if (skipSubscription && path === subscriptionVideosPath) continue
+
const res = await makeGetRequest({
url: server.url,
path,
it('Should display local videos', async function () {
for (const server of servers) {
- const namesResults = await getVideosNames(server, server.accessToken, 'local')
+ const namesResults = await getVideosNames({ server, token: server.accessToken, filter: 'local' })
for (const names of namesResults) {
expect(names).to.have.lengthOf(1)
expect(names[0]).to.equal('public ' + server.serverNumber)
for (const server of servers) {
for (const token of [ server.accessToken, server['moderatorAccessToken'] ]) {
- const namesResults = await getVideosNames(server, token, 'all-local')
+ const namesResults = await getVideosNames({ server, token, filter: 'all-local', skipSubscription: true })
for (const names of namesResults) {
expect(names).to.have.lengthOf(3)
for (const server of servers) {
for (const token of [ server.accessToken, server['moderatorAccessToken'] ]) {
- const [ channelVideos, accountVideos, videos, searchVideos ] = await getVideosNames(server, token, 'all')
+ const [ channelVideos, accountVideos, videos, searchVideos ] = await getVideosNames({ server, token, filter: 'all' })
expect(channelVideos).to.have.lengthOf(3)
expect(accountVideos).to.have.lengthOf(3)
return res.body.data as Video[]
}
- async function getVideosNames (options: {
- server: PeerTubeServer
- isLocal?: boolean
- include?: VideoInclude
- privacyOneOf?: VideoPrivacy[]
- token?: string
- expectedStatus?: HttpStatusCode
- }) {
+ async function getVideosNames (
+ options: {
+ server: PeerTubeServer
+ isLocal?: boolean
+ include?: VideoInclude
+ privacyOneOf?: VideoPrivacy[]
+ token?: string
+ expectedStatus?: HttpStatusCode
+ skipSubscription?: boolean
+ }
+ ) {
+ const { skipSubscription = false } = options
const videosResults: string[][] = []
for (const path of paths) {
+ if (skipSubscription && path === subscriptionVideosPath) continue
+
const videos = await listVideos({ ...options, path })
videosResults.push(videos.map(v => v.name))
for (const server of servers) {
for (const token of [ server.accessToken, server['moderatorAccessToken'] ]) {
- const namesResults = await getVideosNames({
- server,
- token,
- isLocal: true,
- privacyOneOf: [ VideoPrivacy.UNLISTED, VideoPrivacy.PUBLIC, VideoPrivacy.PRIVATE ]
- })
+ const namesResults = await getVideosNames(
+ {
+ server,
+ token,
+ isLocal: true,
+ privacyOneOf: [ VideoPrivacy.UNLISTED, VideoPrivacy.PUBLIC, VideoPrivacy.PRIVATE ],
+ skipSubscription: true
+ }
+ )
for (const names of namesResults) {
expect(names).to.have.lengthOf(3)
}
{
- const body = await servers[0].subscriptions.listVideos({ token: feeduserAccessToken })
+ const body = await servers[0].videos.listMySubscriptionVideos({ token: feeduserAccessToken })
expect(body.total).to.equal(0)
const query = { accountId: feeduserAccountId, token: feeduserFeedToken }
})
it('Should list no videos for a user with videos but no subscriptions', async function () {
- const body = await servers[0].subscriptions.listVideos({ token: userAccessToken })
+ const body = await servers[0].videos.listMySubscriptionVideos({ token: userAccessToken })
expect(body.total).to.equal(0)
const query = { accountId: userAccountId, token: userFeedToken }
await waitJobs(servers)
{
- const body = await servers[0].subscriptions.listVideos({ token: userAccessToken })
+ const body = await servers[0].videos.listMySubscriptionVideos({ token: userAccessToken })
expect(body.total).to.equal(1)
expect(body.data[0].name).to.equal('user video')
await waitJobs(servers)
{
- const body = await servers[0].subscriptions.listVideos({ token: userAccessToken })
+ const body = await servers[0].videos.listMySubscriptionVideos({ token: userAccessToken })
expect(body.total).to.equal(2, 'there should be 2 videos part of the subscription')
const query = { accountId: userAccountId, token: userFeedToken }
registerHook({
target: 'filter:api.user.me.subscription-videos.list.params',
- handler: obj => Object.assign({}, obj, { count: 1 })
+ handler: obj => addToCount(obj)
})
registerHook({
})
it('Should run filter:api.user.me.subscription-videos.list.params', async function () {
- const { data } = await servers[0].subscriptions.listVideos()
+ const { data } = await servers[0].videos.listMySubscriptionVideos({ start: 0, count: 2 })
- // 1 plugin set the count parameter to 1
- expect(data).to.have.lengthOf(1)
+ // 1 plugin do +1 to the count parameter
+ expect(data).to.have.lengthOf(3)
})
it('Should run filter:api.user.me.subscription-videos.list.result', async function () {
- const { total } = await servers[0].subscriptions.listVideos()
+ const { total } = await servers[0].videos.listMySubscriptionVideos({ start: 0, count: 2 })
// Plugin do +4 to the total result
expect(total).to.equal(14)
-import { HttpStatusCode, ResultList, Video, VideoChannel } from '@shared/models'
+import { HttpStatusCode, ResultList, VideoChannel } from '@shared/models'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
export class SubscriptionsCommand extends AbstractCommand {
})
}
- listVideos (options: OverrideCommandOptions & {
- sort?: string // default -createdAt
- } = {}) {
- const { sort = '-createdAt' } = options
- const path = '/api/v1/users/me/subscriptions/videos'
-
- return this.getRequestBody<ResultList<Video>>({
- ...options,
-
- path,
- query: { sort },
- implicitToken: true,
- defaultExpectedStatus: HttpStatusCode.OK_200
- })
- }
-
get (options: OverrideCommandOptions & {
uri: string
}) {
})
}
+ listMySubscriptionVideos (options: OverrideCommandOptions & VideosCommonQuery = {}) {
+ const { sort = '-createdAt' } = options
+ const path = '/api/v1/users/me/subscriptions/videos'
+
+ return this.getRequestBody<ResultList<Video>>({
+ ...options,
+
+ path,
+ query: { sort, ...this.buildListQuery(options) },
+ implicitToken: true,
+ defaultExpectedStatus: HttpStatusCode.OK_200
+ })
+ }
+
// ---------------------------------------------------------------------------
list (options: OverrideCommandOptions & VideosCommonQuery = {}) {