Quote posting #113

Merged
floatingghost merged 9 commits from quote-posts into develop 2022-07-25 16:30:07 +00:00
9 changed files with 34 additions and 21 deletions
Showing only changes of commit 29be90332f - Show all commits

View file

@ -163,7 +163,6 @@ defp fix(data) 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 @@ defp create_request 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,20 +218,28 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Status do
type: :object, type: :object,
properties: %{ properties: %{
source: %Schema{ source: %Schema{
nullable: true,
oneOf: [
%Schema{type: :string, example: 'plaintext content'},
%Schema{
type: :object, type: :object,
properties: %{ properties: %{
content: %Schema{ content: %Schema{
type: :string, type: :string,
description: "The source content of the status" description: "The source content of the status",
nullable: true
}, },
mediaType: %Schema{ mediaType: %Schema{
type: :string, type: :string,
description: "The source MIME type of the status", description: "The source MIME type of the status",
example: "text/plain" example: "text/plain",
}, nullable: true
} }
} }
} }
]
}
}
}, },
poll: %Schema{allOf: [Poll], nullable: true, description: "The poll attached to the status"}, poll: %Schema{allOf: [Poll], nullable: true, description: "The poll attached to the status"},
reblog: %Schema{ reblog: %Schema{

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 @@ defp quote_id(%{params: %{quote_id: id}} = draft) when is_binary(id) 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 @@ def perform(:incoming_ap_doc, params) 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 @@ def render("show.json", %{activity: %{data: %{"object" => _object}} = activity}
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 @@ defp maybe_render_quote(quote, opts) 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 @@ test "a note activity" 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