Fix Rich Media Previews for updated activities
The Rich Media Previews were not regenerated when a post was updated due to a cache invalidation issue. They are now cached by the activity id so they can be evicted with the other activity cache objects in the :scrubber_cache.
This commit is contained in:
parent
0b9990a7e5
commit
04fc4eddaa
8 changed files with 96 additions and 23 deletions
|
|
@ -83,6 +83,34 @@ defmodule Pleroma.Web.RichMedia.HelpersTest do
|
|||
Pleroma.Web.RichMedia.Helpers.fetch_data_for_activity(activity)
|
||||
end
|
||||
|
||||
test "recrawls URLs on updates" do
|
||||
original_url = "https://google.com/"
|
||||
updated_url = "https://yahoo.com/"
|
||||
|
||||
Pleroma.StaticStubbedConfigMock
|
||||
|> stub(:get, fn
|
||||
[:rich_media, :enabled] -> true
|
||||
path -> Pleroma.Test.StaticConfig.get(path)
|
||||
end)
|
||||
|
||||
user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "I like this site #{original_url}"})
|
||||
|
||||
assert match?(
|
||||
%{page_url: ^original_url, rich_media: _},
|
||||
Pleroma.Web.RichMedia.Helpers.fetch_data_for_activity(activity)
|
||||
)
|
||||
|
||||
{:ok, _} = CommonAPI.update(user, activity, %{status: "I like this site #{updated_url}"})
|
||||
|
||||
activity = Pleroma.Activity.get_by_id(activity.id)
|
||||
|
||||
assert match?(
|
||||
%{page_url: ^updated_url, rich_media: _},
|
||||
Pleroma.Web.RichMedia.Helpers.fetch_data_for_activity(activity)
|
||||
)
|
||||
end
|
||||
|
||||
# This does not seem to work. The urls are being fetched.
|
||||
@tag skip: true
|
||||
test "refuses to crawl URLs of private network from posts" do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue