X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;ds=inline;f=lib%2Fpleroma%2Factivity.ex;h=b0f1a900d78cfa26390e5ad2972cfa169aa89851;hb=778010ef8e1f4509bd554e65556336e5e8457ef6;hp=07982331257d5c27ae22b324a6af9d9b07342812;hpb=31c89acd00396f95a35ea325ed848ffeb2826017;p=akkoma
diff --git a/lib/pleroma/activity.ex b/lib/pleroma/activity.ex
index 079823312..b0f1a900d 100644
--- a/lib/pleroma/activity.ex
+++ b/lib/pleroma/activity.ex
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors
+# Copyright © 2017-2021 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Activity do
@@ -24,6 +24,8 @@ defmodule Pleroma.Activity do
@primary_key {:id, FlakeId.Ecto.CompatType, autogenerate: true}
+ @cachex Pleroma.Config.get([:cachex, :provider], Cachex)
+
schema "activities" do
field(:data, :map)
field(:local, :boolean, default: true)
@@ -111,6 +113,7 @@ defmodule Pleroma.Activity do
from([a] in query,
left_join: b in Bookmark,
on: b.user_id == ^user.id and b.activity_id == a.id,
+ as: :bookmark,
preload: [bookmark: b]
)
end
@@ -121,6 +124,7 @@ defmodule Pleroma.Activity do
from([a] in query,
left_join: r in ReportNote,
on: a.id == r.activity_id,
+ as: :report_note,
preload: [report_notes: r]
)
end
@@ -272,7 +276,7 @@ defmodule Pleroma.Activity do
defp get_in_reply_to_activity_from_object(_), do: nil
def get_in_reply_to_activity(%Activity{} = activity) do
- get_in_reply_to_activity_from_object(Object.normalize(activity))
+ get_in_reply_to_activity_from_object(Object.normalize(activity, fetch: false))
end
def normalize(obj) when is_map(obj), do: get_by_ap_id_with_object(obj["id"])
@@ -298,7 +302,7 @@ defmodule Pleroma.Activity do
defp purge_web_resp_cache(%Activity{} = activity) do
%{path: path} = URI.parse(activity.data["id"])
- Cachex.del(:web_resp_cache, path)
+ @cachex.del(:web_resp_cache, path)
activity
end
@@ -341,6 +345,20 @@ defmodule Pleroma.Activity do
|> Repo.all()
end
+ def follow_requests_outstanding_since?(
+ %User{ap_id: follower_id},
+ %User{ap_id: followee_id},
+ since_datetime
+ ) do
+ followee_id
+ |> Queries.by_object_id()
+ |> Queries.by_type("Follow")
+ |> where([a], a.inserted_at > ^since_datetime)
+ |> where([a], fragment("? ->> 'state' != 'accept'", a.data))
+ |> where([a], a.actor == ^follower_id)
+ |> Repo.exists?()
+ end
+
def restrict_deactivated_users(query) do
deactivated_users =
from(u in User.Query.build(%{deactivated: true}), select: u.ap_id)