RichMedia: Add support for disabling wss streaming out on backfill
This commit is contained in:
parent
94a28d1286
commit
678fe8a064
4 changed files with 79 additions and 16 deletions
|
|
@ -5,12 +5,20 @@
|
|||
defmodule Pleroma.Web.RichMedia.BackfillTest do
|
||||
use Pleroma.DataCase
|
||||
|
||||
alias Pleroma.Web.CommonAPI
|
||||
alias Pleroma.Web.RichMedia.Backfill
|
||||
alias Pleroma.Web.RichMedia.Card
|
||||
|
||||
import Mox
|
||||
import Pleroma.Factory
|
||||
|
||||
setup_all do: clear_config([:rich_media, :enabled], true)
|
||||
setup do
|
||||
clear_config([:rich_media, :enabled], true)
|
||||
|
||||
Mox.stub_with(Pleroma.CachexMock, Pleroma.NullCache)
|
||||
|
||||
:ok
|
||||
end
|
||||
|
||||
test "sets a negative cache entry for an error" do
|
||||
url = "https://bad.example.com/"
|
||||
|
|
@ -45,4 +53,50 @@ defmodule Pleroma.Web.RichMedia.BackfillTest do
|
|||
|
||||
Backfill.run(%{"url" => url})
|
||||
end
|
||||
|
||||
test "streams out update when stream == true" do
|
||||
url = "https://example.com"
|
||||
user = insert(:user)
|
||||
|
||||
Tesla.Mock.mock(fn %{url: ^url} ->
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: "<head><meta name=\"twitter:title\" content=\"Cofe\"></head>"
|
||||
}}
|
||||
end)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "#cofe #{url}"})
|
||||
|
||||
Pleroma.CachexMock
|
||||
|> expect(:put, fn :rich_media_cache, _, _ -> {:ok, true} end)
|
||||
|
||||
Pleroma.Web.ActivityPub.ActivityPubMock
|
||||
|> expect(:stream_out, fn _ -> :ok end)
|
||||
|
||||
Backfill.run(%{"url" => url, "activity_id" => "#{activity.data["id"]}", "stream" => true})
|
||||
end
|
||||
|
||||
test "does not stream out update when stream == false" do
|
||||
url = "https://example.com"
|
||||
user = insert(:user)
|
||||
|
||||
Tesla.Mock.mock(fn %{url: ^url} ->
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: "<head><meta name=\"twitter:title\" content=\"Cofe\"></head>"
|
||||
}}
|
||||
end)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "#cofe #{url}"})
|
||||
|
||||
Pleroma.CachexMock
|
||||
|> expect(:put, fn :rich_media_cache, _, _ -> {:ok, true} end)
|
||||
|
||||
Pleroma.Web.ActivityPub.ActivityPubMock
|
||||
|> deny(:stream_out, 1)
|
||||
|
||||
Backfill.run(%{"url" => url, "activity_id" => "#{activity.data["id"]}", "stream" => false})
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue