diff options
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | lib/pleroma/web/activity_pub/activity_pub.ex | 4 | ||||
| -rw-r--r-- | lib/pleroma/web/activity_pub/utils.ex | 17 | ||||
| -rw-r--r-- | lib/pleroma/web/ostatus/activity_representer.ex | 3 | ||||
| -rw-r--r-- | test/web/activity_pub/activity_pub_test.exs | 6 | ||||
| -rw-r--r-- | test/web/ostatus/ostatus_test.exs | 2 | 
6 files changed, 7 insertions, 26 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 2713461ed..069974e44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).  ### Fixed  - Not being able to pin unlisted posts +- Objects being re-embedded to activities after being updated (e.g faved/reposted). Running 'mix pleroma.database prune_objects' again is advised.  - Metadata rendering errors resulting in the entire page being inaccessible  - Federation/MediaProxy not working with instances that have wrong certificate order  - Mastodon API: Handling of search timeouts (`/api/v1/search` and `/api/v2/search`) diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 2877c029e..1a279a7df 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -749,8 +749,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do    defp restrict_favorited_by(query, %{"favorited_by" => ap_id}) do      from( -      activity in query, -      where: fragment(~s(? <@ (? #> '{"object","likes"}'\)), ^ap_id, activity.data) +      [_activity, object] in query, +      where: fragment("(?)->'likes' \\? (?)", object.data, ^ap_id)      )    end diff --git a/lib/pleroma/web/activity_pub/utils.ex b/lib/pleroma/web/activity_pub/utils.ex index 39074888b..fc5305c58 100644 --- a/lib/pleroma/web/activity_pub/utils.ex +++ b/lib/pleroma/web/activity_pub/utils.ex @@ -251,20 +251,6 @@ defmodule Pleroma.Web.ActivityPub.Utils do    def insert_full_object(map), do: {:ok, map, nil} -  def update_object_in_activities(%{data: %{"id" => id}} = object) do -    # TODO -    # Update activities that already had this. Could be done in a seperate process. -    # Alternatively, just don't do this and fetch the current object each time. Most -    # could probably be taken from cache. -    relevant_activities = Activity.get_all_create_by_object_ap_id(id) - -    Enum.map(relevant_activities, fn activity -> -      new_activity_data = activity.data |> Map.put("object", object.data) -      changeset = Changeset.change(activity, data: new_activity_data) -      Repo.update(changeset) -    end) -  end -    #### Like-related helpers    @doc """ @@ -347,8 +333,7 @@ defmodule Pleroma.Web.ActivityPub.Utils do             |> Map.put("#{property}_count", length(element))             |> Map.put("#{property}s", element),           changeset <- Changeset.change(object, data: new_data), -         {:ok, object} <- Object.update_and_set_cache(changeset), -         _ <- update_object_in_activities(object) do +         {:ok, object} <- Object.update_and_set_cache(changeset) do        {:ok, object}      end    end diff --git a/lib/pleroma/web/ostatus/activity_representer.ex b/lib/pleroma/web/ostatus/activity_representer.ex index 760345301..8e55b9f0b 100644 --- a/lib/pleroma/web/ostatus/activity_representer.ex +++ b/lib/pleroma/web/ostatus/activity_representer.ex @@ -183,6 +183,7 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenter do      author = if with_author, do: [{:author, UserRepresenter.to_simple_form(user)}], else: []      retweeted_activity = Activity.get_create_by_object_ap_id(activity.data["object"]) +    retweeted_object = Object.normalize(retweeted_activity)      retweeted_user = User.get_cached_by_ap_id(retweeted_activity.data["actor"])      retweeted_xml = to_simple_form(retweeted_activity, retweeted_user, true) @@ -197,7 +198,7 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenter do        {:"activity:verb", ['http://activitystrea.ms/schema/1.0/share']},        {:id, h.(activity.data["id"])},        {:title, ['#{user.nickname} repeated a notice']}, -      {:content, [type: 'html'], ['RT #{retweeted_activity.data["object"]["content"]}']}, +      {:content, [type: 'html'], ['RT #{retweeted_object.data["content"]}']},        {:published, h.(inserted_at)},        {:updated, h.(updated_at)},        {:"ostatus:conversation", [ref: h.(activity.data["context"])], diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index 3d9a678dd..d723f331f 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -677,14 +677,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do        assert object.data["likes"] == [user.ap_id]        assert object.data["like_count"] == 1 -      [note_activity] = Activity.get_all_create_by_object_ap_id(object.data["id"]) -      assert note_activity.data["object"]["like_count"] == 1 -        {:ok, _like_activity, object} = ActivityPub.like(user_two, object)        assert object.data["like_count"] == 2 - -      [note_activity] = Activity.get_all_create_by_object_ap_id(object.data["id"]) -      assert note_activity.data["object"]["like_count"] == 2      end    end diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs index f8d389020..803a97695 100644 --- a/test/web/ostatus/ostatus_test.exs +++ b/test/web/ostatus/ostatus_test.exs @@ -199,7 +199,7 @@ defmodule Pleroma.Web.OStatusTest do      assert retweeted_activity.data["type"] == "Create"      assert retweeted_activity.data["actor"] == user.ap_id      assert retweeted_activity.local -    assert retweeted_activity.data["object"]["announcement_count"] == 1 +    assert Object.normalize(retweeted_activity).data["announcement_count"] == 1    end    test "handle incoming retweets - Mastodon, salmon" do  | 
