mastodon pins
This commit is contained in:
parent
3ec1dbd922
commit
17f28c0507
4 changed files with 146 additions and 4 deletions
|
|
@ -71,6 +71,14 @@ defmodule Pleroma.Object.Containment do
|
|||
compare_uris(id_uri, other_uri)
|
||||
end
|
||||
|
||||
# Mastodon pin activities don't have an id, so we check the object field, which will be pinned.
|
||||
def contain_origin_from_id(id, %{"object" => object}) when is_binary(object) do
|
||||
id_uri = URI.parse(id)
|
||||
object_uri = URI.parse(object)
|
||||
|
||||
compare_uris(id_uri, object_uri)
|
||||
end
|
||||
|
||||
def contain_origin_from_id(_id, _data), do: :error
|
||||
|
||||
def contain_child(%{"object" => %{"id" => id, "attributedTo" => _} = object}),
|
||||
|
|
|
|||
|
|
@ -557,10 +557,19 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
|||
end
|
||||
|
||||
def handle_incoming(%{"type" => type} = data, _options) when type in ~w(Add Remove) do
|
||||
with :ok <- ObjectValidator.fetch_actor_and_object(data),
|
||||
%Object{} <- Object.normalize(data["object"], fetch: true),
|
||||
{:ok, activity, _meta} <- Pipeline.common_pipeline(data, local: false) do
|
||||
{:ok, activity}
|
||||
with {:ok, user} <- ObjectValidator.fetch_actor(data),
|
||||
%Object{} <- Object.normalize(data["object"], fetch: true) do
|
||||
# Mastodon sends pin/unpin objects without id, to, cc fields
|
||||
data =
|
||||
data
|
||||
|> Map.put_new("id", Utils.generate_activity_id())
|
||||
|> Map.put_new("to", [Pleroma.Constants.as_public()])
|
||||
|> Map.put_new("cc", [user.follower_address])
|
||||
|
||||
case Pipeline.common_pipeline(data, local: false) do
|
||||
{:ok, activity, _meta} -> {:ok, activity}
|
||||
error -> error
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue