From 91c789ec630757b1de6e0b84aa6b6dac55c6998b Mon Sep 17 00:00:00 2001 From: unarist Date: Tue, 30 May 2017 01:01:08 +0900 Subject: [PATCH] Don't stream toots from users who have blocked the recipient user (#3300) * Don't stream toots from users who have blocked the recipient user This filter was already applied on the `/api/v1/timelines/public` API, but not yet for the Streaming API. * Boosted status' account_id doesn't need for filtering in streaming/index.js This filtering is only for public/hashtag timelines, but boosts already filtered on FanOutOnWriteService because those timelines don't show boosts. --- streaming/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/streaming/index.js b/streaming/index.js index 52b5ccced..fe39cf21d 100644 --- a/streaming/index.js +++ b/streaming/index.js @@ -240,7 +240,7 @@ const startWorker = (workerId) => { } const unpackedPayload = JSON.parse(payload); - const targetAccountIds = [unpackedPayload.account.id].concat(unpackedPayload.mentions.map(item => item.id)).concat(unpackedPayload.reblog ? [unpackedPayload.reblog.account.id] : []); + const targetAccountIds = [unpackedPayload.account.id].concat(unpackedPayload.mentions.map(item => item.id)); const accountDomain = unpackedPayload.account.acct.split('@')[1]; if (Array.isArray(req.filteredLanguages) && req.filteredLanguages.includes(unpackedPayload.language)) { @@ -250,7 +250,7 @@ const startWorker = (workerId) => { } const queries = [ - client.query(`SELECT 1 FROM blocks WHERE account_id = $1 AND target_account_id IN (${placeholders(targetAccountIds, 1)}) UNION SELECT 1 FROM mutes WHERE account_id = $1 AND target_account_id IN (${placeholders(targetAccountIds, 1)})`, [req.accountId].concat(targetAccountIds)), + client.query(`SELECT 1 FROM blocks WHERE (account_id = $1 AND target_account_id IN (${placeholders(targetAccountIds, 2)})) OR (account_id = $2 AND target_account_id = $1) UNION SELECT 1 FROM mutes WHERE account_id = $1 AND target_account_id IN (${placeholders(targetAccountIds, 2)})`, [req.accountId, unpackedPayload.account.id].concat(targetAccountIds)), ]; if (accountDomain) {