credo, lint

This commit is contained in:
Phantasm 2026-05-23 19:49:22 +02:00
commit 0c0d687330
No known key found for this signature in database
GPG key ID: 2669E588BCC634C8
4 changed files with 19 additions and 6 deletions

View file

@ -32,6 +32,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
# otherwise old posts can show up on timelines. # otherwise old posts can show up on timelines.
defp fetch_rich_media_for_activities(activities, opts) do defp fetch_rich_media_for_activities(activities, opts) do
opts = Map.put(opts, :stream, false) opts = Map.put(opts, :stream, false)
Enum.each(activities, fn activity -> Enum.each(activities, fn activity ->
Card.get_by_activity(activity, opts) Card.get_by_activity(activity, opts)
end) end)

View file

@ -53,7 +53,8 @@ defmodule Pleroma.Web.RichMedia.Backfill do
end end
end end
defp maybe_update_stream(%{"activity_id" => activity_id, "stream" => true}) when is_binary(activity_id) do defp maybe_update_stream(%{"activity_id" => activity_id, "stream" => true})
when is_binary(activity_id) do
Pleroma.Activity.get_by_id(activity_id) Pleroma.Activity.get_by_id(activity_id)
|> Pleroma.Activity.normalize() |> Pleroma.Activity.normalize()
|> @stream_out_impl.stream_out() |> @stream_out_impl.stream_out()

View file

@ -90,12 +90,19 @@ defmodule Pleroma.Web.RichMedia.Card do
nil -> nil ->
activity_id = Keyword.get(opts, :activity_id, nil) activity_id = Keyword.get(opts, :activity_id, nil)
# Nested opts, first layer comes from get_by_activity/2 as Keyword, second from API views/Federation as Map.
# Nested opts, first layer comes from get_by_activity/2 as Keyword,
# second from API views/Federation as Map.
# Provide default Map when called directly. # Provide default Map when called directly.
opts = Keyword.get(opts, :opts, %{}) opts = Keyword.get(opts, :opts, %{})
stream = Map.get(opts, :stream, true) stream = Map.get(opts, :stream, true)
RichMediaWorker.new(%{"op" => "backfill", "url" => url, "activity_id" => activity_id, "stream" => stream}) RichMediaWorker.new(%{
"op" => "backfill",
"url" => url,
"activity_id" => activity_id,
"stream" => stream
})
|> Oban.insert() |> Oban.insert()
nil nil

View file

@ -5,15 +5,15 @@
defmodule Pleroma.Web.RichMedia.BackfillTest do defmodule Pleroma.Web.RichMedia.BackfillTest do
use Pleroma.DataCase use Pleroma.DataCase
alias Pleroma.Tests.ObanHelpers
alias Pleroma.Web.CommonAPI alias Pleroma.Web.CommonAPI
alias Pleroma.Web.RichMedia.Backfill alias Pleroma.Web.RichMedia.Backfill
alias Pleroma.Web.RichMedia.Card alias Pleroma.Web.RichMedia.Card
alias Pleroma.Tests.ObanHelpers
import Mox import Mox
import Pleroma.Factory import Pleroma.Factory
setup do setup do
clear_config([:rich_media, :enabled], true) clear_config([:rich_media, :enabled], true)
Mox.stub_with(Pleroma.UnstubbedConfigMock, Pleroma.Test.StaticConfig) Mox.stub_with(Pleroma.UnstubbedConfigMock, Pleroma.Test.StaticConfig)
@ -131,7 +131,11 @@ defmodule Pleroma.Web.RichMedia.BackfillTest do
Pleroma.Activity.HTML.invalidate_cache_for(activity.id) Pleroma.Activity.HTML.invalidate_cache_for(activity.id)
Pleroma.Web.RichMedia.Card.delete(url) Pleroma.Web.RichMedia.Card.delete(url)
Pleroma.Web.MastodonAPI.StatusView.render("index.json", %{activities: [activity], as: :activity}) Pleroma.Web.MastodonAPI.StatusView.render("index.json", %{
activities: [activity],
as: :activity
})
ObanHelpers.perform_all() ObanHelpers.perform_all()
end end