編集時にフィルターが機能しない問題を修正
This commit is contained in:
parent
44b739a39a
commit
e1ac510c65
4 changed files with 23 additions and 4 deletions
|
@ -11,6 +11,7 @@ const normalizeFilter = (state, filter) => {
|
||||||
filter_action: filter.filter_action,
|
filter_action: filter.filter_action,
|
||||||
keywords: filter.keywords,
|
keywords: filter.keywords,
|
||||||
expires_at: filter.expires_at ? Date.parse(filter.expires_at) : null,
|
expires_at: filter.expires_at ? Date.parse(filter.expires_at) : null,
|
||||||
|
with_quote: filter.with_quote,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (is(state.get(filter.id), normalizedFilter)) {
|
if (is(state.get(filter.id), normalizedFilter)) {
|
||||||
|
|
|
@ -37,12 +37,14 @@ export const makeGetStatus = () => {
|
||||||
[
|
[
|
||||||
(state, { id }) => state.getIn(['statuses', id]),
|
(state, { id }) => state.getIn(['statuses', id]),
|
||||||
(state, { id }) => state.getIn(['statuses', state.getIn(['statuses', id, 'reblog'])]),
|
(state, { id }) => state.getIn(['statuses', state.getIn(['statuses', id, 'reblog'])]),
|
||||||
|
(state, { id }) => state.getIn(['statuses', state.getIn(['statuses', id, 'quote_id'])]),
|
||||||
(state, { id }) => state.getIn(['accounts', state.getIn(['statuses', id, 'account'])]),
|
(state, { id }) => state.getIn(['accounts', state.getIn(['statuses', id, 'account'])]),
|
||||||
(state, { id }) => state.getIn(['accounts', state.getIn(['statuses', state.getIn(['statuses', id, 'reblog']), 'account'])]),
|
(state, { id }) => state.getIn(['accounts', state.getIn(['statuses', state.getIn(['statuses', id, 'reblog']), 'account'])]),
|
||||||
|
(state, { id }) => state.getIn(['accounts', state.getIn(['statuses', state.getIn(['statuses', id, 'quote_id']), 'account'])]),
|
||||||
getFilters,
|
getFilters,
|
||||||
],
|
],
|
||||||
|
|
||||||
(statusBase, statusReblog, accountBase, accountReblog, filters) => {
|
(statusBase, statusReblog, statusQuote, accountBase, accountReblog, accountQuote, filters) => {
|
||||||
if (!statusBase || statusBase.get('isLoading')) {
|
if (!statusBase || statusBase.get('isLoading')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -53,6 +55,12 @@ export const makeGetStatus = () => {
|
||||||
statusReblog = null;
|
statusReblog = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (statusQuote) {
|
||||||
|
statusQuote = statusQuote.set('account', accountQuote);
|
||||||
|
} else {
|
||||||
|
statusQuote = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (hideBlockingQuote && statusBase.getIn(['quote', 'quote_muted'])) {
|
if (hideBlockingQuote && statusBase.getIn(['quote', 'quote_muted'])) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -61,6 +69,14 @@ export const makeGetStatus = () => {
|
||||||
let filterAction = 'warn';
|
let filterAction = 'warn';
|
||||||
if ((accountReblog || accountBase).get('id') !== me && filters) {
|
if ((accountReblog || accountBase).get('id') !== me && filters) {
|
||||||
let filterResults = statusReblog?.get('filtered') || statusBase.get('filtered') || ImmutableList();
|
let filterResults = statusReblog?.get('filtered') || statusBase.get('filtered') || ImmutableList();
|
||||||
|
const quoteFilterResults = statusQuote?.get('filtered');
|
||||||
|
if (quoteFilterResults) {
|
||||||
|
const filterWithQuote = quoteFilterResults.some((result) => filters.getIn([result.get('filter'), 'with_quote']));
|
||||||
|
if (filterWithQuote) {
|
||||||
|
filterResults = filterResults.concat(quoteFilterResults);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (filterResults.some((result) => filters.getIn([result.get('filter'), 'filter_action']) === 'hide')) {
|
if (filterResults.some((result) => filters.getIn([result.get('filter'), 'filter_action']) === 'hide')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -73,6 +89,7 @@ export const makeGetStatus = () => {
|
||||||
|
|
||||||
return statusBase.withMutations(map => {
|
return statusBase.withMutations(map => {
|
||||||
map.set('reblog', statusReblog);
|
map.set('reblog', statusReblog);
|
||||||
|
map.set('quote', statusQuote);
|
||||||
map.set('account', accountBase);
|
map.set('account', accountBase);
|
||||||
map.set('matched_filters', filtered);
|
map.set('matched_filters', filtered);
|
||||||
map.set('filter_action', filterAction);
|
map.set('filter_action', filterAction);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class REST::FilterSerializer < ActiveModel::Serializer
|
class REST::FilterSerializer < ActiveModel::Serializer
|
||||||
attributes :id, :title, :exclude_follows, :exclude_localusers, :context, :expires_at, :filter_action
|
attributes :id, :title, :exclude_follows, :exclude_localusers, :with_quote, :context, :expires_at, :filter_action
|
||||||
has_many :keywords, serializer: REST::FilterKeywordSerializer, if: :rules_requested?
|
has_many :keywords, serializer: REST::FilterKeywordSerializer, if: :rules_requested?
|
||||||
has_many :statuses, serializer: REST::FilterStatusSerializer, if: :rules_requested?
|
has_many :statuses, serializer: REST::FilterStatusSerializer, if: :rules_requested?
|
||||||
|
|
||||||
|
|
|
@ -864,7 +864,7 @@ const startServer = async () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!payload.filtered && !req.cachedFilters) {
|
if (!payload.filtered && !req.cachedFilters) {
|
||||||
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]));
|
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, filter.with_quote AS with_quote, 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) {
|
if (!payload.filtered) {
|
||||||
queries.push(client.query(`SELECT 1
|
queries.push(client.query(`SELECT 1
|
||||||
|
@ -913,7 +913,8 @@ const startServer = async () => {
|
||||||
// representing a value in an enum defined by Ruby on Rails:
|
// representing a value in an enum defined by Ruby on Rails:
|
||||||
//
|
//
|
||||||
// enum { warn: 0, hide: 1 }
|
// enum { warn: 0, hide: 1 }
|
||||||
filter_action: ['warn', 'hide'][filter.filter_action],
|
filter_action: ['warn', 'hide', 'half_warn'][filter.filter_action],
|
||||||
|
with_quote: filter.with_quote,
|
||||||
excludeFollows: filter.exclude_follows,
|
excludeFollows: filter.exclude_follows,
|
||||||
excludeLocalusers: filter.exclude_localusers,
|
excludeLocalusers: filter.exclude_localusers,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue