]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/user/user-video-history.ts
Don't fail remote transcoding on retry
[github/Chocobozzz/PeerTube.git] / server / models / user / user-video-history.ts
index 6d9f2e03f72521a9c6b2890f23d62e9134b99737..f4d0889a104c7bb8df09d80c065cce55024f4c8d 100644 (file)
@@ -4,7 +4,6 @@ import { MUserAccountId, MUserId } from '@server/types/models'
 import { AttributesOnly } from '@shared/typescript-utils'
 import { VideoModel } from '../video/video'
 import { UserModel } from './user'
-import { getServerActor } from '../application/application'
 
 @Table({
   tableName: 'userVideoHistory',
@@ -57,24 +56,30 @@ export class UserVideoHistoryModel extends Model<Partial<AttributesOnly<UserVide
   })
   User: UserModel
 
-  static async listForApi (user: MUserAccountId, start: number, count: number, search?: string) {
-    const serverActor = await getServerActor()
-
+  static listForApi (user: MUserAccountId, start: number, count: number, search?: string) {
     return VideoModel.listForApi({
       start,
       count,
       search,
       sort: '-"userVideoHistory"."updatedAt"',
       nsfw: null, // All
-      displayOnlyForFollower: {
-        actorId: serverActor.id,
-        orLocalVideos: true
-      },
+      displayOnlyForFollower: null,
       user,
       historyOfUser: user
     })
   }
 
+  static removeUserHistoryElement (user: MUserId, videoId: number) {
+    const query: DestroyOptions = {
+      where: {
+        userId: user.id,
+        videoId
+      }
+    }
+
+    return UserVideoHistoryModel.destroy(query)
+  }
+
   static removeUserHistoryBefore (user: MUserId, beforeDate: string, t: Transaction) {
     const query: DestroyOptions = {
       where: {