aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/process/process-create.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-05-22 17:06:26 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-05-29 09:32:20 +0200
commit696d83fd1377486dd03cc1bd02a21d9b6ddd9fcd (patch)
treee1b88451c4357add80721f530993e2b48d197feb /server/lib/activitypub/process/process-create.ts
parent72c33e716fecd1826dcf645957f8669821f91ff3 (diff)
downloadPeerTube-696d83fd1377486dd03cc1bd02a21d9b6ddd9fcd.tar.gz
PeerTube-696d83fd1377486dd03cc1bd02a21d9b6ddd9fcd.tar.zst
PeerTube-696d83fd1377486dd03cc1bd02a21d9b6ddd9fcd.zip
Block comments from muted accounts/servers
Add better control for users of comments displayed on their videos: * Do not forward comments from muted remote accounts/servers (muted by the current server or by the video owner) * Do not list threads and hide replies (with their children) of accounts/servers muted by the video owner * Hide from RSS comments of muted accounts/servers by video owners Use case: * Try to limit spam propagation in the federation * Add ability for users to automatically hide comments on their videos from undesirable accounts/servers (the comment section belongs to videomakers, so they choose what's posted there)
Diffstat (limited to 'server/lib/activitypub/process/process-create.ts')
-rw-r--r--server/lib/activitypub/process/process-create.ts23
1 files changed, 15 insertions, 8 deletions
diff --git a/server/lib/activitypub/process/process-create.ts b/server/lib/activitypub/process/process-create.ts
index 566bf6992..f8f9b80c6 100644
--- a/server/lib/activitypub/process/process-create.ts
+++ b/server/lib/activitypub/process/process-create.ts
@@ -1,18 +1,19 @@
1import { isRedundancyAccepted } from '@server/lib/redundancy'
1import { ActivityCreate, CacheFileObject, VideoTorrentObject } from '../../../../shared' 2import { ActivityCreate, CacheFileObject, VideoTorrentObject } from '../../../../shared'
3import { PlaylistObject } from '../../../../shared/models/activitypub/objects/playlist-object'
2import { VideoCommentObject } from '../../../../shared/models/activitypub/objects/video-comment-object' 4import { VideoCommentObject } from '../../../../shared/models/activitypub/objects/video-comment-object'
3import { retryTransactionWrapper } from '../../../helpers/database-utils' 5import { retryTransactionWrapper } from '../../../helpers/database-utils'
4import { logger } from '../../../helpers/logger' 6import { logger } from '../../../helpers/logger'
5import { sequelizeTypescript } from '../../../initializers/database' 7import { sequelizeTypescript } from '../../../initializers/database'
6import { resolveThread } from '../video-comments'
7import { getOrCreateVideoAndAccountAndChannel } from '../videos'
8import { forwardVideoRelatedActivity } from '../send/utils'
9import { createOrUpdateCacheFile } from '../cache-file'
10import { Notifier } from '../../notifier'
11import { PlaylistObject } from '../../../../shared/models/activitypub/objects/playlist-object'
12import { createOrUpdateVideoPlaylist } from '../playlist'
13import { APProcessorOptions } from '../../../typings/activitypub-processor.model' 8import { APProcessorOptions } from '../../../typings/activitypub-processor.model'
14import { MActorSignature, MCommentOwnerVideo, MVideoAccountLightBlacklistAllFiles } from '../../../typings/models' 9import { MActorSignature, MCommentOwnerVideo, MVideoAccountLightBlacklistAllFiles } from '../../../typings/models'
15import { isRedundancyAccepted } from '@server/lib/redundancy' 10import { Notifier } from '../../notifier'
11import { createOrUpdateCacheFile } from '../cache-file'
12import { createOrUpdateVideoPlaylist } from '../playlist'
13import { forwardVideoRelatedActivity } from '../send/utils'
14import { resolveThread } from '../video-comments'
15import { getOrCreateVideoAndAccountAndChannel } from '../videos'
16import { isBlockedByServerOrAccount } from '@server/lib/blocklist'
16 17
17async function processCreateActivity (options: APProcessorOptions<ActivityCreate>) { 18async function processCreateActivity (options: APProcessorOptions<ActivityCreate>) {
18 const { activity, byActor } = options 19 const { activity, byActor } = options
@@ -101,6 +102,12 @@ async function processCreateVideoComment (activity: ActivityCreate, byActor: MAc
101 return 102 return
102 } 103 }
103 104
105 // Try to not forward unwanted commments on our videos
106 if (video.isOwned() && await isBlockedByServerOrAccount(comment.Account, video.VideoChannel.Account)) {
107 logger.info('Skip comment forward from blocked account or server %s.', comment.Account.Actor.url)
108 return
109 }
110
104 if (video.isOwned() && created === true) { 111 if (video.isOwned() && created === true) {
105 // Don't resend the activity to the sender 112 // Don't resend the activity to the sender
106 const exceptions = [ byActor ] 113 const exceptions = [ byActor ]