1
0
Fork 0
mirror of https://github.com/mastodon/mastodon.git synced 2024-08-20 21:08:15 -07:00

Compare commits

...

4 commits

10 changed files with 40 additions and 36 deletions

View file

@ -29,5 +29,7 @@ class Api::V1::TagsController < Api::BaseController
return not_found unless Tag::HASHTAG_NAME_RE.match?(params[:id])
@tag = Tag.find_normalized(params[:id]) || Tag.new(name: Tag.normalize(params[:id]), display_name: params[:id])
not_found unless @tag.usable?
end
end

View file

@ -19,7 +19,7 @@ class Api::V1::Timelines::TagController < Api::V1::Timelines::BaseController
end
def load_tag
@tag = Tag.find_normalized(params[:id])
@tag = Tag.usable.find_normalized(params[:id])
end
def load_statuses

View file

@ -60,7 +60,7 @@ export interface BaseNotificationGroupJSON {
interface NotificationGroupWithStatusJSON extends BaseNotificationGroupJSON {
type: NotificationWithStatusType;
status: ApiStatusJSON;
status_id: string;
}
interface NotificationWithStatusJSON extends BaseNotificationJSON {

View file

@ -49,21 +49,14 @@ export const FilteredNotificationsBanner: React.FC = () => {
<span>
<FormattedMessage
id='filtered_notifications_banner.pending_requests'
defaultMessage='Notifications from {count, plural, =0 {no one} one {one person} other {# people}} you may know'
defaultMessage='From {count, plural, =0 {no one} one {one person} other {# people}} you may know'
values={{ count: policy.summary.pending_requests_count }}
/>
</span>
</div>
<div className='filtered-notifications-banner__badge'>
<div className='filtered-notifications-banner__badge__badge'>
{toCappedNumber(policy.summary.pending_notifications_count)}
</div>
<FormattedMessage
id='filtered_notifications_banner.mentions'
defaultMessage='{count, plural, one {mention} other {mentions}}'
values={{ count: policy.summary.pending_notifications_count }}
/>
{toCappedNumber(policy.summary.pending_notifications_count)}
</div>
</Link>
);

View file

@ -300,8 +300,7 @@
"filter_modal.select_filter.subtitle": "Use an existing category or create a new one",
"filter_modal.select_filter.title": "Filter this post",
"filter_modal.title.status": "Filter a post",
"filtered_notifications_banner.mentions": "{count, plural, one {mention} other {mentions}}",
"filtered_notifications_banner.pending_requests": "Notifications from {count, plural, =0 {no one} one {one person} other {# people}} you may know",
"filtered_notifications_banner.pending_requests": "From {count, plural, =0 {no one} one {one person} other {# people}} you may know",
"filtered_notifications_banner.title": "Filtered notifications",
"firehose.all": "All",
"firehose.local": "This server",

View file

@ -124,9 +124,9 @@ export function createNotificationGroupFromJSON(
case 'mention':
case 'poll':
case 'update': {
const { status, ...groupWithoutStatus } = group;
const { status_id: statusId, ...groupWithoutStatus } = group;
return {
statusId: status.id,
statusId,
sampleAccountIds,
...groupWithoutStatus,
};

View file

@ -10171,25 +10171,10 @@ noscript {
}
&__badge {
display: flex;
align-items: center;
border-radius: 999px;
background: var(--background-border-color);
color: $darker-text-color;
padding: 4px;
padding-inline-end: 8px;
gap: 6px;
font-weight: 500;
font-size: 11px;
line-height: 16px;
word-break: keep-all;
&__badge {
background: $ui-button-background-color;
color: $white;
border-radius: 100px;
padding: 2px 8px;
}
background: $ui-button-background-color;
color: $white;
border-radius: 100px;
padding: 2px 8px;
}
}

View file

@ -13,6 +13,8 @@ class SearchQueryTransformer < Parslet::Transform
).freeze
class Query
attr_reader :keywords
def initialize(clauses, options = {})
raise ArgumentError if options[:current_account].nil?
@ -20,6 +22,7 @@ class SearchQueryTransformer < Parslet::Transform
@options = options
flags_from_clauses!
keywords_from_clauses!
end
def request
@ -42,6 +45,10 @@ class SearchQueryTransformer < Parslet::Transform
@flags = clauses_by_operator.fetch(:flag, []).to_h { |clause| [clause.prefix, clause.term] }
end
def keywords_from_clauses!
@keywords = must_clauses.flat_map(&:keywords).uniq
end
def must_clauses
clauses_by_operator.fetch(:must, [])
end
@ -128,6 +135,10 @@ class SearchQueryTransformer < Parslet::Transform
{ multi_match: { type: 'most_fields', query: @term, fields: ['text', 'text.stemmed'], operator: 'and' } }
end
end
def keywords
@term.split
end
end
class PhraseClause
@ -141,6 +152,10 @@ class SearchQueryTransformer < Parslet::Transform
def to_query
{ match_phrase: { text: { query: @phrase } } }
end
def keywords
@phrase.split
end
end
class PrefixClause
@ -193,6 +208,10 @@ class SearchQueryTransformer < Parslet::Transform
end
end
def keywords
[]
end
private
def account_id_from_term(term)

View file

@ -25,6 +25,8 @@ class StatusesSearchService < BaseService
private
def status_search_results
return [] if contains_forbidden_terms?
request = parsed_query.request
results = request.collapse(field: :id).order(id: { order: :desc }).limit(@limit).offset(@offset).objects.compact
account_ids = results.map(&:account_id)
@ -37,7 +39,7 @@ class StatusesSearchService < BaseService
end
def parsed_query
SearchQueryTransformer.new.apply(SearchQueryParser.new.parse(@query), current_account: @account)
@parsed_query ||= SearchQueryTransformer.new.apply(SearchQueryParser.new.parse(@query), current_account: @account)
end
def convert_deprecated_options!
@ -60,4 +62,8 @@ class StatusesSearchService < BaseService
@query = "#{@query} #{syntax_options.join(' ')}".strip if syntax_options.any?
end
def contains_forbidden_terms?
Tag.where(usable: false).matching_name(parsed_query.keywords).exists?
end
end

View file

@ -41,7 +41,7 @@ class TagSearchService < BaseService
normalized_query = Tag.normalize(@query)
exact_match = results.find { |tag| tag.name.downcase == normalized_query }
exact_match ||= Tag.find_normalized(normalized_query)
exact_match ||= Tag.listable.find_normalized(normalized_query)
unless exact_match.nil?
results.delete(exact_match)
results = [exact_match] + results