diff options
author | Chocobozzz <me@florianbigard.com> | 2020-05-22 17:06:26 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-05-29 09:32:20 +0200 |
commit | 696d83fd1377486dd03cc1bd02a21d9b6ddd9fcd (patch) | |
tree | e1b88451c4357add80721f530993e2b48d197feb /server/lib/activitypub | |
parent | 72c33e716fecd1826dcf645957f8669821f91ff3 (diff) | |
download | PeerTube-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')
-rw-r--r-- | server/lib/activitypub/process/process-create.ts | 23 |
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 @@ | |||
1 | import { isRedundancyAccepted } from '@server/lib/redundancy' | ||
1 | import { ActivityCreate, CacheFileObject, VideoTorrentObject } from '../../../../shared' | 2 | import { ActivityCreate, CacheFileObject, VideoTorrentObject } from '../../../../shared' |
3 | import { PlaylistObject } from '../../../../shared/models/activitypub/objects/playlist-object' | ||
2 | import { VideoCommentObject } from '../../../../shared/models/activitypub/objects/video-comment-object' | 4 | import { VideoCommentObject } from '../../../../shared/models/activitypub/objects/video-comment-object' |
3 | import { retryTransactionWrapper } from '../../../helpers/database-utils' | 5 | import { retryTransactionWrapper } from '../../../helpers/database-utils' |
4 | import { logger } from '../../../helpers/logger' | 6 | import { logger } from '../../../helpers/logger' |
5 | import { sequelizeTypescript } from '../../../initializers/database' | 7 | import { sequelizeTypescript } from '../../../initializers/database' |
6 | import { resolveThread } from '../video-comments' | ||
7 | import { getOrCreateVideoAndAccountAndChannel } from '../videos' | ||
8 | import { forwardVideoRelatedActivity } from '../send/utils' | ||
9 | import { createOrUpdateCacheFile } from '../cache-file' | ||
10 | import { Notifier } from '../../notifier' | ||
11 | import { PlaylistObject } from '../../../../shared/models/activitypub/objects/playlist-object' | ||
12 | import { createOrUpdateVideoPlaylist } from '../playlist' | ||
13 | import { APProcessorOptions } from '../../../typings/activitypub-processor.model' | 8 | import { APProcessorOptions } from '../../../typings/activitypub-processor.model' |
14 | import { MActorSignature, MCommentOwnerVideo, MVideoAccountLightBlacklistAllFiles } from '../../../typings/models' | 9 | import { MActorSignature, MCommentOwnerVideo, MVideoAccountLightBlacklistAllFiles } from '../../../typings/models' |
15 | import { isRedundancyAccepted } from '@server/lib/redundancy' | 10 | import { Notifier } from '../../notifier' |
11 | import { createOrUpdateCacheFile } from '../cache-file' | ||
12 | import { createOrUpdateVideoPlaylist } from '../playlist' | ||
13 | import { forwardVideoRelatedActivity } from '../send/utils' | ||
14 | import { resolveThread } from '../video-comments' | ||
15 | import { getOrCreateVideoAndAccountAndChannel } from '../videos' | ||
16 | import { isBlockedByServerOrAccount } from '@server/lib/blocklist' | ||
16 | 17 | ||
17 | async function processCreateActivity (options: APProcessorOptions<ActivityCreate>) { | 18 | async 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 ] |