summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorIvan Tashkinov <ivantashkinov@gmail.com>2021-01-29 00:17:33 +0300
committerIvan Tashkinov <ivantashkinov@gmail.com>2021-01-29 00:17:33 +0300
commit380d0cce6b802baf4d13031a4a39f169dd65bffd (patch)
tree83bdfd18e29d5ac6efcb74775e37820bcc63cb74 /lib
parente7864a32d7c9930e5f6c62bd77cef64c68f1eb21 (diff)
downloadpleroma-380d0cce6b802baf4d13031a4a39f169dd65bffd.tar.gz
pleroma-380d0cce6b802baf4d13031a4a39f169dd65bffd.zip
[#3213] Reinstated DISTINCT clause for hashtag "any" filtering with 2+ terms. Added test.
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/activity_pub/activity_pub.ex17
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex2
2 files changed, 13 insertions, 6 deletions
diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex
index be81e0833..0a21ac2f2 100644
--- a/lib/pleroma/web/activity_pub/activity_pub.ex
+++ b/lib/pleroma/web/activity_pub/activity_pub.ex
@@ -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
diff --git a/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex b/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex
index 08e6f23b9..1fb954a9b 100644
--- a/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex
+++ b/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex
@@ -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