forked from AkkomaGang/akkoma
Pleroma.Object/1: take %Object{} as argument instead
This commit is contained in:
parent
87b13c5430
commit
18b536c176
9 changed files with 12 additions and 17 deletions
|
@ -48,18 +48,12 @@ defp item_creation_tags(tags, _, _) do
|
||||||
tags
|
tags
|
||||||
end
|
end
|
||||||
|
|
||||||
defp hashtags_to_topics(%{data: %{"hashtags" => tags}}) do
|
defp hashtags_to_topics(object) do
|
||||||
Enum.map(tags, fn tag -> "hashtag:" <> tag end)
|
object
|
||||||
end
|
|> Object.hashtags()
|
||||||
|
|
||||||
defp hashtags_to_topics(%{data: %{"tag" => tags}}) do
|
|
||||||
tags
|
|
||||||
|> Enum.filter(&is_bitstring(&1))
|
|
||||||
|> Enum.map(fn tag -> "hashtag:" <> tag end)
|
|> Enum.map(fn tag -> "hashtag:" <> tag end)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp hashtags_to_topics(_), do: []
|
|
||||||
|
|
||||||
defp remote_topics(%{local: true}), do: []
|
defp remote_topics(%{local: true}), do: []
|
||||||
|
|
||||||
defp remote_topics(%{actor: actor}) when is_binary(actor),
|
defp remote_topics(%{actor: actor}) when is_binary(actor),
|
||||||
|
|
|
@ -345,7 +345,7 @@ def replies(object, opts \\ []) do
|
||||||
def self_replies(object, opts \\ []),
|
def self_replies(object, opts \\ []),
|
||||||
do: replies(object, Keyword.put(opts, :self_only, true))
|
do: replies(object, Keyword.put(opts, :self_only, true))
|
||||||
|
|
||||||
def hashtags(%{"hashtags" => hashtags}), do: hashtags || []
|
def hashtags(%Object{data: %{"hashtags" => hashtags}}), do: hashtags || []
|
||||||
def hashtags(%{"tag" => tags}), do: Enum.filter(tags, &is_bitstring(&1))
|
def hashtags(%Object{data: %{"tag" => tags}}), do: Enum.filter(tags, &is_bitstring(&1))
|
||||||
def hashtags(_), do: []
|
def hashtags(_), do: []
|
||||||
end
|
end
|
||||||
|
|
|
@ -77,7 +77,7 @@ defp check_media_nsfw(
|
||||||
if MRF.subdomain_match?(media_nsfw, actor_host) do
|
if MRF.subdomain_match?(media_nsfw, actor_host) do
|
||||||
child_object =
|
child_object =
|
||||||
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("sensitive", true)
|
||||||
|
|
||||||
Map.put(object, "object", child_object)
|
Map.put(object, "object", child_object)
|
||||||
|
|
|
@ -864,7 +864,7 @@ def maybe_fix_object_url(data), do: data
|
||||||
|
|
||||||
def add_hashtags(object) do
|
def add_hashtags(object) do
|
||||||
hashtags =
|
hashtags =
|
||||||
object
|
%Object{data: object}
|
||||||
|> Object.hashtags()
|
|> Object.hashtags()
|
||||||
|> Enum.map(fn tag ->
|
|> Enum.map(fn tag ->
|
||||||
%{
|
%{
|
||||||
|
|
|
@ -32,6 +32,7 @@ def prepare_activity(activity, opts \\ []) do
|
||||||
|
|
||||||
%{
|
%{
|
||||||
activity: activity,
|
activity: activity,
|
||||||
|
object: object,
|
||||||
data: Map.get(object, :data),
|
data: Map.get(object, :data),
|
||||||
actor: actor
|
actor: actor
|
||||||
}
|
}
|
||||||
|
|
|
@ -347,7 +347,7 @@ def render("show.json", %{activity: %{data: %{"object" => _object}} = activity}
|
||||||
media_attachments: attachments,
|
media_attachments: attachments,
|
||||||
poll: render(PollView, "show.json", object: object, for: opts[:for]),
|
poll: render(PollView, "show.json", object: object, for: opts[:for]),
|
||||||
mentions: mentions,
|
mentions: mentions,
|
||||||
tags: build_tags(Object.hashtags(object.data)),
|
tags: build_tags(Object.hashtags(object)),
|
||||||
application: %{
|
application: %{
|
||||||
name: "Web",
|
name: "Web",
|
||||||
website: nil
|
website: nil
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
<link type="text/html" href='<%= @data["external_url"] %>' rel="alternate"/>
|
<link type="text/html" href='<%= @data["external_url"] %>' rel="alternate"/>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= for hashtag <- Object.hashtags(@data) do %>
|
<%= for hashtag <- Object.hashtags(@object) do %>
|
||||||
<category term="<%= hashtag %>"></category>
|
<category term="<%= hashtag %>"></category>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
<link><%= @data["external_url"] %></link>
|
<link><%= @data["external_url"] %></link>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= for hashtag <- Object.hashtags(@data) do %>
|
<%= for hashtag <- Object.hashtags(@object) do %>
|
||||||
<category term="<%= hashtag %>"></category>
|
<category term="<%= hashtag %>"></category>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= for hashtag <- Object.hashtags(@data) do %>
|
<%= for hashtag <- Object.hashtags(@object) do %>
|
||||||
<category term="<%= hashtag %>"></category>
|
<category term="<%= hashtag %>"></category>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue