Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F85829841
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/lib/pleroma/web/activity_pub/object_validator.ex b/lib/pleroma/web/activity_pub/object_validator.ex
index a678b94d1..0c01ec917 100644
--- a/lib/pleroma/web/activity_pub/object_validator.ex
+++ b/lib/pleroma/web/activity_pub/object_validator.ex
@@ -224,6 +224,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidator do
with {_, {:ok, object_data, _}} <-
{:object_validation,
object
+ |> maybe_drop_local_history(meta)
|> CommonFixes.maybe_set_attributed_to_from_activity(update_activity)
|> CommonFixes.maybe_add_language_from_activity(update_activity)
|> validate(meta)},
@@ -329,6 +330,16 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidator do
defp maybe_rebuild_local_update_object(object, _meta), do: object
+ # The server built the history of local objects from stored data, which
+ # older versions may not have validated.
+ defp maybe_drop_local_history(object, meta) do
+ if Keyword.get(meta, :local, false) do
+ Map.delete(object, "formerRepresentations")
+ else
+ object
+ end
+ end
+
defp validate_local_update(%{"id" => id} = object_data, meta) do
with true <- Keyword.get(meta, :local, false),
%Object{} = orig_object <- Object.get_by_ap_id(id) do
diff --git a/lib/pleroma/web/common_api.ex b/lib/pleroma/web/common_api.ex
index 75cc38436..2c1d5489b 100644
--- a/lib/pleroma/web/common_api.ex
+++ b/lib/pleroma/web/common_api.ex
@@ -571,7 +571,9 @@ defmodule Pleroma.Web.CommonAPI do
{:ok, update, _} <- Pipeline.common_pipeline(update_data, local: true) do
{:ok, update}
else
- _ -> {:error, nil}
+ error ->
+ Logger.warning("Could not update #{orig_activity.id}: #{inspect(error)}")
+ {:error, nil}
end
end
diff --git a/test/pleroma/web/activity_pub/object_validators/update_handling_test.exs b/test/pleroma/web/activity_pub/object_validators/update_handling_test.exs
index 50dbab587..26fb2cd38 100644
--- a/test/pleroma/web/activity_pub/object_validators/update_handling_test.exs
+++ b/test/pleroma/web/activity_pub/object_validators/update_handling_test.exs
@@ -180,6 +180,17 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.UpdateHandlingTest do
refute object["updated"] =~ "2999"
end
+ test "a local Update does not validate the stored history again" do
+ user = insert(:user)
+ old_history = %{"type" => "OrderedCollection", "totalItems" => 1, "orderedItems" => [%{}]}
+ note = insert(:note, user: user, data: %{"formerRepresentations" => old_history})
+
+ {:ok, update, _} = Builder.update(user, Map.put(note.data, "content", "edited"))
+
+ assert {:ok, %{"object" => %{"content" => "edited"}}, _} =
+ ObjectValidator.validate(update, local: true)
+ end
+
test "a local Update with an invalid object is rejected" do
user = insert(:user)
note = insert(:note, user: user)
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sun, Nov 1, 12:50 AM (17 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1802006
Default Alt Text
(2 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline