X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;ds=inline;f=lib%2Fpleroma%2Factivity.ex;h=5a8329e69368de5c03e1ed4fc7ad22de7f7e6ad2;hb=41fdcb72828d52a23d57c41f910b02da5156e979;hp=0f8fce774e81b5904a24e19c0404cf85596e777d;hpb=4f004ab92e6d824140e1f87155c3f91a6eedcb09;p=akkoma
diff --git a/lib/pleroma/activity.ex b/lib/pleroma/activity.ex
index 0f8fce774..5a8329e69 100644
--- a/lib/pleroma/activity.ex
+++ b/lib/pleroma/activity.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 do
@@ -31,7 +31,7 @@ defmodule Pleroma.Activity do
"Announce" => "reblog",
"Like" => "favourite",
"Move" => "move",
- "EmojiReaction" => "pleroma:emoji_reaction"
+ "EmojiReact" => "pleroma:emoji_reaction"
}
@mastodon_to_ap_notification_types for {k, v} <- @mastodon_notification_types,
@@ -95,6 +95,17 @@ defmodule Pleroma.Activity do
|> preload([activity, object: object], object: object)
end
+ # Note: applies to fake activities (ActivityPub.Utils.get_notified_from_object/1 etc.)
+ def user_actor(%Activity{actor: nil}), do: nil
+
+ def user_actor(%Activity{} = activity) do
+ with %User{} <- activity.user_actor do
+ activity.user_actor
+ else
+ _ -> User.get_cached_by_ap_id(activity.actor)
+ end
+ end
+
def with_joined_user_actor(query, join_type \\ :inner) do
join(query, join_type, [activity], u in User,
on: u.ap_id == activity.actor,
@@ -308,9 +319,16 @@ 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()
Activity.Queries.exclude_authors(query, deactivated_users)