Add domain search prefix

This commit is contained in:
KMY 2023-08-30 07:53:51 +09:00
parent 05a022448b
commit 7c4a4b905b
2 changed files with 11 additions and 0 deletions

View file

@ -50,6 +50,7 @@ class Search extends PureComponent {
{ label: <><mark>is:</mark> <FormattedList type='disjunction' value={['reply', 'sensitive']} /></>, action: e => { e.preventDefault(); this._insertText('is:') } },
{ label: <><mark>language:</mark> <FormattedMessage id='search_popout.language_code' defaultMessage='ISO language code' /></>, action: e => { e.preventDefault(); this._insertText('language:') } },
{ label: <><mark>from:</mark> <FormattedMessage id='search_popout.user' defaultMessage='user' /></>, action: e => { e.preventDefault(); this._insertText('from:') } },
{ label: <><mark>domain:</mark> <FormattedMessage id='search_popout.domain' defaultMessage='domain' /></>, action: e => { e.preventDefault(); this._insertText('domain:') } },
{ label: <><mark>before:</mark> <FormattedMessage id='search_popout.specific_date' defaultMessage='specific date' /></>, action: e => { e.preventDefault(); this._insertText('before:') } },
{ label: <><mark>during:</mark> <FormattedMessage id='search_popout.specific_date' defaultMessage='specific date' /></>, action: e => { e.preventDefault(); this._insertText('during:') } },
{ label: <><mark>after:</mark> <FormattedMessage id='search_popout.specific_date' defaultMessage='specific date' /></>, action: e => { e.preventDefault(); this._insertText('after:') } },

View file

@ -103,6 +103,10 @@ class SearchQueryTransformer < Parslet::Transform
@filter = :account_id
@type = :term
@term = account_id_from_term(term)
when 'domain'
@filter = :domain
@type = :term
@term = domain_from_term(term)
when 'before'
@filter = :created_at
@type = :range
@ -137,6 +141,12 @@ class SearchQueryTransformer < Parslet::Transform
# an ID that does not exist
account&.id || -1
end
def domain_from_term(term)
return '' if %w(local me).include?(term)
term
end
end
rule(clause: subtree(:clause)) do