Prefer naming this put_application because we're putting it into the params map

This commit is contained in:
Mark Felder 2021-02-11 14:19:53 -06:00
parent 09b8378646
commit 7c508319a5
1 changed files with 4 additions and 4 deletions

View File

@ -140,7 +140,7 @@ def create(
when not is_nil(scheduled_at) do when not is_nil(scheduled_at) do
params = params =
Map.put(params, :in_reply_to_status_id, params[:in_reply_to_id]) Map.put(params, :in_reply_to_status_id, params[:in_reply_to_id])
|> add_application(conn) |> put_application(conn)
attrs = %{ attrs = %{
params: Map.new(params, fn {key, value} -> {to_string(key), value} end), params: Map.new(params, fn {key, value} -> {to_string(key), value} end),
@ -169,7 +169,7 @@ def create(
) do ) do
params = params =
Map.put(params, :in_reply_to_status_id, params[:in_reply_to_id]) Map.put(params, :in_reply_to_status_id, params[:in_reply_to_id])
|> add_application(conn) |> put_application(conn)
with {:ok, activity} <- CommonAPI.post(user, params) do with {:ok, activity} <- CommonAPI.post(user, params) do
try_render(conn, "show.json", try_render(conn, "show.json",
@ -422,9 +422,9 @@ def bookmarks(%{assigns: %{user: user}} = conn, params) do
) )
end end
defp add_application(params, %{assigns: %{token: %{app_id: app_id}}} = _conn) do defp put_application(params, %{assigns: %{token: %{app_id: app_id}}} = _conn) do
params |> Map.put(:application, Pleroma.Web.OAuth.App.get_app_by_id(app_id)) params |> Map.put(:application, Pleroma.Web.OAuth.App.get_app_by_id(app_id))
end end
defp add_application(params, _), do: Map.put(params, :application, %{name: "Web", website: nil}) defp put_application(params, _), do: Map.put(params, :application, %{name: "Web", website: nil})
end end