mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 00:26:30 +00:00
Merge branch 'oban/richmedia-stream' into 'develop'
RichMedia: test that activity is streamed out after backfill See merge request pleroma/pleroma!4160
This commit is contained in:
commit
9953b0da59
4 changed files with 10 additions and 2 deletions
0
changelog.d/rich_media_stream_test.skip
Normal file
0
changelog.d/rich_media_stream_test.skip
Normal file
|
@ -184,7 +184,8 @@ config :pleroma, Pleroma.Uploaders.Uploader, timeout: 1_000
|
||||||
|
|
||||||
config :pleroma, Pleroma.Emoji.Loader, test_emoji: true
|
config :pleroma, Pleroma.Emoji.Loader, test_emoji: true
|
||||||
|
|
||||||
config :pleroma, Pleroma.Web.RichMedia.Backfill, provider: Pleroma.Web.RichMedia.Backfill
|
config :pleroma, Pleroma.Web.RichMedia.Backfill,
|
||||||
|
stream_out: Pleroma.Web.ActivityPub.ActivityPubMock
|
||||||
|
|
||||||
if File.exists?("./config/test.secret.exs") do
|
if File.exists?("./config/test.secret.exs") do
|
||||||
import_config "test.secret.exs"
|
import_config "test.secret.exs"
|
||||||
|
|
|
@ -11,6 +11,10 @@ defmodule Pleroma.Web.RichMedia.Backfill do
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
@cachex Pleroma.Config.get([:cachex, :provider], Cachex)
|
@cachex Pleroma.Config.get([:cachex, :provider], Cachex)
|
||||||
|
@stream_out_impl Pleroma.Config.get(
|
||||||
|
[__MODULE__, :stream_out],
|
||||||
|
Pleroma.Web.ActivityPub.ActivityPub
|
||||||
|
)
|
||||||
|
|
||||||
@spec run(map()) ::
|
@spec run(map()) ::
|
||||||
:ok | {:error, {:invalid_metadata, any()} | :body_too_large | {:content, any()} | any()}
|
:ok | {:error, {:invalid_metadata, any()} | :body_too_large | {:content, any()} | any()}
|
||||||
|
@ -64,7 +68,7 @@ defmodule Pleroma.Web.RichMedia.Backfill do
|
||||||
defp stream_update(%{"activity_id" => activity_id}) do
|
defp stream_update(%{"activity_id" => activity_id}) do
|
||||||
Pleroma.Activity.get_by_id(activity_id)
|
Pleroma.Activity.get_by_id(activity_id)
|
||||||
|> Pleroma.Activity.normalize()
|
|> Pleroma.Activity.normalize()
|
||||||
|> Pleroma.Web.ActivityPub.ActivityPub.stream_out()
|
|> @stream_out_impl.stream_out()
|
||||||
end
|
end
|
||||||
|
|
||||||
defp warm_cache(key, val), do: @cachex.put(:rich_media_cache, key, val)
|
defp warm_cache(key, val), do: @cachex.put(:rich_media_cache, key, val)
|
||||||
|
|
|
@ -39,6 +39,9 @@ defmodule Pleroma.Web.RichMedia.CardTest do
|
||||||
content_type: "text/markdown"
|
content_type: "text/markdown"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Pleroma.Web.ActivityPub.ActivityPubMock
|
||||||
|
|> expect(:stream_out, fn ^activity -> nil end)
|
||||||
|
|
||||||
assert_enqueued(
|
assert_enqueued(
|
||||||
worker: RichMediaWorker,
|
worker: RichMediaWorker,
|
||||||
args: %{"url" => url, "activity_id" => activity.id}
|
args: %{"url" => url, "activity_id" => activity.id}
|
||||||
|
|
Loading…
Reference in a new issue