ActivityDraft: allow quoting
This commit is contained in:
parent
6ac19c3999
commit
d4fea8b559
3 changed files with 29 additions and 1 deletions
|
@ -217,6 +217,7 @@ defmodule Pleroma.Web.ActivityPub.Builder do
|
||||||
"tag" => Keyword.values(draft.tags) |> Enum.uniq()
|
"tag" => Keyword.values(draft.tags) |> Enum.uniq()
|
||||||
}
|
}
|
||||||
|> add_in_reply_to(draft.in_reply_to)
|
|> add_in_reply_to(draft.in_reply_to)
|
||||||
|
|> add_quote(draft.quote_post)
|
||||||
|> Map.merge(draft.extra)
|
|> Map.merge(draft.extra)
|
||||||
|
|
||||||
{:ok, data, []}
|
{:ok, data, []}
|
||||||
|
@ -232,6 +233,16 @@ defmodule Pleroma.Web.ActivityPub.Builder do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp add_quote(object, nil), do: object
|
||||||
|
|
||||||
|
defp add_quote(object, quote_post) do
|
||||||
|
with %Object{} = quote_object <- Object.normalize(quote_post, fetch: false) do
|
||||||
|
Map.put(object, "quoteUrl", quote_object.data["id"])
|
||||||
|
else
|
||||||
|
_ -> object
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def chat_message(actor, recipient, content, opts \\ []) do
|
def chat_message(actor, recipient, content, opts \\ []) do
|
||||||
basic = %{
|
basic = %{
|
||||||
"id" => Utils.generate_object_id(),
|
"id" => Utils.generate_object_id(),
|
||||||
|
|
|
@ -581,7 +581,12 @@ defmodule Pleroma.Web.ApiSpec.StatusOperation do
|
||||||
type: :string,
|
type: :string,
|
||||||
description:
|
description:
|
||||||
"Will reply to a given conversation, addressing only the people who are part of the recipient set of that conversation. Sets the visibility to `direct`."
|
"Will reply to a given conversation, addressing only the people who are part of the recipient set of that conversation. Sets the visibility to `direct`."
|
||||||
}
|
},
|
||||||
|
quote_id: %Schema{
|
||||||
|
nullable: true,
|
||||||
|
allOf: [FlakeID],
|
||||||
|
description: "ID of the status being quoted, if any"
|
||||||
|
},
|
||||||
},
|
},
|
||||||
example: %{
|
example: %{
|
||||||
"status" => "What time is it?",
|
"status" => "What time is it?",
|
||||||
|
|
|
@ -796,6 +796,18 @@ defmodule Pleroma.Web.CommonAPITest do
|
||||||
scheduled_at: expires_at
|
scheduled_at: expires_at
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "it allows allows quote posting" do
|
||||||
|
user = insert(:user)
|
||||||
|
|
||||||
|
{:ok, quoted} = CommonAPI.post(user, %{status: "Hello world"})
|
||||||
|
{:ok, quote_post} = CommonAPI.post(user, %{status: "nice post", quote_id: quoted.id})
|
||||||
|
|
||||||
|
quoted = Object.normalize(quoted)
|
||||||
|
quote_post = Object.normalize(quote_post)
|
||||||
|
|
||||||
|
assert quote_post.data["quoteUrl"] == quoted.data["id"]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "reactions" do
|
describe "reactions" do
|
||||||
|
|
Loading…
Reference in a new issue