Remove remaining conn usages from log_details

This commit is contained in:
Luna D 2024-06-23 10:38:56 -04:00 committed by Liam
parent cc21b402a0
commit bb7aa0a124
2 changed files with 7 additions and 6 deletions

View file

@ -51,7 +51,8 @@ defmodule PhilomenaWeb.Admin.Batch.TagController do
details: &log_details/3, details: &log_details/3,
data: %{ data: %{
tag_list: tag_list, tag_list: tag_list,
image_count: Enum.count(image_ids) image_count: Enum.count(image_ids),
user: conn.assigns.current_user
} }
) )
|> json(%{succeeded: image_ids, failed: []}) |> json(%{succeeded: image_ids, failed: []})
@ -68,10 +69,10 @@ defmodule PhilomenaWeb.Admin.Batch.TagController do
end end
end end
defp log_details(conn, _action, data) do defp log_details(_conn, _action, data) do
%{ %{
body: "Batch tagged '#{data.tag_list}' on #{data.image_count} images", body: "Batch tagged '#{data.tag_list}' on #{data.image_count} images",
subject_path: ~p"/profiles/#{conn.assigns.current_user}" subject_path: ~p"/profiles/#{data.user}"
} }
end end
end end

View file

@ -26,12 +26,12 @@ defmodule PhilomenaWeb.Image.TamperController do
|> put_flash(:info, "Vote removed.") |> put_flash(:info, "Vote removed.")
|> moderation_log( |> moderation_log(
details: &log_details/3, details: &log_details/3,
data: %{vote: result, image: image} data: %{vote: result, image: image, username: conn.assigns.user.name}
) )
|> redirect(to: ~p"/images/#{conn.assigns.image}") |> redirect(to: ~p"/images/#{conn.assigns.image}")
end end
defp log_details(conn, _action, data) do defp log_details(_conn, _action, data) do
image = data.image image = data.image
vote_type = vote_type =
@ -42,7 +42,7 @@ defmodule PhilomenaWeb.Image.TamperController do
end end
%{ %{
body: "Deleted #{vote_type} by #{conn.assigns.user.name} on image >>#{data.image.id}", body: "Deleted #{vote_type} by #{data.username} on image >>#{data.image.id}",
subject_path: ~p"/images/#{image}" subject_path: ~p"/images/#{image}"
} }
end end