# Creates a scheduled status when `scheduled_at` param is present and it's far enough
def create(
%{
- assigns: %{user: user, token: %{app_id: app_id}},
+ assigns: %{user: user},
body_params: %{status: _, scheduled_at: scheduled_at} = params
} = conn,
_
when not is_nil(scheduled_at) do
params =
Map.put(params, :in_reply_to_status_id, params[:in_reply_to_id])
- |> add_application(app_id)
+ |> add_application(conn)
attrs = %{
params: Map.new(params, fn {key, value} -> {to_string(key), value} end),
# Creates a regular status
def create(
- %{assigns: %{user: user, token: %{app_id: app_id}}, body_params: %{status: _} = params} =
- conn,
+ %{assigns: %{user: user}, body_params: %{status: _} = params} = conn,
_
) do
params =
Map.put(params, :in_reply_to_status_id, params[:in_reply_to_id])
- |> add_application(app_id)
+ |> add_application(conn)
with {:ok, activity} <- CommonAPI.post(user, params) do
try_render(conn, "show.json",
)
end
- defp add_application(params, app_id) do
+ defp add_application(params, %{assigns: %{token: %{app_id: app_id}}} = _conn) do
params |> Map.put(:application, Pleroma.Web.OAuth.App.get_app_by_id(app_id))
end
+
+ defp add_application(params, _), do: Map.put(params, :application, %{name: "Web", website: nil})
end