Add ability for users to block an account/instance on server side

This commit is contained in:
Chocobozzz 2018-10-12 15:26:04 +02:00
parent dffd5d127f
commit 7ad9b9846c
33 changed files with 1344 additions and 56 deletions

View file

@ -64,9 +64,27 @@ function createSimilarityAttribute (col: string, value: string) {
)
}
function buildBlockedAccountSQL (serverAccountId: number, userAccountId?: number) {
const blockerIds = [ serverAccountId ]
if (userAccountId) blockerIds.push(userAccountId)
const blockerIdsString = blockerIds.join(', ')
const query = 'SELECT "targetAccountId" AS "id" FROM "accountBlocklist" WHERE "accountId" IN (' + blockerIdsString + ')' +
' UNION ALL ' +
// 'SELECT "accountId" FROM "accountBlocklist" WHERE "targetAccountId" = user.account.id
// UNION ALL
'SELECT "account"."id" AS "id" FROM account INNER JOIN "actor" ON account."actorId" = actor.id ' +
'INNER JOIN "serverBlocklist" ON "actor"."serverId" = "serverBlocklist"."targetServerId" ' +
'WHERE "serverBlocklist"."accountId" IN (' + blockerIdsString + ')'
return query
}
// ---------------------------------------------------------------------------
export {
buildBlockedAccountSQL,
SortType,
getSort,
getVideoSort,