Fix filter exclude_followings not work

This commit is contained in:
KMY 2023-08-01 18:59:37 +09:00
parent 287eacf5f3
commit 543d5d01ac
2 changed files with 9 additions and 6 deletions

View file

@ -20,7 +20,7 @@ class StatusCacheHydrator
payload[:bookmarked] = false
payload[:pinned] = false if @status.account_id == account_id
payload[:filtered] = CustomFilter
.apply_cached_filters(CustomFilter.cached_filters_for(account_id), @status.reblog)
.apply_cached_filters(CustomFilter.cached_filters_for(account_id), @status.reblog, following?(account_id))
.map { |filter| serialized_filter(filter) }
# If the reblogged status is being delivered to the author who disabled the display of the application
@ -54,7 +54,7 @@ class StatusCacheHydrator
payload[:bookmarked] = Bookmark.where(account_id: account_id, status_id: @status.id).exists?
payload[:pinned] = StatusPin.where(account_id: account_id, status_id: @status.id).exists? if @status.account_id == account_id
payload[:filtered] = CustomFilter
.apply_cached_filters(CustomFilter.cached_filters_for(account_id), @status)
.apply_cached_filters(CustomFilter.cached_filters_for(account_id), @status, following?(account_id))
.map { |filter| serialized_filter(filter) }
if payload[:poll]
@ -68,6 +68,10 @@ class StatusCacheHydrator
private
def following?(account_id)
Follow.exists?(account_id: account_id, target_account_id: @status.account_id)
end
def serialized_filter(filter)
ActiveModelSerializers::SerializableResource.new(
filter,

View file

@ -704,9 +704,8 @@ const startServer = async () => {
queries.push(client.query('SELECT filter.id AS id, filter.phrase AS title, filter.context AS context, filter.expires_at AS expires_at, filter.action AS filter_action, keyword.keyword AS keyword, keyword.whole_word AS whole_word, filter.exclude_follows AS exclude_follows, filter.exclude_localusers AS exclude_localusers FROM custom_filter_keywords keyword JOIN custom_filters filter ON keyword.custom_filter_id = filter.id WHERE filter.account_id = $1 AND (filter.expires_at IS NULL OR filter.expires_at > NOW())', [req.accountId]));
}
if (!payload.filtered) {
queries.push(client.query(`SELECT accounts.domain AS domain
queries.push(client.query(`SELECT 1
FROM follows
JOIN accounts ON follows.target_account_id = accounts.id
WHERE (account_id = $1 AND target_account_id = $2)`, [req.accountId, payload.account.id]));
}
@ -799,11 +798,11 @@ const startServer = async () => {
return results;
}
if (cachedFilter.repr.excludeFollows && following) {
if (cachedFilter.filter && cachedFilter.filter.excludeFollows && following) {
return results;
}
if (cachedFilter.repr.excludeLocalusers && !accountDomain) {
if (cachedFilter.filter && cachedFilter.filter.excludeLocalusers && !accountDomain) {
return results;
}