From f8ab1b7427e91ec1b7883e021836099226b56566 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Mon, 21 Jan 2019 06:46:47 +0100 Subject: [PATCH] =?UTF-8?q?Activity:=20get=5Fall=5Fby=5Fobject=5Fap=5Fid/1?= =?UTF-8?q?=20=E2=86=92=20get=5Fall=5Fcreate=5Fby=5Fobject=5Fap=5Fid/1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pleroma/activity.ex | 8 ++++---- lib/pleroma/web/activity_pub/utils.ex | 2 +- test/activity_test.exs | 2 +- test/web/activity_pub/activity_pub_test.exs | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/pleroma/activity.ex b/lib/pleroma/activity.ex index 588027de1..8c73d1fa0 100644 --- a/lib/pleroma/activity.ex +++ b/lib/pleroma/activity.ex @@ -63,10 +63,6 @@ def by_object_ap_id(ap_id) do ) end - def get_all_by_object_ap_id(ap_id) do - Repo.all(create_by_object_ap_id(ap_id)) - end - def create_activity_by_object_id_query(ap_ids) do from( activity in Activity, @@ -81,6 +77,10 @@ def create_activity_by_object_id_query(ap_ids) do ) end + def get_all_create_by_object_ap_id(ap_id) do + Repo.all(create_by_object_ap_id(ap_id)) + end + def get_create_activity_by_object_ap_id(ap_id) when is_binary(ap_id) do create_activity_by_object_id_query([ap_id]) |> Repo.one() diff --git a/lib/pleroma/web/activity_pub/utils.ex b/lib/pleroma/web/activity_pub/utils.ex index cfbe6c857..4f4a54052 100644 --- a/lib/pleroma/web/activity_pub/utils.ex +++ b/lib/pleroma/web/activity_pub/utils.ex @@ -198,7 +198,7 @@ def update_object_in_activities(%{data: %{"id" => id}} = object) do # 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_by_object_ap_id(id) + 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) diff --git a/test/activity_test.exs b/test/activity_test.exs index 8f3f613ec..dcac8649a 100644 --- a/test/activity_test.exs +++ b/test/activity_test.exs @@ -16,7 +16,7 @@ test "returns an activity by it's AP id" do test "returns activities by it's objects AP ids" do activity = insert(:note_activity) - [found_activity] = Activity.get_all_by_object_ap_id(activity.data["object"]["id"]) + [found_activity] = Activity.get_all_create_by_object_ap_id(activity.data["object"]["id"]) assert activity == found_activity end diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index 6538fb7af..ea9ac5ba8 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -330,7 +330,7 @@ test "adds a like activity to the db" do assert like_activity == same_like_activity assert object.data["likes"] == [user.ap_id] - [note_activity] = Activity.get_all_by_object_ap_id(object.data["id"]) + [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)