Fix the logic in multi-hashtag TLs
This commit is contained in:
parent
4ad0ad14ed
commit
5a84def6a6
4 changed files with 37 additions and 7 deletions
|
|
@ -426,15 +426,26 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
|||
|
||||
defp restrict_since(query, _), do: query
|
||||
|
||||
defp restrict_tag(query, %{"tag" => tag, "tag_reject" => tag_reject})
|
||||
when is_list(tag) and tag_reject != [] do
|
||||
defp restrict_tag_reject(query, %{"tag_reject" => tag_reject})
|
||||
when is_list(tag_reject) and tag_reject != [] do
|
||||
from(
|
||||
activity in query,
|
||||
where: fragment("(? #> '{\"object\",\"tag\"}') \\?| ?", activity.data, ^tag),
|
||||
where: fragment("(not (? #> '{\"object\",\"tag\"}') \\?| ?)", activity.data, ^tag_reject)
|
||||
)
|
||||
end
|
||||
|
||||
defp restrict_tag_reject(query, _), do: query
|
||||
|
||||
defp restrict_tag_all(query, %{"tag_all" => tag_all})
|
||||
when is_list(tag_all) and tag_all != [] do
|
||||
from(
|
||||
activity in query,
|
||||
where: fragment("(? #> '{\"object\",\"tag\"}') \\?& ?", activity.data, ^tag_all)
|
||||
)
|
||||
end
|
||||
|
||||
defp restrict_tag_all(query, _), do: query
|
||||
|
||||
defp restrict_tag(query, %{"tag" => tag}) when is_list(tag) do
|
||||
from(
|
||||
activity in query,
|
||||
|
|
@ -591,6 +602,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
|||
base_query
|
||||
|> restrict_recipients(recipients, opts["user"])
|
||||
|> restrict_tag(opts)
|
||||
|> restrict_tag_reject(opts)
|
||||
|> restrict_tag_all(opts)
|
||||
|> restrict_since(opts)
|
||||
|> restrict_local(opts)
|
||||
|> restrict_limit(opts)
|
||||
|
|
|
|||
|
|
@ -541,11 +541,16 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
|
|||
local_only = params["local"] in [true, "True", "true", "1"]
|
||||
|
||||
tags =
|
||||
([params["tag"]] ++ (params["all"] || []) ++ (params["any"] || []))
|
||||
([params["tag"]] ++ (params["any"] || []))
|
||||
|> Enum.uniq()
|
||||
|> Enum.filter(& &1)
|
||||
|> Enum.map(&String.downcase(&1))
|
||||
|
||||
tag_all =
|
||||
params["all"] ||
|
||||
[]
|
||||
|> Enum.map(&String.downcase(&1))
|
||||
|
||||
tag_reject =
|
||||
params["none"] ||
|
||||
[]
|
||||
|
|
@ -557,6 +562,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
|
|||
|> Map.put("local_only", local_only)
|
||||
|> Map.put("blocking_user", user)
|
||||
|> Map.put("tag", tags)
|
||||
|> Map.put("tag_all", tag_all)
|
||||
|> Map.put("tag_reject", tag_reject)
|
||||
|
||||
activities =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue