fix tests/schema

This commit is contained in:
FloatingGhost 2022-07-25 10:44:12 +01:00
parent 583c14fb0a
commit 29be90332f
9 changed files with 34 additions and 21 deletions

View File

@ -163,7 +163,6 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ArticleNotePageValidator do
end end
def changeset(struct, data) do def changeset(struct, data) do
IO.inspect(data)
data = fix(data) data = fix(data)
struct struct

View File

@ -31,7 +31,6 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
Modifies an incoming AP object (mastodon format) to our internal format. Modifies an incoming AP object (mastodon format) to our internal format.
""" """
def fix_object(object, options \\ []) do def fix_object(object, options \\ []) do
IO.inspect(object)
object object
|> strip_internal_fields() |> strip_internal_fields()
|> fix_actor() |> fix_actor()

View File

@ -500,8 +500,7 @@ defmodule Pleroma.Web.ApiSpec.StatusOperation do
quote_id: %Schema{ quote_id: %Schema{
nullable: true, nullable: true,
type: :string, type: :string,
description: description: "Will quote a given status."
"Will quote a given status."
} }
}, },
example: %{ example: %{

View File

@ -139,7 +139,9 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Status do
nullable: true nullable: true
}, },
quote: %Schema{ quote: %Schema{
allOf: [%OpenApiSpex.Reference{"$ref": "#/components/schemas/Status"}],
nullable: true,
description: "Quoted status (if any)"
}, },
pleroma: %Schema{ pleroma: %Schema{
type: :object, type: :object,
@ -216,18 +218,26 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Status do
type: :object, type: :object,
properties: %{ properties: %{
source: %Schema{ source: %Schema{
type: :object, nullable: true,
properties: %{ oneOf: [
content: %Schema{ %Schema{type: :string, example: 'plaintext content'},
type: :string, %Schema{
description: "The source content of the status" type: :object,
}, properties: %{
mediaType: %Schema{ content: %Schema{
type: :string, type: :string,
description: "The source MIME type of the status", description: "The source content of the status",
example: "text/plain" nullable: true
}, },
} mediaType: %Schema{
type: :string,
description: "The source MIME type of the status",
example: "text/plain",
nullable: true
}
}
}
]
} }
} }
}, },

View File

@ -39,7 +39,6 @@ defmodule Pleroma.Web.CommonAPI.ActivityDraft do
preview?: false, preview?: false,
changes: %{} changes: %{}
def new(user, params) do def new(user, params) do
%__MODULE__{user: user} %__MODULE__{user: user}
|> put_params(params) |> put_params(params)
@ -118,6 +117,7 @@ defmodule Pleroma.Web.CommonAPI.ActivityDraft do
quote = Activity.get_by_id(id) quote = Activity.get_by_id(id)
# only quote public/unlisted statuses # only quote public/unlisted statuses
visibility = CommonAPI.get_quoted_visibility(quote) visibility = CommonAPI.get_quoted_visibility(quote)
if visibility in ["public", "unlisted"] do if visibility in ["public", "unlisted"] do
%__MODULE__{draft | quote: Activity.get_by_id(id)} %__MODULE__{draft | quote: Activity.get_by_id(id)}
else else

View File

@ -112,7 +112,6 @@ defmodule Pleroma.Web.Federator do
e -> e ->
# Just drop those for now # Just drop those for now
Logger.debug(fn -> "Unhandled activity\n" <> Jason.encode!(params, pretty: true) end) Logger.debug(fn -> "Unhandled activity\n" <> Jason.encode!(params, pretty: true) end)
IO.inspect(e)
{:error, e} {:error, e}
end end
end end

View File

@ -365,7 +365,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
application: build_application(object.data["generator"]), application: build_application(object.data["generator"]),
language: nil, language: nil,
emojis: build_emojis(object.data["emoji"]), emojis: build_emojis(object.data["emoji"]),
quote_id: (if quote, do: quote.id, else: nil), quote_id: if(quote, do: quote.id, else: nil),
quote: maybe_render_quote(quote, opts), quote: maybe_render_quote(quote, opts),
pleroma: %{ pleroma: %{
local: activity.local, local: activity.local,
@ -619,6 +619,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
opts opts
|> Map.put(:activity, quote) |> Map.put(:activity, quote)
|> Map.put(:do_not_recurse, true) |> Map.put(:do_not_recurse, true)
render("show.json", opts) render("show.json", opts)
end end
end end

View File

@ -17,6 +17,8 @@
"ostatus": "http://ostatus.org#", "ostatus": "http://ostatus.org#",
"schema": "http://schema.org#", "schema": "http://schema.org#",
"toot": "http://joinmastodon.org/ns#", "toot": "http://joinmastodon.org/ns#",
"misskey": "https://misskey-hub.net/ns#",
"fedibird": "http://fedibird.com/ns#",
"value": "schema:value", "value": "schema:value",
"sensitive": "as:sensitive", "sensitive": "as:sensitive",
"litepub": "http://litepub.social/ns#", "litepub": "http://litepub.social/ns#",
@ -26,6 +28,8 @@
"@id": "litepub:listMessage", "@id": "litepub:listMessage",
"@type": "@id" "@type": "@id"
}, },
"quoteUrl": "as:quoteUrl",
"quoteUri": "fedibird:quoteUri",
"oauthRegistrationEndpoint": { "oauthRegistrationEndpoint": {
"@id": "litepub:oauthRegistrationEndpoint", "@id": "litepub:oauthRegistrationEndpoint",
"@type": "@id" "@type": "@id"

View File

@ -305,7 +305,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
}, },
akkoma: %{ akkoma: %{
source: HTML.filter_tags(object_data["content"]) source: HTML.filter_tags(object_data["content"])
} },
quote_id: nil,
quote: nil
} }
assert status == expected assert status == expected