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/models/account | |
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/models/account')
-rw-r--r-- | server/models/account/account.ts | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/server/models/account/account.ts b/server/models/account/account.ts index a0081f259..ad649837a 100644 --- a/server/models/account/account.ts +++ b/server/models/account/account.ts | |||
@@ -32,9 +32,10 @@ import { FindOptions, IncludeOptions, Op, Transaction, WhereOptions } from 'sequ | |||
32 | import { AccountBlocklistModel } from './account-blocklist' | 32 | import { AccountBlocklistModel } from './account-blocklist' |
33 | import { ServerBlocklistModel } from '../server/server-blocklist' | 33 | import { ServerBlocklistModel } from '../server/server-blocklist' |
34 | import { ActorFollowModel } from '../activitypub/actor-follow' | 34 | import { ActorFollowModel } from '../activitypub/actor-follow' |
35 | import { MAccountActor, MAccountAP, MAccountDefault, MAccountFormattable, MAccountSummaryFormattable } from '../../typings/models' | 35 | import { MAccountActor, MAccountAP, MAccountDefault, MAccountFormattable, MAccountSummaryFormattable, MAccount } from '../../typings/models' |
36 | import * as Bluebird from 'bluebird' | 36 | import * as Bluebird from 'bluebird' |
37 | import { ModelCache } from '@server/models/model-cache' | 37 | import { ModelCache } from '@server/models/model-cache' |
38 | import { VideoModel } from '../video/video' | ||
38 | 39 | ||
39 | export enum ScopeNames { | 40 | export enum ScopeNames { |
40 | SUMMARY = 'SUMMARY' | 41 | SUMMARY = 'SUMMARY' |
@@ -343,6 +344,29 @@ export class AccountModel extends Model<AccountModel> { | |||
343 | }) | 344 | }) |
344 | } | 345 | } |
345 | 346 | ||
347 | static loadAccountIdFromVideo (videoId: number): Bluebird<MAccount> { | ||
348 | const query = { | ||
349 | include: [ | ||
350 | { | ||
351 | attributes: [ 'id', 'accountId' ], | ||
352 | model: VideoChannelModel.unscoped(), | ||
353 | required: true, | ||
354 | include: [ | ||
355 | { | ||
356 | attributes: [ 'id', 'channelId' ], | ||
357 | model: VideoModel.unscoped(), | ||
358 | where: { | ||
359 | id: videoId | ||
360 | } | ||
361 | } | ||
362 | ] | ||
363 | } | ||
364 | ] | ||
365 | } | ||
366 | |||
367 | return AccountModel.findOne(query) | ||
368 | } | ||
369 | |||
346 | static listLocalsForSitemap (sort: string): Bluebird<MAccountActor[]> { | 370 | static listLocalsForSitemap (sort: string): Bluebird<MAccountActor[]> { |
347 | const query = { | 371 | const query = { |
348 | attributes: [ ], | 372 | attributes: [ ], |