X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Factivity%2Fqueries.ex;h=a34c20343471582e7c0dbb8e0bebd647d5cd83e0;hb=d20152700470c9b84a9404193ff08dd6d90b97a3;hp=c17affec98501b973f346b259793b57d8ce73d9c;hpb=61d9f43e463a3b3b0c1e4b9c98c22e222797bd82;p=akkoma
diff --git a/lib/pleroma/activity/queries.ex b/lib/pleroma/activity/queries.ex
index c17affec9..a34c20343 100644
--- a/lib/pleroma/activity/queries.ex
+++ b/lib/pleroma/activity/queries.ex
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors
+# Copyright © 2017-2020 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Activity.Queries do
@@ -30,11 +30,18 @@ defmodule Pleroma.Activity.Queries do
)
end
- @spec by_author(query, String.t()) :: query
+ @spec by_author(query, User.t()) :: query
def by_author(query \\ Activity, %User{ap_id: ap_id}) do
from(a in query, where: a.actor == ^ap_id)
end
+ def find_by_object_ap_id(activities, object_ap_id) do
+ Enum.find(
+ activities,
+ &(object_ap_id in [is_map(&1.data["object"]) && &1.data["object"]["id"], &1.data["object"]])
+ )
+ end
+
@spec by_object_id(query, String.t() | [String.t()]) :: query
def by_object_id(query \\ Activity, object_id)
@@ -63,7 +70,7 @@ defmodule Pleroma.Activity.Queries do
)
end
- @spec by_object_id(query, String.t()) :: query
+ @spec by_object_in_reply_to_id(query, String.t(), keyword()) :: query
def by_object_in_reply_to_id(query, in_reply_to_id, opts \\ []) do
query =
if opts[:skip_preloading] do