Web.ActivityPub.ActivityPub: Simplify multi-hashtag, add tests
This commit is contained in:
parent
d8f446f438
commit
4ad0ad14ed
2 changed files with 24 additions and 18 deletions
|
|
@ -430,30 +430,15 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
|||
when is_list(tag) and tag_reject != [] do
|
||||
from(
|
||||
activity in query,
|
||||
where:
|
||||
fragment(
|
||||
"? && ARRAY(SELECT jsonb_array_elements_text((? #> '{\"object\",\"tag\"}')))",
|
||||
^tag,
|
||||
activity.data
|
||||
),
|
||||
where:
|
||||
fragment(
|
||||
"(not ? && ARRAY(SELECT jsonb_array_elements_text((? #> '{\"object\",\"tag\"}'))))",
|
||||
^tag_reject,
|
||||
activity.data
|
||||
)
|
||||
where: fragment("(? #> '{\"object\",\"tag\"}') \\?| ?", activity.data, ^tag),
|
||||
where: fragment("(not (? #> '{\"object\",\"tag\"}') \\?| ?)", activity.data, ^tag_reject)
|
||||
)
|
||||
end
|
||||
|
||||
defp restrict_tag(query, %{"tag" => tag}) when is_list(tag) do
|
||||
from(
|
||||
activity in query,
|
||||
where:
|
||||
fragment(
|
||||
"? && ARRAY(SELECT jsonb_array_elements_text((? #> '{\"object\",\"tag\"}')))",
|
||||
^tag,
|
||||
activity.data
|
||||
)
|
||||
where: fragment("(? #> '{\"object\",\"tag\"}') \\?| ?", activity.data, ^tag)
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue