From f1273314593a4a7dc7ec9594ce0c6c3ae8f62b34 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 16 Nov 2020 11:55:17 +0100 Subject: Add admin view to manage comments --- shared/extra-utils/videos/video-comments.ts | 37 ++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'shared') diff --git a/shared/extra-utils/videos/video-comments.ts b/shared/extra-utils/videos/video-comments.ts index 831e5e7d4..0b0df81dc 100644 --- a/shared/extra-utils/videos/video-comments.ts +++ b/shared/extra-utils/videos/video-comments.ts @@ -1,7 +1,41 @@ /* eslint-disable @typescript-eslint/no-floating-promises */ import * as request from 'supertest' -import { makeDeleteRequest } from '../requests/requests' +import { makeDeleteRequest, makeGetRequest } from '../requests/requests' + +function getAdminVideoComments (options: { + url: string + token: string + start: number + count: number + sort?: string + isLocal?: boolean + search?: string + searchAccount?: string + searchVideo?: string +}) { + const { url, token, start, count, sort, isLocal, search, searchAccount, searchVideo } = options + const path = '/api/v1/videos/comments' + + const query = { + start, + count, + sort: sort || '-createdAt' + } + + if (isLocal !== undefined) Object.assign(query, { isLocal }) + if (search !== undefined) Object.assign(query, { search }) + if (searchAccount !== undefined) Object.assign(query, { searchAccount }) + if (searchVideo !== undefined) Object.assign(query, { searchVideo }) + + return makeGetRequest({ + url, + path, + token, + query, + statusCodeExpected: 200 + }) +} function getVideoCommentThreads (url: string, videoId: number | string, start: number, count: number, sort?: string, token?: string) { const path = '/api/v1/videos/' + videoId + '/comment-threads' @@ -88,6 +122,7 @@ function deleteVideoComment ( export { getVideoCommentThreads, + getAdminVideoComments, getVideoThreadComments, addVideoCommentThread, addVideoCommentReply, -- cgit v1.2.3