projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'revert-a6d3bb5f' into 'develop'
[akkoma]
/
lib
/
pleroma
/
web
/
common_api
/
activity_draft.ex
diff --git
a/lib/pleroma/web/common_api/activity_draft.ex
b/lib/pleroma/web/common_api/activity_draft.ex
index 244cf2be5fdc313374a0e541c91f4cc37e03bbcd..f849b2e01fcea1419e8fb7a3b6f1529e84271170 100644
(file)
--- a/
lib/pleroma/web/common_api/activity_draft.ex
+++ b/
lib/pleroma/web/common_api/activity_draft.ex
@@
-58,16
+58,16
@@
defmodule Pleroma.Web.CommonAPI.ActivityDraft do
end
defp put_params(draft, params) do
end
defp put_params(draft, params) do
- params = Map.put_new(params,
"in_reply_to_status_id", params["in_reply_to_id"
])
+ params = Map.put_new(params,
:in_reply_to_status_id, params[:in_reply_to_id
])
%__MODULE__{draft | params: params}
end
%__MODULE__{draft | params: params}
end
- defp status(%{params: %{
"status" =>
status}} = draft) do
+ defp status(%{params: %{
status:
status}} = draft) do
%__MODULE__{draft | status: String.trim(status)}
end
defp summary(%{params: params} = draft) do
%__MODULE__{draft | status: String.trim(status)}
end
defp summary(%{params: params} = draft) do
- %__MODULE__{draft | summary: Map.get(params,
"spoiler_text"
, "")}
+ %__MODULE__{draft | summary: Map.get(params,
:spoiler_text
, "")}
end
defp full_payload(%{status: status, summary: summary} = draft) do
end
defp full_payload(%{status: status, summary: summary} = draft) do
@@
-84,20
+84,20
@@
defmodule Pleroma.Web.CommonAPI.ActivityDraft do
%__MODULE__{draft | attachments: attachments}
end
%__MODULE__{draft | attachments: attachments}
end
- defp in_reply_to(%{params: %{
"in_reply_to_status_id" =>
""}} = draft), do: draft
+ defp in_reply_to(%{params: %{
in_reply_to_status_id:
""}} = draft), do: draft
- defp in_reply_to(%{params: %{
"in_reply_to_status_id" =>
id}} = draft) when is_binary(id) do
+ defp in_reply_to(%{params: %{
in_reply_to_status_id:
id}} = draft) when is_binary(id) do
%__MODULE__{draft | in_reply_to: Activity.get_by_id(id)}
end
%__MODULE__{draft | in_reply_to: Activity.get_by_id(id)}
end
- defp in_reply_to(%{params: %{
"in_reply_to_status_id" =>
%Activity{} = in_reply_to}} = draft) do
+ defp in_reply_to(%{params: %{
in_reply_to_status_id:
%Activity{} = in_reply_to}} = draft) do
%__MODULE__{draft | in_reply_to: in_reply_to}
end
defp in_reply_to(draft), do: draft
defp in_reply_to_conversation(draft) do
%__MODULE__{draft | in_reply_to: in_reply_to}
end
defp in_reply_to(draft), do: draft
defp in_reply_to_conversation(draft) do
- in_reply_to_conversation = Participation.get(draft.params[
"in_reply_to_conversation_id"
])
+ in_reply_to_conversation = Participation.get(draft.params[
:in_reply_to_conversation_id
])
%__MODULE__{draft | in_reply_to_conversation: in_reply_to_conversation}
end
%__MODULE__{draft | in_reply_to_conversation: in_reply_to_conversation}
end
@@
-112,7
+112,7
@@
defmodule Pleroma.Web.CommonAPI.ActivityDraft do
end
defp expires_at(draft) do
end
defp expires_at(draft) do
- case CommonAPI.check_expiry_date(draft.params[
"expires_in"
]) do
+ case CommonAPI.check_expiry_date(draft.params[
:expires_in
]) do
{:ok, expires_at} -> %__MODULE__{draft | expires_at: expires_at}
{:error, message} -> add_error(draft, message)
end
{:ok, expires_at} -> %__MODULE__{draft | expires_at: expires_at}
{:error, message} -> add_error(draft, message)
end
@@
-144,7
+144,7
@@
defmodule Pleroma.Web.CommonAPI.ActivityDraft do
addressed_users =
draft.mentions
|> Enum.map(fn {_, mentioned_user} -> mentioned_user.ap_id end)
addressed_users =
draft.mentions
|> Enum.map(fn {_, mentioned_user} -> mentioned_user.ap_id end)
- |> Utils.get_addressed_users(draft.params[
"to"
])
+ |> Utils.get_addressed_users(draft.params[
:to
])
{to, cc} =
Utils.get_to_and_cc(
{to, cc} =
Utils.get_to_and_cc(
@@
-164,7
+164,7
@@
defmodule Pleroma.Web.CommonAPI.ActivityDraft do
end
defp sensitive(draft) do
end
defp sensitive(draft) do
- sensitive = draft.params[
"sensitive"
] || Enum.member?(draft.tags, {"#nsfw", "nsfw"})
+ sensitive = draft.params[
:sensitive
] || Enum.member?(draft.tags, {"#nsfw", "nsfw"})
%__MODULE__{draft | sensitive: sensitive}
end
%__MODULE__{draft | sensitive: sensitive}
end
@@
-186,17
+186,25
@@
defmodule Pleroma.Web.CommonAPI.ActivityDraft do
draft.poll
)
|> Map.put("emoji", emoji)
draft.poll
)
|> Map.put("emoji", emoji)
+ |> Map.put("source", draft.status)
%__MODULE__{draft | object: object}
end
defp preview?(draft) do
%__MODULE__{draft | object: object}
end
defp preview?(draft) do
- preview? = Pleroma.Web.ControllerHelper.truthy_param?(draft.params[
"preview"
])
+ preview? = Pleroma.Web.ControllerHelper.truthy_param?(draft.params[
:preview
])
%__MODULE__{draft | preview?: preview?}
end
defp changes(draft) do
direct? = draft.visibility == "direct"
%__MODULE__{draft | preview?: preview?}
end
defp changes(draft) do
direct? = draft.visibility == "direct"
+ additional = %{"cc" => draft.cc, "directMessage" => direct?}
+
+ additional =
+ case draft.expires_at do
+ %NaiveDateTime{} = expires_at -> Map.put(additional, "expires_at", expires_at)
+ _ -> additional
+ end
changes =
%{
changes =
%{
@@
-204,7
+212,7
@@
defmodule Pleroma.Web.CommonAPI.ActivityDraft do
actor: draft.user,
context: draft.context,
object: draft.object,
actor: draft.user,
context: draft.context,
object: draft.object,
- additional:
%{"cc" => draft.cc, "directMessage" => direct?}
+ additional:
additional
}
|> Utils.maybe_add_list_data(draft.user, draft.visibility)
}
|> Utils.maybe_add_list_data(draft.user, draft.visibility)