mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-26 07:52:17 +00:00
Builder.note/1: return {:ok, map(), keyword()} like other Builder functions
This commit is contained in:
parent
a2eacfc525
commit
ba6049aa81
|
@ -126,7 +126,9 @@ defmodule Pleroma.Web.ActivityPub.Builder do
|
||||||
|> Pleroma.Maps.put_if_present("context", context), []}
|
|> Pleroma.Maps.put_if_present("context", context), []}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@spec note(ActivityDraft.t()) :: {:ok, map(), keyword()}
|
||||||
def note(%ActivityDraft{} = draft) do
|
def note(%ActivityDraft{} = draft) do
|
||||||
|
data =
|
||||||
%{
|
%{
|
||||||
"type" => "Note",
|
"type" => "Note",
|
||||||
"to" => draft.to,
|
"to" => draft.to,
|
||||||
|
@ -141,6 +143,8 @@ defmodule Pleroma.Web.ActivityPub.Builder do
|
||||||
}
|
}
|
||||||
|> add_in_reply_to(draft.in_reply_to)
|
|> add_in_reply_to(draft.in_reply_to)
|
||||||
|> Map.merge(draft.extra)
|
|> Map.merge(draft.extra)
|
||||||
|
|
||||||
|
{:ok, data, []}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp add_in_reply_to(object, nil), do: object
|
defp add_in_reply_to(object, nil), do: object
|
||||||
|
|
|
@ -214,8 +214,10 @@ defmodule Pleroma.Web.CommonAPI.ActivityDraft do
|
||||||
|
|
||||||
emoji = Map.merge(emoji, summary_emoji)
|
emoji = Map.merge(emoji, summary_emoji)
|
||||||
|
|
||||||
|
{:ok, note_data, _meta} = Builder.note(draft)
|
||||||
|
|
||||||
object =
|
object =
|
||||||
Builder.note(draft)
|
note_data
|
||||||
|> Map.put("emoji", emoji)
|
|> Map.put("emoji", emoji)
|
||||||
|> Map.put("source", draft.status)
|
|> Map.put("source", draft.status)
|
||||||
|> Map.put("generator", draft.params[:generator])
|
|> Map.put("generator", draft.params[:generator])
|
||||||
|
|
|
@ -28,7 +28,7 @@ defmodule Pleroma.Web.ActivityPub.BuilderTest do
|
||||||
extra: %{"custom_tag" => "test"}
|
extra: %{"custom_tag" => "test"}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert Builder.note(draft) == %{
|
expected = %{
|
||||||
"actor" => user.ap_id,
|
"actor" => user.ap_id,
|
||||||
"attachment" => [],
|
"attachment" => [],
|
||||||
"cc" => [user3.ap_id],
|
"cc" => [user3.ap_id],
|
||||||
|
@ -41,6 +41,8 @@ defmodule Pleroma.Web.ActivityPub.BuilderTest do
|
||||||
"type" => "Note",
|
"type" => "Note",
|
||||||
"custom_tag" => "test"
|
"custom_tag" => "test"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert {:ok, ^expected, []} = Builder.note(draft)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue