diff options
Diffstat (limited to 'server/models/utils.ts')
-rw-r--r-- | server/models/utils.ts | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/server/models/utils.ts b/server/models/utils.ts index e0bf091ad..50c865e75 100644 --- a/server/models/utils.ts +++ b/server/models/utils.ts | |||
@@ -64,9 +64,27 @@ 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 "accountId" FROM "accountBlocklist" WHERE "targetAccountId" = user.account.id | ||
76 | // UNION ALL | ||
77 | 'SELECT "account"."id" AS "id" FROM account INNER JOIN "actor" ON account."actorId" = actor.id ' + | ||
78 | 'INNER JOIN "serverBlocklist" ON "actor"."serverId" = "serverBlocklist"."targetServerId" ' + | ||
79 | 'WHERE "serverBlocklist"."accountId" IN (' + blockerIdsString + ')' | ||
80 | |||
81 | return query | ||
82 | } | ||
83 | |||
67 | // --------------------------------------------------------------------------- | 84 | // --------------------------------------------------------------------------- |
68 | 85 | ||
69 | export { | 86 | export { |
87 | buildBlockedAccountSQL, | ||
70 | SortType, | 88 | SortType, |
71 | getSort, | 89 | getSort, |
72 | getVideoSort, | 90 | getVideoSort, |