little fix
authorAlexander Strizhakov <alex.strizhakov@gmail.com>
Thu, 19 Nov 2020 12:29:26 +0000 (15:29 +0300)
committerAlexander Strizhakov <alex.strizhakov@gmail.com>
Thu, 19 Nov 2020 12:29:26 +0000 (15:29 +0300)
lib/pleroma/activity.ex
test/pleroma/activity_test.exs
test/pleroma/web/activity_pub/activity_pub_controller_test.exs

index bda5aa616cf09665c9822703835ec8f1172ede71..8559ae6a97a388dd5356b3d1869310156f2b65ee 100644 (file)
@@ -362,6 +362,7 @@ defmodule Pleroma.Activity do
     ap_id
     |> Queries.by_object_id()
     |> with_preloaded_object()
+    |> first()
     |> Repo.one()
   end
 
index ee6a99cc36b76b638ca6e87f855915d81efcfb09..3e9fe209e7736c2bca2f25501e14781f55c07735 100644 (file)
@@ -231,4 +231,20 @@ defmodule Pleroma.ActivityTest do
 
     assert [%Activity{id: ^id1}, %Activity{id: ^id2}] = activities
   end
+
+  test "get_by_object_ap_id_with_object/1" do
+    user = insert(:user)
+    another = insert(:user)
+
+    {:ok, %{id: id, object: %{data: %{"id" => obj_id}}}} =
+      Pleroma.Web.CommonAPI.post(user, %{status: "cofe"})
+
+    Pleroma.Web.CommonAPI.favorite(another, id)
+
+    assert obj_id
+           |> Pleroma.Activity.Queries.by_object_id()
+           |> Repo.aggregate(:count, :id) == 2
+
+    assert %{id: ^id} = Activity.get_by_object_ap_id_with_object(obj_id)
+  end
 end
index 6a1044991d781abb22972288b709e4b00b204ce8..b577e25ddb7702994dfbb997571fb1e5a5d9d4ca 100644 (file)
@@ -882,10 +882,12 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
       actor = insert(:user, local: false)
       remote_domain = URI.parse(actor.ap_id).host
       remote_actor = "https://#{remote_domain}/actor"
-      reported_user = insert(:user)
+      [reported_user, another] = insert_list(2, :user)
 
       note = insert(:note_activity, user: reported_user)
 
+      Pleroma.Web.CommonAPI.favorite(another, note.id)
+
       mock_json_body =
         "test/fixtures/mastodon/application_actor.json"
         |> File.read!()
@@ -920,8 +922,6 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
 
       ObanHelpers.perform(all_enqueued(worker: ReceiverWorker))
 
-      assert Pleroma.Repo.aggregate(Activity, :count, :id) == 2
-
       flag_activity = "Flag" |> Pleroma.Activity.Queries.by_type() |> Pleroma.Repo.one()
       reported_user_ap_id = reported_user.ap_id