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
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 @@ defp create_request 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 @@ defp quote_id(%{params: %{quote_id: id}} = draft) when is_binary(id) 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 @@ def perform(:incoming_ap_doc, params) 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 @@ def render("show.json", %{activity: %{data: %{"object" => _object}} = activity}
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 @@ defp maybe_render_quote(quote, opts) 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 @@ test "a note activity" do
},
akkoma: %{
source: HTML.filter_tags(object_data["content"])
}
},
quote_id: nil,
quote: nil
}
assert status == expected