From: Mark Felder Date: Fri, 19 Feb 2021 21:16:55 +0000 (-0600) Subject: Add follow_requests_outstanding_since?/3 to Pleroma.Activity X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=1926d0804ba6ade106a509c027af6bf56e6a8791;p=akkoma Add follow_requests_outstanding_since?/3 to Pleroma.Activity --- diff --git a/lib/pleroma/activity.ex b/lib/pleroma/activity.ex index d59403884..b0f1a900d 100644 --- a/lib/pleroma/activity.ex +++ b/lib/pleroma/activity.ex @@ -345,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)