X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Factivity%2Fqueries.ex;h=c99aae44bb27428eedc2e8bbf84a694b2e55cd10;hb=efb5d64e5089ab59d8304f49f7c92fcab6e00b86;hp=8d08d81ca071aee1a61e6ecd512a8beb21329b86;hpb=8b4d1a0b2917ac5146e6a37e062cda5ae968ea28;p=akkoma
diff --git a/lib/pleroma/activity/queries.ex b/lib/pleroma/activity/queries.ex
index 8d08d81ca..c99aae44b 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
@@ -24,10 +24,7 @@ defmodule Pleroma.Activity.Queries do
@spec by_actor(query, String.t()) :: query
def by_actor(query \\ Activity, actor) do
- from(
- activity in query,
- where: fragment("(?)->>'actor' = ?", activity.data, ^actor)
- )
+ from(a in query, where: a.actor == ^actor)
end
@spec by_author(query, User.t()) :: query
@@ -35,6 +32,13 @@ defmodule Pleroma.Activity.Queries 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)