mirror of
https://github.com/mastodon/mastodon.git
synced 2025-03-23 08:39:57 +01:00
Add supported operator and properties for search
This commit is contained in:
parent
828eebad48
commit
04ad5e67d0
1 changed files with 19 additions and 0 deletions
|
@ -12,6 +12,23 @@ class SearchQueryTransformer < Parslet::Transform
|
||||||
in
|
in
|
||||||
).freeze
|
).freeze
|
||||||
|
|
||||||
|
SUPPORTED_OPERATOR = %w(
|
||||||
|
+
|
||||||
|
-
|
||||||
|
).freeze
|
||||||
|
|
||||||
|
SUPPORTED_PROPERTIES = %w(
|
||||||
|
image
|
||||||
|
video
|
||||||
|
audio
|
||||||
|
media
|
||||||
|
poll
|
||||||
|
link
|
||||||
|
embed
|
||||||
|
sensitive
|
||||||
|
reply
|
||||||
|
).freeze
|
||||||
|
|
||||||
class Query
|
class Query
|
||||||
def initialize(clauses, options = {})
|
def initialize(clauses, options = {})
|
||||||
raise ArgumentError if options[:current_account].nil?
|
raise ArgumentError if options[:current_account].nil?
|
||||||
|
@ -152,6 +169,8 @@ class SearchQueryTransformer < Parslet::Transform
|
||||||
|
|
||||||
case prefix
|
case prefix
|
||||||
when 'has', 'is'
|
when 'has', 'is'
|
||||||
|
raise "Unknown properties: #{term}" unless SUPPORTED_PROPERTIES.include?(term)
|
||||||
|
|
||||||
@filter = :properties
|
@filter = :properties
|
||||||
@type = :term
|
@type = :term
|
||||||
@term = term
|
@term = term
|
||||||
|
|
Loading…
Add table
Reference in a new issue