X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fuser%2Fuser-video-history.ts;h=f4d0889a104c7bb8df09d80c065cce55024f4c8d;hb=91a4893063402d7beabb3104f9b989b8f88b6038;hp=6be1d65ea19e76d2e29d0f0b86960f102a02dea3;hpb=7d9ba5c08999c6482f0bc5e0c09c6f55b7724090;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/user/user-video-history.ts b/server/models/user/user-video-history.ts index 6be1d65ea..f4d0889a1 100644 --- a/server/models/user/user-video-history.ts +++ b/server/models/user/user-video-history.ts @@ -1,8 +1,9 @@ +import { DestroyOptions, Op, Transaction } from 'sequelize' import { AllowNull, BelongsTo, Column, CreatedAt, ForeignKey, IsInt, Model, Table, UpdatedAt } from 'sequelize-typescript' +import { MUserAccountId, MUserId } from '@server/types/models' +import { AttributesOnly } from '@shared/typescript-utils' import { VideoModel } from '../video/video' import { UserModel } from './user' -import { DestroyOptions, Op, Transaction } from 'sequelize' -import { MUserAccountId, MUserId } from '@server/types/models' @Table({ tableName: 'userVideoHistory', @@ -19,7 +20,7 @@ import { MUserAccountId, MUserId } from '@server/types/models' } ] }) -export class UserVideoHistoryModel extends Model { +export class UserVideoHistoryModel extends Model>> { @CreatedAt createdAt: Date @@ -62,13 +63,23 @@ export class UserVideoHistoryModel extends Model { search, sort: '-"userVideoHistory"."updatedAt"', nsfw: null, // All - includeLocalVideos: true, - withFiles: false, + 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: {