diff --git a/lib/pleroma/activity/ir/topics.ex b/lib/pleroma/activity/ir/topics.ex
index 2cdecf1e4..b7553c728 100644
--- a/lib/pleroma/activity/ir/topics.ex
+++ b/lib/pleroma/activity/ir/topics.ex
@@ -48,18 +48,12 @@ defp item_creation_tags(tags, _, _) do
tags
end
- defp hashtags_to_topics(%{data: %{"hashtags" => tags}}) do
- Enum.map(tags, fn tag -> "hashtag:" <> tag end)
- end
-
- defp hashtags_to_topics(%{data: %{"tag" => tags}}) do
- tags
- |> Enum.filter(&is_bitstring(&1))
+ defp hashtags_to_topics(object) do
+ object
+ |> Object.hashtags()
|> Enum.map(fn tag -> "hashtag:" <> tag end)
end
- defp hashtags_to_topics(_), do: []
-
defp remote_topics(%{local: true}), do: []
defp remote_topics(%{actor: actor}) when is_binary(actor),
diff --git a/lib/pleroma/object.ex b/lib/pleroma/object.ex
index 00d561d1b..9cbc1c6a6 100644
--- a/lib/pleroma/object.ex
+++ b/lib/pleroma/object.ex
@@ -345,7 +345,7 @@ def replies(object, opts \\ []) do
def self_replies(object, opts \\ []),
do: replies(object, Keyword.put(opts, :self_only, true))
- def hashtags(%{"hashtags" => hashtags}), do: hashtags || []
- def hashtags(%{"tag" => tags}), do: Enum.filter(tags, &is_bitstring(&1))
+ def hashtags(%Object{data: %{"hashtags" => hashtags}}), do: hashtags || []
+ def hashtags(%Object{data: %{"tag" => tags}}), do: Enum.filter(tags, &is_bitstring(&1))
def hashtags(_), do: []
end
diff --git a/lib/pleroma/web/activity_pub/mrf/simple_policy.ex b/lib/pleroma/web/activity_pub/mrf/simple_policy.ex
index 8e0514dc8..94933ce99 100644
--- a/lib/pleroma/web/activity_pub/mrf/simple_policy.ex
+++ b/lib/pleroma/web/activity_pub/mrf/simple_policy.ex
@@ -77,7 +77,7 @@ defp check_media_nsfw(
if MRF.subdomain_match?(media_nsfw, actor_host) do
child_object =
child_object
- |> Map.put("hashtags", Object.hashtags(child_object) ++ ["nsfw"])
+ |> Map.put("hashtags", Object.hashtags(%Object{data: child_object}) ++ ["nsfw"])
|> Map.put("sensitive", true)
Map.put(object, "object", child_object)
diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex
index 36ef6a454..109f03641 100644
--- a/lib/pleroma/web/activity_pub/transmogrifier.ex
+++ b/lib/pleroma/web/activity_pub/transmogrifier.ex
@@ -864,7 +864,7 @@ def maybe_fix_object_url(data), do: data
def add_hashtags(object) do
hashtags =
- object
+ %Object{data: object}
|> Object.hashtags()
|> Enum.map(fn tag ->
%{
diff --git a/lib/pleroma/web/feed/feed_view.ex b/lib/pleroma/web/feed/feed_view.ex
index 30e0a2a55..1155c6a39 100644
--- a/lib/pleroma/web/feed/feed_view.ex
+++ b/lib/pleroma/web/feed/feed_view.ex
@@ -32,6 +32,7 @@ def prepare_activity(activity, opts \\ []) do
%{
activity: activity,
+ object: object,
data: Map.get(object, :data),
actor: actor
}
diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex
index b39f05d13..3ba453d1f 100644
--- a/lib/pleroma/web/mastodon_api/views/status_view.ex
+++ b/lib/pleroma/web/mastodon_api/views/status_view.ex
@@ -347,7 +347,7 @@ def render("show.json", %{activity: %{data: %{"object" => _object}} = activity}
media_attachments: attachments,
poll: render(PollView, "show.json", object: object, for: opts[:for]),
mentions: mentions,
- tags: build_tags(Object.hashtags(object.data)),
+ tags: build_tags(Object.hashtags(object)),
application: %{
name: "Web",
website: nil
diff --git a/lib/pleroma/web/templates/feed/feed/_activity.atom.eex b/lib/pleroma/web/templates/feed/feed/_activity.atom.eex
index cb18abb5d..4a1a3e993 100644
--- a/lib/pleroma/web/templates/feed/feed/_activity.atom.eex
+++ b/lib/pleroma/web/templates/feed/feed/_activity.atom.eex
@@ -22,7 +22,7 @@
<% end %>
- <%= for hashtag <- Object.hashtags(@data) do %>
+ <%= for hashtag <- Object.hashtags(@object) do %>
<% end %>
diff --git a/lib/pleroma/web/templates/feed/feed/_activity.rss.eex b/lib/pleroma/web/templates/feed/feed/_activity.rss.eex
index 6ef24d0ef..9ebaa3300 100644
--- a/lib/pleroma/web/templates/feed/feed/_activity.rss.eex
+++ b/lib/pleroma/web/templates/feed/feed/_activity.rss.eex
@@ -21,7 +21,7 @@
<%= @data["external_url"] %>
<% end %>
- <%= for hashtag <- Object.hashtags(@data) do %>
+ <%= for hashtag <- Object.hashtags(@object) do %>
<% end %>
diff --git a/lib/pleroma/web/templates/feed/feed/_tag_activity.atom.eex b/lib/pleroma/web/templates/feed/feed/_tag_activity.atom.eex
index 098e28205..8d78520cf 100644
--- a/lib/pleroma/web/templates/feed/feed/_tag_activity.atom.eex
+++ b/lib/pleroma/web/templates/feed/feed/_tag_activity.atom.eex
@@ -41,7 +41,7 @@
<% end %>
<% end %>
- <%= for hashtag <- Object.hashtags(@data) do %>
+ <%= for hashtag <- Object.hashtags(@object) do %>
<% end %>