1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 19:42:24 +02:00

Add ability for admins to refuse remote comments

This commit is contained in:
Chocobozzz 2025-06-18 09:29:45 +02:00
parent 031b61c466
commit f5fd593976
No known key found for this signature in database
GPG key ID: 583A612D890159BE
12 changed files with 157 additions and 14 deletions

View file

@ -1,3 +1,4 @@
import { arrayify } from '@peertube/peertube-core-utils'
import {
AbuseObject,
ActivityCreate,
@ -9,6 +10,7 @@ import {
VideoObject,
WatchActionObject
} from '@peertube/peertube-models'
import { CONFIG } from '@server/initializers/config.js'
import { isBlockedByServerOrAccount } from '@server/lib/blocklist.js'
import { isRedundancyAccepted } from '@server/lib/redundancy.js'
import { VideoCommentModel } from '@server/models/video/video-comment.js'
@ -27,7 +29,6 @@ import { sendReplyApproval } from '../send/send-reply-approval.js'
import { forwardVideoRelatedActivity } from '../send/shared/send-utils.js'
import { resolveThread } from '../video-comments.js'
import { canVideoBeFederated, getOrCreateAPVideo } from '../videos/index.js'
import { arrayify } from '@peertube/peertube-core-utils'
async function processCreateActivity (options: APProcessorOptions<ActivityCreate<ActivityCreateObject>>) {
const { activity, byActor } = options
@ -123,10 +124,11 @@ async function processCreateVideoComment (
byActor: MActorSignature,
fromFetch: false
) {
if (CONFIG.VIDEO_COMMENTS.ACCEPT_REMOTE_COMMENTS !== true) return
if (fromFetch) throw new Error('Processing create video comment from fetch is not supported')
const byAccount = byActor.Account
if (!byAccount) throw new Error('Cannot create video comment with the non account actor ' + byActor.url)
let video: MVideoAccountLightBlacklistAllFiles

View file

@ -20,6 +20,7 @@ import { fetchAP } from './activity.js'
import { getOrCreateAPActor } from './actors/index.js'
import { checkUrlsSameHost } from './url.js'
import { canVideoBeFederated, getOrCreateAPVideo } from './videos/index.js'
import { CONFIG } from '@server/initializers/config.js'
type ResolveThreadParams = {
url: string
@ -30,6 +31,8 @@ type ResolveThreadParams = {
type ResolveThreadResult = Promise<{ video: MVideoAccountLightBlacklistAllFiles, comment: MCommentOwnerVideo, commentCreated: boolean }>
export async function addVideoComments (commentUrls: string[]) {
if (CONFIG.VIDEO_COMMENTS.ACCEPT_REMOTE_COMMENTS !== true) return
return Bluebird.map(commentUrls, async commentUrl => {
try {
await resolveThread({ url: commentUrl, isVideo: false })