Fix: #404 フィルターでhalf_warnを設定してると、クライアントアプリでタイムラインが読み込まれない (#410)

This commit is contained in:
KMY(雪あすか) 2024-01-03 22:10:02 +09:00 committed by GitHub
parent 47489783bc
commit eee362b9e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 7 deletions

View file

@ -83,7 +83,7 @@ export function updateNotifications(notification, intlMessages, intlLocale) {
if (['mention', 'status'].includes(notification.type) && notification.status.filtered) {
const filters = notification.status.filtered.filter(result => result.filter.context.includes('notifications'));
if (filters.some(result => result.filter.filter_action === 'hide')) {
if (filters.some(result => result.filter.filter_action_ex === 'hide')) {
return;
}

View file

@ -452,7 +452,7 @@ class Status extends ImmutablePureComponent {
moveDown: this.handleHotkeyMoveDown,
};
if (status.get('filter_action') === 'half_warn') {
if (status.get('filter_action_ex') === 'half_warn') {
return (
<HotKeys handlers={minHandlers}>
<div className='status__wrapper status__wrapper--filtered focusable' tabIndex={0} ref={this.handleRef}>

View file

@ -9,6 +9,7 @@ const normalizeFilter = (state, filter) => {
title: filter.title,
context: filter.context,
filter_action: filter.filter_action,
filter_action_ex: filter.filter_action_ex,
keywords: filter.keywords,
expires_at: filter.expires_at ? Date.parse(filter.expires_at) : null,
with_quote: filter.with_quote,

View file

@ -56,13 +56,13 @@ export const makeGetStatus = () => {
}
}
if (filterResults.some((result) => filters.getIn([result.get('filter'), 'filter_action']) === 'hide')) {
if (filterResults.some((result) => filters.getIn([result.get('filter'), 'filter_action_ex']) === 'hide')) {
return null;
}
filterResults = filterResults.filter(result => filters.has(result.get('filter')));
if (!filterResults.isEmpty()) {
filtered = filterResults.map(result => filters.getIn([result.get('filter'), 'title']));
filterAction = filterResults.some((result) => filters.getIn([result.get('filter'), 'filter_action']) === 'warn') ? 'warn' : 'half_warn';
filterAction = filterResults.some((result) => filters.getIn([result.get('filter'), 'filter_action_ex']) === 'warn') ? 'warn' : 'half_warn';
}
}
@ -72,6 +72,7 @@ export const makeGetStatus = () => {
map.set('account', accountBase);
map.set('matched_filters', filtered);
map.set('filter_action', filterAction);
map.set('filter_action_ex', filterAction);
});
},
);

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true
class REST::FilterSerializer < ActiveModel::Serializer
attributes :id, :title, :exclude_follows, :exclude_localusers, :with_quote, :context, :expires_at, :filter_action
attributes :id, :title, :exclude_follows, :exclude_localusers, :with_quote, :context, :expires_at, :filter_action, :filter_action_ex
has_many :keywords, serializer: REST::FilterKeywordSerializer, if: :rules_requested?
has_many :statuses, serializer: REST::FilterStatusSerializer, if: :rules_requested?
@ -12,4 +12,14 @@ class REST::FilterSerializer < ActiveModel::Serializer
def rules_requested?
instance_options[:rules_requested]
end
def filter_action
return :hide if object.half_warn_action?
object.filter_action
end
def filter_action_ex
object.filter_action
end
end

View file

@ -836,8 +836,9 @@ const startServer = async () => {
// custom_filters.action database column, it is an integer
// representing a value in an enum defined by Ruby on Rails:
//
// enum { warn: 0, hide: 1 }
filter_action: ['warn', 'hide', 'half_warn'][filter.filter_action],
// enum { warn: 0, hide: 1, half_warn: 2 }
filter_action: ['warn', 'hide', 'half_warn'][Math.min(filter.filter_action, 1)],
filter_action_ex: ['warn', 'hide', 'half_warn'][filter.filter_action],
with_quote: filter.with_quote,
excludeFollows: filter.exclude_follows,
excludeLocalusers: filter.exclude_localusers,