diff options
author | Chocobozzz <me@florianbigard.com> | 2020-07-24 15:05:51 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-07-31 11:35:19 +0200 |
commit | edbc9325462ddf4536775871ebc25e06f46612d1 (patch) | |
tree | 9671dd51303e75d48d4f4f9a1df7a1960e33780d /server/models/abuse/abuse-query-builder.ts | |
parent | 20516920d2b72c8a18bc24b9740f7176aa962da2 (diff) | |
download | PeerTube-edbc9325462ddf4536775871ebc25e06f46612d1.tar.gz PeerTube-edbc9325462ddf4536775871ebc25e06f46612d1.tar.zst PeerTube-edbc9325462ddf4536775871ebc25e06f46612d1.zip |
Add server API to abuse messages
Diffstat (limited to 'server/models/abuse/abuse-query-builder.ts')
-rw-r--r-- | server/models/abuse/abuse-query-builder.ts | 15 |
1 files changed, 12 insertions, 3 deletions
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 = { | |||
26 | state?: AbuseState | 26 | state?: AbuseState |
27 | 27 | ||
28 | // accountIds | 28 | // accountIds |
29 | serverAccountId: number | 29 | serverAccountId?: number |
30 | userAccountId: number | 30 | userAccountId?: number |
31 | |||
32 | reporterAccountId?: number | ||
31 | } | 33 | } |
32 | 34 | ||
33 | function buildAbuseListQuery (options: BuildAbusesQueryOptions, type: 'count' | 'id') { | 35 | function buildAbuseListQuery (options: BuildAbusesQueryOptions, type: 'count' | 'id') { |
@@ -45,7 +47,14 @@ function buildAbuseListQuery (options: BuildAbusesQueryOptions, type: 'count' | | |||
45 | 'LEFT JOIN "videoComment" ON "commentAbuse"."videoCommentId" = "videoComment"."id"' | 47 | 'LEFT JOIN "videoComment" ON "commentAbuse"."videoCommentId" = "videoComment"."id"' |
46 | ] | 48 | ] |
47 | 49 | ||
48 | whereAnd.push('"abuse"."reporterAccountId" NOT IN (' + buildBlockedAccountSQL([ options.serverAccountId, options.userAccountId ]) + ')') | 50 | if (options.serverAccountId || options.userAccountId) { |
51 | whereAnd.push('"abuse"."reporterAccountId" NOT IN (' + buildBlockedAccountSQL([ options.serverAccountId, options.userAccountId ]) + ')') | ||
52 | } | ||
53 | |||
54 | if (options.reporterAccountId) { | ||
55 | whereAnd.push('"abuse"."reporterAccountId" = :reporterAccountId') | ||
56 | replacements.reporterAccountId = options.reporterAccountId | ||
57 | } | ||
49 | 58 | ||
50 | if (options.search) { | 59 | if (options.search) { |
51 | const searchWhereOr = [ | 60 | const searchWhereOr = [ |