mirror of
https://git.youjo.love/youjo/youjo-be.git
synced 2024-11-20 13:59:55 +01:00
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 @@ defmodule Pleroma.Activity.Ir.Topics 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),
|
||||
|
|
|
@ -345,7 +345,7 @@ defmodule Pleroma.Object 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
|
||||
|
|
|
@ -77,7 +77,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicy do
|
|||
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)
|
||||
|
|
|
@ -864,7 +864,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
|||
|
||||
def add_hashtags(object) do
|
||||
hashtags =
|
||||
object
|
||||
%Object{data: object}
|
||||
|> Object.hashtags()
|
||||
|> Enum.map(fn tag ->
|
||||
%{
|
||||
|
|
|
@ -32,6 +32,7 @@ defmodule Pleroma.Web.Feed.FeedView do
|
|||
|
||||
%{
|
||||
activity: activity,
|
||||
object: object,
|
||||
data: Map.get(object, :data),
|
||||
actor: actor
|
||||
}
|
||||
|
|
|
@ -347,7 +347,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
|
|||
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
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<link type="text/html" href='<%= @data["external_url"] %>' rel="alternate"/>
|
||||
<% end %>
|
||||
|
||||
<%= for hashtag <- Object.hashtags(@data) do %>
|
||||
<%= for hashtag <- Object.hashtags(@object) do %>
|
||||
<category term="<%= hashtag %>"></category>
|
||||
<% end %>
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
<link><%= @data["external_url"] %></link>
|
||||
<% end %>
|
||||
|
||||
<%= for hashtag <- Object.hashtags(@data) do %>
|
||||
<%= for hashtag <- Object.hashtags(@object) do %>
|
||||
<category term="<%= hashtag %>"></category>
|
||||
<% end %>
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<%= for hashtag <- Object.hashtags(@data) do %>
|
||||
<%= for hashtag <- Object.hashtags(@object) do %>
|
||||
<category term="<%= hashtag %>"></category>
|
||||
<% end %>
|
||||
|
||||
|
|
Loading…
Reference in a new issue