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
def changeset(struct, data) do
IO.inspect(data)
data = fix(data)
struct

View File

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

View File

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

View File

@ -139,7 +139,9 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Status do
nullable: true
},
quote: %Schema{
allOf: [%OpenApiSpex.Reference{"$ref": "#/components/schemas/Status"}],
nullable: true,
description: "Quoted status (if any)"
},
pleroma: %Schema{
type: :object,
@ -216,18 +218,26 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Status do
type: :object,
properties: %{
source: %Schema{
type: :object,
properties: %{
content: %Schema{
type: :string,
description: "The source content of the status"
},
mediaType: %Schema{
type: :string,
description: "The source MIME type of the status",
example: "text/plain"
},
}
nullable: true,
oneOf: [
%Schema{type: :string, example: 'plaintext content'},
%Schema{
type: :object,
properties: %{
content: %Schema{
type: :string,
description: "The source content of the status",
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,
changes: %{}
def new(user, params) do
%__MODULE__{user: user}
|> put_params(params)
@ -118,6 +117,7 @@ defmodule Pleroma.Web.CommonAPI.ActivityDraft do
quote = Activity.get_by_id(id)
# only quote public/unlisted statuses
visibility = CommonAPI.get_quoted_visibility(quote)
if visibility in ["public", "unlisted"] do
%__MODULE__{draft | quote: Activity.get_by_id(id)}
else

View File

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

View File

@ -365,7 +365,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
application: build_application(object.data["generator"]),
language: nil,
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),
pleroma: %{
local: activity.local,
@ -619,6 +619,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
opts
|> Map.put(:activity, quote)
|> Map.put(:do_not_recurse, true)
render("show.json", opts)
end
end

View File

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

View File

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