relay list shows hosts without accepted follow
[akkoma] / lib / pleroma / activity.ex
index 510d3273c1bb9c9244701498145de730530eef1e..6ca05f74e061ce4739b52fe592db979cc92408b5 100644 (file)
@@ -1,5 +1,5 @@
 # Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Activity do
@@ -30,7 +30,8 @@ defmodule Pleroma.Activity do
     "Follow" => "follow",
     "Announce" => "reblog",
     "Like" => "favourite",
-    "Move" => "move"
+    "Move" => "move",
+    "EmojiReact" => "pleroma:emoji_reaction"
   }
 
   @mastodon_to_ap_notification_types for {k, v} <- @mastodon_notification_types,
@@ -307,14 +308,19 @@ defmodule Pleroma.Activity do
     |> where([a], fragment("? ->> 'state' = 'pending'", a.data))
   end
 
+  def following_requests_for_actor(%Pleroma.User{ap_id: ap_id}) do
+    Queries.by_type("Follow")
+    |> where([a], fragment("?->>'state' = 'pending'", a.data))
+    |> where([a], a.actor == ^ap_id)
+    |> Repo.all()
+  end
+
   def restrict_deactivated_users(query) do
     deactivated_users =
-      from(u in User.Query.build(deactivated: true), select: u.ap_id)
+      from(u in User.Query.build(%{deactivated: true}), select: u.ap_id)
       |> Repo.all()
 
-    from(activity in query,
-      where: activity.actor not in ^deactivated_users
-    )
+    Activity.Queries.exclude_authors(query, deactivated_users)
   end
 
   defdelegate search(user, query, options \\ []), to: Pleroma.Activity.Search