QuestionValidator: Create

This commit is contained in:
Haelwenn (lanodan) Monnier 2020-06-11 20:23:10 +02:00
commit 7bcd7a9595
No known key found for this signature in database
GPG key ID: D5B7A8E43C997DEE
10 changed files with 297 additions and 11 deletions

View file

@ -457,7 +457,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
%{"type" => "Create", "object" => %{"type" => objtype} = object} = data,
options
)
when objtype in ["Article", "Event", "Note", "Video", "Page", "Question", "Answer", "Audio"] do
when objtype in ["Article", "Event", "Note", "Video", "Page", "Answer", "Audio"] do
actor = Containment.get_actor(data)
with nil <- Activity.get_create_by_object_ap_id(object["id"]),
@ -613,6 +613,21 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|> handle_incoming(options)
end
def handle_incoming(
%{"type" => "Create", "object" => %{"type" => "Question"} = object} = data,
_options
) do
data =
data
|> Map.put("object", fix_object(object))
|> fix_addressing()
with {:ok, %User{}} <- ObjectValidator.fetch_actor(data),
{:ok, activity, _} <- Pipeline.common_pipeline(data, local: false) do
{:ok, activity}
end
end
def handle_incoming(
%{"type" => "Create", "object" => %{"type" => "ChatMessage"}} = data,
_options