[#3213] Made Object.hashtags/1 work with :hashtags assoc. Adjusted tests.

This commit is contained in:
Ivan Tashkinov 2020-12-28 00:08:09 +03:00
commit 14fae94c0e
4 changed files with 29 additions and 14 deletions

View file

@ -96,6 +96,8 @@ defmodule Pleroma.Config do
end
end
def object_embedded_hashtags?, do: !get([:instance, :improved_hashtag_timeline])
def oauth_consumer_strategies, do: get([:auth, :oauth_consumer_strategies], [])
def oauth_consumer_enabled?, do: oauth_consumer_strategies() != []

View file

@ -384,7 +384,19 @@ defmodule Pleroma.Object do
def tags(_), do: []
def hashtags(object), do: embedded_hashtags(object)
def hashtags(%Object{} = object) do
cond do
Config.object_embedded_hashtags?() ->
embedded_hashtags(object)
object.id == "pleroma:fake_object_id" ->
[]
true ->
hashtag_records = Repo.preload(object, :hashtags).hashtags
Enum.map(hashtag_records, & &1.name)
end
end
defp embedded_hashtags(%Object{data: data}) do
object_data_hashtags(data)

View file

@ -1199,16 +1199,16 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|> exclude_invisible_actors(opts)
|> exclude_visibility(opts)
if Config.get([:instance, :improved_hashtag_timeline]) do
query
|> restrict_hashtag_any(opts)
|> restrict_hashtag_all(opts)
|> restrict_hashtag_reject_any(opts)
else
if Config.object_embedded_hashtags?() do
query
|> restrict_tag(opts)
|> restrict_tag_reject(opts)
|> restrict_tag_all(opts)
else
query
|> restrict_hashtag_any(opts)
|> restrict_hashtag_all(opts)
|> restrict_hashtag_reject_any(opts)
end
end