diff options
Diffstat (limited to 'server/models/utils.ts')
-rw-r--r-- | server/models/utils.ts | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/server/models/utils.ts b/server/models/utils.ts index e0bf091ad..60b0906e8 100644 --- a/server/models/utils.ts +++ b/server/models/utils.ts | |||
@@ -64,9 +64,25 @@ function createSimilarityAttribute (col: string, value: string) { | |||
64 | ) | 64 | ) |
65 | } | 65 | } |
66 | 66 | ||
67 | function buildBlockedAccountSQL (serverAccountId: number, userAccountId?: number) { | ||
68 | const blockerIds = [ serverAccountId ] | ||
69 | if (userAccountId) blockerIds.push(userAccountId) | ||
70 | |||
71 | const blockerIdsString = blockerIds.join(', ') | ||
72 | |||
73 | const query = 'SELECT "targetAccountId" AS "id" FROM "accountBlocklist" WHERE "accountId" IN (' + blockerIdsString + ')' + | ||
74 | ' UNION ALL ' + | ||
75 | 'SELECT "account"."id" AS "id" FROM account INNER JOIN "actor" ON account."actorId" = actor.id ' + | ||
76 | 'INNER JOIN "serverBlocklist" ON "actor"."serverId" = "serverBlocklist"."targetServerId" ' + | ||
77 | 'WHERE "serverBlocklist"."accountId" IN (' + blockerIdsString + ')' | ||
78 | |||
79 | return query | ||
80 | } | ||
81 | |||
67 | // --------------------------------------------------------------------------- | 82 | // --------------------------------------------------------------------------- |
68 | 83 | ||
69 | export { | 84 | export { |
85 | buildBlockedAccountSQL, | ||
70 | SortType, | 86 | SortType, |
71 | getSort, | 87 | getSort, |
72 | getVideoSort, | 88 | getVideoSort, |