X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fvideo%2Fvideo-blacklist.ts;h=1c279b1baefdb6eaa9edbc4313b5ecf2377b3ff0;hb=608624252466acf9f1d9ee1c1170bd4fe4d18d18;hp=dc49852b66a3ca8e239bd6ca61310ecf527c91b6;hpb=0aef76c479bc7fc758e70e1cd478ade46761b51b;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/video/video-blacklist.ts b/server/models/video/video-blacklist.ts index dc49852b6..1c279b1ba 100644 --- a/server/models/video/video-blacklist.ts +++ b/server/models/video/video-blacklist.ts @@ -1,6 +1,8 @@ import * as Sequelize from 'sequelize' -import { addMethodsToModel, getSort } from '../utils' +import { SortType } from '../../helpers' +import { addMethodsToModel, getSortOnModel } from '../utils' +import { VideoInstance } from './video-interface' import { BlacklistedVideoInstance, BlacklistedVideoAttributes, @@ -49,10 +51,23 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da // ------------------------------ METHODS ------------------------------ toFormattedJSON = function (this: BlacklistedVideoInstance) { + let video: VideoInstance + + video = this.Video + return { id: this.id, videoId: this.videoId, - createdAt: this.createdAt + createdAt: this.createdAt, + updatedAt: this.updatedAt, + name: video.name, + uuid: video.uuid, + description: video.description, + duration: video.duration, + views: video.views, + likes: video.likes, + dislikes: video.dislikes, + nsfw: video.nsfw } } @@ -76,11 +91,12 @@ list = function () { return BlacklistedVideo.findAll() } -listForApi = function (start: number, count: number, sort: string) { +listForApi = function (start: number, count: number, sort: SortType) { const query = { offset: start, limit: count, - order: [ getSort(sort) ] + order: [ getSortOnModel(sort.sortModel, sort.sortValue) ], + include: [ { model: BlacklistedVideo['sequelize'].models.Video } ] } return BlacklistedVideo.findAndCountAll(query).then(({ rows, count }) => {