Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Fix my videos total counter

Chocobozzza65858746c1d
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index d216ed47dd..e6a8d3f955 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -972,7 +972,7 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
}) {
const { accountId, channelId, start, count, sort, search, isLive } = options
- function buildBaseQuery (): FindOptions {
+ function buildBaseQuery (forCount: boolean): FindOptions {
const where: WhereOptions = {}
if (search) {
@@ -1001,7 +1001,9 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
where: channelWhere,
include: [
{
- model: AccountModel,
+ model: forCount
+ ? AccountModel.unscoped()
+ : AccountModel,
where: {
id: accountId
},
@@ -1015,8 +1017,8 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
return baseQuery
}
- const countQuery = buildBaseQuery()
- const findQuery = buildBaseQuery()
+ const countQuery = buildBaseQuery(true)
+ const findQuery = buildBaseQuery(false)
const findScopes: (string | ScopeOptions)[] = [
ScopeNames.WITH_SCHEDULED_UPDATE,
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts
index a47713bf02..01b4c2eab1 100644
--- a/server/tests/api/users/users.ts
+++ b/server/tests/api/users/users.ts
@@ -622,6 +622,13 @@ describe('Test users', function () {
}
})
+ it('Should still have the same amount of videos in my account', async function () {
+ const { total, data } = await server.videos.listMyVideos({ token: userToken })
+
+ expect(total).to.equal(2)
+ expect(data).to.have.lengthOf(2)
+ })
+
it('Should be able to update my display name', async function () {
await server.users.updateMe({ token: userToken, displayName: 'new display name' })