X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fabuse%2Fabuse-query-builder.ts;h=9d7cb75aa37cf75b8d7145fd632ceaa3c6272914;hb=edbc9325462ddf4536775871ebc25e06f46612d1;hp=5fddcf3c439d451b4b8267fc11d7ad600c4f75c6;hpb=17aa80ed016bafa3ccb071af3f86054033823284;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/abuse/abuse-query-builder.ts b/server/models/abuse/abuse-query-builder.ts index 5fddcf3c4..9d7cb75aa 100644 --- a/server/models/abuse/abuse-query-builder.ts +++ b/server/models/abuse/abuse-query-builder.ts @@ -26,8 +26,10 @@ export type BuildAbusesQueryOptions = { state?: AbuseState // accountIds - serverAccountId: number - userAccountId: number + serverAccountId?: number + userAccountId?: number + + reporterAccountId?: number } function buildAbuseListQuery (options: BuildAbusesQueryOptions, type: 'count' | 'id') { @@ -45,7 +47,14 @@ function buildAbuseListQuery (options: BuildAbusesQueryOptions, type: 'count' | 'LEFT JOIN "videoComment" ON "commentAbuse"."videoCommentId" = "videoComment"."id"' ] - whereAnd.push('"abuse"."reporterAccountId" NOT IN (' + buildBlockedAccountSQL([ options.serverAccountId, options.userAccountId ]) + ')') + if (options.serverAccountId || options.userAccountId) { + whereAnd.push('"abuse"."reporterAccountId" NOT IN (' + buildBlockedAccountSQL([ options.serverAccountId, options.userAccountId ]) + ')') + } + + if (options.reporterAccountId) { + whereAnd.push('"abuse"."reporterAccountId" = :reporterAccountId') + replacements.reporterAccountId = options.reporterAccountId + } if (options.search) { const searchWhereOr = [