The user is not always preloaded into the notification

This commit is contained in:
Mark Felder 2024-06-11 18:14:07 -04:00
parent 568819c08a
commit 603a575766

View File

@ -27,7 +27,7 @@ defmodule Pleroma.Web.Push.Impl do
def build( def build(
%{ %{
activity: %{data: %{"type" => activity_type}} = activity, activity: %{data: %{"type" => activity_type}} = activity,
user: user user_id: user_id
} = notification } = notification
) )
when activity_type in @types do when activity_type in @types do
@ -35,9 +35,10 @@ defmodule Pleroma.Web.Push.Impl do
avatar_url = User.avatar_url(notification_actor) avatar_url = User.avatar_url(notification_actor)
object = Object.normalize(activity, fetch: false) object = Object.normalize(activity, fetch: false)
user = User.get_cached_by_id(user_id)
direct_conversation_id = Activity.direct_conversation_id(activity, user) direct_conversation_id = Activity.direct_conversation_id(activity, user)
subscriptions = fetch_subscriptions(user.id) subscriptions = fetch_subscriptions(user_id)
subscriptions subscriptions
|> Enum.filter(&Subscription.enabled?(&1, notification.type)) |> Enum.filter(&Subscription.enabled?(&1, notification.type))