[#3213] Reinstated DISTINCT clause for hashtag "any" filtering with 2+ terms. Added test.

This commit is contained in:
Ivan Tashkinov 2021-01-29 00:17:33 +03:00
commit 380d0cce6b
3 changed files with 28 additions and 8 deletions

View file

@ -846,11 +846,18 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
end
defp restrict_hashtag_any(query, %{tag: tags}) when is_list(tags) do
from(
[_activity, object] in query,
join: hashtag in assoc(object, :hashtags),
where: hashtag.name in ^tags
)
query =
from(
[_activity, object] in query,
join: hashtag in assoc(object, :hashtags),
where: hashtag.name in ^tags
)
if length(tags) > 1 do
distinct(query, [activity], true)
else
query
end
end
defp restrict_hashtag_any(query, %{tag: tag}) when is_binary(tag) do

View file

@ -134,9 +134,9 @@ defmodule Pleroma.Web.MastodonAPI.TimelineController do
tags =
[params[:tag], params[:any]]
|> List.flatten()
|> Enum.uniq()
|> Enum.reject(&is_nil/1)
|> Enum.map(&String.downcase/1)
|> Enum.uniq()
tag_all =
params