aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video-blacklist.ts
diff options
context:
space:
mode:
authorGreen-Star <Green-Star@users.noreply.github.com>2017-09-22 09:13:43 +0200
committerBigard Florian <florian.bigard@gmail.com>2017-09-22 09:13:43 +0200
commit792dbaf07f83fbe3f1d209cd9edf190442c7d2f3 (patch)
treef7edf9caf17baaaf95c219c3ac73d598e3fd3df8 /server/models/video/video-blacklist.ts
parentc9d6d155c397d0da0cb2d50064264fc1716f0501 (diff)
downloadPeerTube-792dbaf07f83fbe3f1d209cd9edf190442c7d2f3.tar.gz
PeerTube-792dbaf07f83fbe3f1d209cd9edf190442c7d2f3.tar.zst
PeerTube-792dbaf07f83fbe3f1d209cd9edf190442c7d2f3.zip
Handle blacklist (#84)
* Client: Add list blacklist feature * Server: Add list blacklist feature * Client: Add videoId column * Server: Add some video infos in the REST api * Client: Add video information in the blacklist list * Fix sortable columns :) * Client: Add removeFromBlacklist feature * Server: Add removeFromBlacklist feature * Move to TypeScript * Move to TypeScript and Promises * Server: Fix blacklist list sort * Server: Fetch videos informations * Use common shared interface for client and server * Add check-params remove blacklisted video tests * Add check-params list blacklisted videos tests * Add list blacklist tests * Add remove from blacklist tests * Add video blacklist management tests * Fix rebase onto develop issues * Server: Add sort on blacklist id column * Server: Add blacklists library * Add blacklist id sort test * Add check-params tests for blacklist list pagination, count and sort * Fix coding style * Increase Remote API tests timeout * Increase Request scheduler API tests timeout * Fix typo * Increase video transcoding API tests timeout * Move tests to Typescript * Use lodash orderBy method * Fix typos * Client: Remove optional tests in blacklist model attributes * Move blacklist routes from 'blacklists' to 'blacklist' * CLient: Remove blacklist-list.component.scss * Rename 'blacklists' files to 'blacklist' * Use only BlacklistedVideo interface * Server: Use getFormattedObjects method in listBlacklist method * Client: Use new coding style * Server: Use new sort validator methods * Server: Use new checkParams methods * Client: Fix sortable columns
Diffstat (limited to 'server/models/video/video-blacklist.ts')
-rw-r--r--server/models/video/video-blacklist.ts24
1 files changed, 20 insertions, 4 deletions
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 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2 2
3import { addMethodsToModel, getSort } from '../utils' 3import { SortType } from '../../helpers'
4import { addMethodsToModel, getSortOnModel } from '../utils'
5import { VideoInstance } from './video-interface'
4import { 6import {
5 BlacklistedVideoInstance, 7 BlacklistedVideoInstance,
6 BlacklistedVideoAttributes, 8 BlacklistedVideoAttributes,
@@ -49,10 +51,23 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da
49// ------------------------------ METHODS ------------------------------ 51// ------------------------------ METHODS ------------------------------
50 52
51toFormattedJSON = function (this: BlacklistedVideoInstance) { 53toFormattedJSON = function (this: BlacklistedVideoInstance) {
54 let video: VideoInstance
55
56 video = this.Video
57
52 return { 58 return {
53 id: this.id, 59 id: this.id,
54 videoId: this.videoId, 60 videoId: this.videoId,
55 createdAt: this.createdAt 61 createdAt: this.createdAt,
62 updatedAt: this.updatedAt,
63 name: video.name,
64 uuid: video.uuid,
65 description: video.description,
66 duration: video.duration,
67 views: video.views,
68 likes: video.likes,
69 dislikes: video.dislikes,
70 nsfw: video.nsfw
56 } 71 }
57} 72}
58 73
@@ -76,11 +91,12 @@ list = function () {
76 return BlacklistedVideo.findAll() 91 return BlacklistedVideo.findAll()
77} 92}
78 93
79listForApi = function (start: number, count: number, sort: string) { 94listForApi = function (start: number, count: number, sort: SortType) {
80 const query = { 95 const query = {
81 offset: start, 96 offset: start,
82 limit: count, 97 limit: count,
83 order: [ getSort(sort) ] 98 order: [ getSortOnModel(sort.sortModel, sort.sortValue) ],
99 include: [ { model: BlacklistedVideo['sequelize'].models.Video } ]
84 } 100 }
85 101
86 return BlacklistedVideo.findAndCountAll(query).then(({ rows, count }) => { 102 return BlacklistedVideo.findAndCountAll(query).then(({ rows, count }) => {