refetch user on incoming add/remove activity
if featured_address is nil
This commit is contained in:
parent
d1d2744ee3
commit
3adb43cc20
4 changed files with 90 additions and 2 deletions
|
|
@ -558,6 +558,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
|||
|
||||
def handle_incoming(%{"type" => type} = data, _options) when type in ~w(Add Remove) do
|
||||
with {:ok, %User{} = user} <- ObjectValidator.fetch_actor(data),
|
||||
# maybe locally user doesn't have featured_address
|
||||
{:ok, user} <- maybe_refetch_user(user),
|
||||
%Object{} <- Object.normalize(data["object"], fetch: true) do
|
||||
# Mastodon sends pin/unpin objects without id, to, cc fields
|
||||
data =
|
||||
|
|
@ -669,6 +671,12 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
|||
|
||||
def handle_incoming(_, _), do: :error
|
||||
|
||||
defp maybe_refetch_user(%User{featured_address: address} = user) when is_binary(address) do
|
||||
{:ok, user}
|
||||
end
|
||||
|
||||
defp maybe_refetch_user(%User{ap_id: ap_id}), do: upgrade_user_from_ap_id(ap_id)
|
||||
|
||||
@spec get_obj_helper(String.t(), Keyword.t()) :: {:ok, Object.t()} | nil
|
||||
def get_obj_helper(id, options \\ []) do
|
||||
options = Keyword.put(options, :fetch, true)
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
|
|||
|> Enum.filter(& &1)
|
||||
|> Enum.map(fn user -> AccountView.render("mention.json", %{user: user}) end)
|
||||
|
||||
{pinned?, pinned_at} = pin_data(activity_object, user)
|
||||
{pinned?, pinned_at} = pin_data(object, user)
|
||||
|
||||
%{
|
||||
id: to_string(activity.id),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue