From bb7aa0a12427dfebb10f636dfa4110fcbda5d1b1 Mon Sep 17 00:00:00 2001 From: Luna D Date: Sun, 23 Jun 2024 10:38:56 -0400 Subject: [PATCH 1/8] Remove remaining conn usages from log_details --- .../controllers/admin/batch/tag_controller.ex | 7 ++++--- lib/philomena_web/controllers/image/tamper_controller.ex | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/philomena_web/controllers/admin/batch/tag_controller.ex b/lib/philomena_web/controllers/admin/batch/tag_controller.ex index 302981be..1eaae044 100644 --- a/lib/philomena_web/controllers/admin/batch/tag_controller.ex +++ b/lib/philomena_web/controllers/admin/batch/tag_controller.ex @@ -51,7 +51,8 @@ defmodule PhilomenaWeb.Admin.Batch.TagController do details: &log_details/3, data: %{ 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: []}) @@ -68,10 +69,10 @@ defmodule PhilomenaWeb.Admin.Batch.TagController do 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", - subject_path: ~p"/profiles/#{conn.assigns.current_user}" + subject_path: ~p"/profiles/#{data.user}" } end end diff --git a/lib/philomena_web/controllers/image/tamper_controller.ex b/lib/philomena_web/controllers/image/tamper_controller.ex index 4ce1ac3c..2cc03745 100644 --- a/lib/philomena_web/controllers/image/tamper_controller.ex +++ b/lib/philomena_web/controllers/image/tamper_controller.ex @@ -26,12 +26,12 @@ defmodule PhilomenaWeb.Image.TamperController do |> put_flash(:info, "Vote removed.") |> moderation_log( 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}") end - defp log_details(conn, _action, data) do + defp log_details(_conn, _action, data) do image = data.image vote_type = @@ -42,7 +42,7 @@ defmodule PhilomenaWeb.Image.TamperController do 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}" } end From dfeefb1651b45e06b0b428903f03cb782d350169 Mon Sep 17 00:00:00 2001 From: Luna D Date: Sun, 23 Jun 2024 10:42:29 -0400 Subject: [PATCH 2/8] Commands: git grep -l 'defp log_details(_conn' | xargs sed -i -e 's/defp log_details(_conn, /defp log_details(/g' git grep -l '&log_details/3' | xargs sed -i -e 's|\&log_details/3|\&log_details/2|g' --- .../controllers/admin/artist_link/contact_controller.ex | 4 ++-- .../controllers/admin/artist_link/reject_controller.ex | 4 ++-- .../admin/artist_link/verification_controller.ex | 4 ++-- .../controllers/admin/batch/tag_controller.ex | 4 ++-- .../controllers/admin/fingerprint_ban_controller.ex | 8 ++++---- .../controllers/admin/subnet_ban_controller.ex | 8 ++++---- .../controllers/admin/user/verification_controller.ex | 6 +++--- .../controllers/admin/user_ban_controller.ex | 8 ++++---- lib/philomena_web/controllers/admin/user_controller.ex | 4 ++-- .../conversation/message/approve_controller.ex | 4 ++-- .../controllers/duplicate_report/accept_controller.ex | 4 ++-- .../duplicate_report/accept_reverse_controller.ex | 4 ++-- .../controllers/duplicate_report/claim_controller.ex | 6 +++--- .../controllers/duplicate_report/reject_controller.ex | 4 ++-- .../controllers/image/anonymous_controller.ex | 4 ++-- lib/philomena_web/controllers/image/approve_controller.ex | 4 ++-- .../controllers/image/comment/approve_controller.ex | 4 ++-- .../controllers/image/comment/delete_controller.ex | 4 ++-- .../controllers/image/comment/hide_controller.ex | 6 +++--- .../controllers/image/comment_lock_controller.ex | 6 +++--- lib/philomena_web/controllers/image/delete_controller.ex | 8 ++++---- .../controllers/image/description_lock_controller.ex | 6 +++--- lib/philomena_web/controllers/image/destroy_controller.ex | 4 ++-- lib/philomena_web/controllers/image/feature_controller.ex | 4 ++-- lib/philomena_web/controllers/image/hash_controller.ex | 4 ++-- lib/philomena_web/controllers/image/repair_controller.ex | 4 ++-- .../controllers/image/scratchpad_controller.ex | 4 ++-- .../controllers/image/source_history_controller.ex | 4 ++-- .../controllers/image/tag_change_controller.ex | 4 ++-- .../controllers/image/tag_lock_controller.ex | 8 ++++---- lib/philomena_web/controllers/image/tamper_controller.ex | 4 ++-- lib/philomena_web/controllers/tag/image_controller.ex | 6 +++--- lib/philomena_web/controllers/tag_controller.ex | 6 +++--- lib/philomena_web/controllers/topic/hide_controller.ex | 6 +++--- lib/philomena_web/controllers/topic/lock_controller.ex | 6 +++--- lib/philomena_web/controllers/topic/move_controller.ex | 4 ++-- .../controllers/topic/post/approve_controller.ex | 4 ++-- .../controllers/topic/post/delete_controller.ex | 4 ++-- .../controllers/topic/post/hide_controller.ex | 6 +++--- lib/philomena_web/controllers/topic/stick_controller.ex | 6 +++--- 40 files changed, 101 insertions(+), 101 deletions(-) diff --git a/lib/philomena_web/controllers/admin/artist_link/contact_controller.ex b/lib/philomena_web/controllers/admin/artist_link/contact_controller.ex index 2f270db8..df25d5be 100644 --- a/lib/philomena_web/controllers/admin/artist_link/contact_controller.ex +++ b/lib/philomena_web/controllers/admin/artist_link/contact_controller.ex @@ -18,11 +18,11 @@ defmodule PhilomenaWeb.Admin.ArtistLink.ContactController do conn |> put_flash(:info, "Artist successfully marked as contacted.") - |> moderation_log(details: &log_details/3, data: artist_link) + |> moderation_log(details: &log_details/2, data: artist_link) |> redirect(to: ~p"/admin/artist_links") end - defp log_details(_conn, _action, artist_link) do + defp log_details(_action, artist_link) do %{ body: "Contacted artist #{artist_link.user.name} at #{artist_link.uri}", subject_path: ~p"/profiles/#{artist_link.user}/artist_links/#{artist_link}" diff --git a/lib/philomena_web/controllers/admin/artist_link/reject_controller.ex b/lib/philomena_web/controllers/admin/artist_link/reject_controller.ex index b238efcf..b9aab712 100644 --- a/lib/philomena_web/controllers/admin/artist_link/reject_controller.ex +++ b/lib/philomena_web/controllers/admin/artist_link/reject_controller.ex @@ -17,11 +17,11 @@ defmodule PhilomenaWeb.Admin.ArtistLink.RejectController do conn |> put_flash(:info, "Artist link successfully marked as rejected.") - |> moderation_log(details: &log_details/3, data: artist_link) + |> moderation_log(details: &log_details/2, data: artist_link) |> redirect(to: ~p"/admin/artist_links") end - defp log_details(_conn, _action, artist_link) do + defp log_details(_action, artist_link) do %{ body: "Rejected artist link #{artist_link.uri} created by #{artist_link.user.name}", subject_path: ~p"/profiles/#{artist_link.user}/artist_links/#{artist_link}" diff --git a/lib/philomena_web/controllers/admin/artist_link/verification_controller.ex b/lib/philomena_web/controllers/admin/artist_link/verification_controller.ex index 836b59d7..a1a2f86a 100644 --- a/lib/philomena_web/controllers/admin/artist_link/verification_controller.ex +++ b/lib/philomena_web/controllers/admin/artist_link/verification_controller.ex @@ -18,11 +18,11 @@ defmodule PhilomenaWeb.Admin.ArtistLink.VerificationController do conn |> put_flash(:info, "Artist link successfully verified.") - |> moderation_log(details: &log_details/3, data: result.artist_link) + |> moderation_log(details: &log_details/2, data: result.artist_link) |> redirect(to: ~p"/admin/artist_links") end - defp log_details(_conn, _action, artist_link) do + defp log_details(_action, artist_link) do %{ body: "Verified artist link #{artist_link.uri} created by #{artist_link.user.name}", subject_path: ~p"/profiles/#{artist_link.user}/artist_links/#{artist_link}" diff --git a/lib/philomena_web/controllers/admin/batch/tag_controller.ex b/lib/philomena_web/controllers/admin/batch/tag_controller.ex index 1eaae044..44e6485b 100644 --- a/lib/philomena_web/controllers/admin/batch/tag_controller.ex +++ b/lib/philomena_web/controllers/admin/batch/tag_controller.ex @@ -48,7 +48,7 @@ defmodule PhilomenaWeb.Admin.Batch.TagController do {:ok, _} -> conn |> moderation_log( - details: &log_details/3, + details: &log_details/2, data: %{ tag_list: tag_list, image_count: Enum.count(image_ids), @@ -69,7 +69,7 @@ defmodule PhilomenaWeb.Admin.Batch.TagController do end end - defp log_details(_conn, _action, data) do + defp log_details(_action, data) do %{ body: "Batch tagged '#{data.tag_list}' on #{data.image_count} images", subject_path: ~p"/profiles/#{data.user}" diff --git a/lib/philomena_web/controllers/admin/fingerprint_ban_controller.ex b/lib/philomena_web/controllers/admin/fingerprint_ban_controller.ex index 4e520c33..d3c17c12 100644 --- a/lib/philomena_web/controllers/admin/fingerprint_ban_controller.ex +++ b/lib/philomena_web/controllers/admin/fingerprint_ban_controller.ex @@ -52,7 +52,7 @@ defmodule PhilomenaWeb.Admin.FingerprintBanController do {:ok, fingerprint_ban} -> conn |> put_flash(:info, "Fingerprint was successfully banned.") - |> moderation_log(details: &log_details/3, data: fingerprint_ban) + |> moderation_log(details: &log_details/2, data: fingerprint_ban) |> redirect(to: ~p"/admin/fingerprint_bans") {:error, changeset} -> @@ -70,7 +70,7 @@ defmodule PhilomenaWeb.Admin.FingerprintBanController do {:ok, fingerprint_ban} -> conn |> put_flash(:info, "Fingerprint ban successfully updated.") - |> moderation_log(details: &log_details/3, data: fingerprint_ban) + |> moderation_log(details: &log_details/2, data: fingerprint_ban) |> redirect(to: ~p"/admin/fingerprint_bans") {:error, changeset} -> @@ -83,7 +83,7 @@ defmodule PhilomenaWeb.Admin.FingerprintBanController do conn |> put_flash(:info, "Fingerprint ban successfully deleted.") - |> moderation_log(details: &log_details/3, data: fingerprint_ban) + |> moderation_log(details: &log_details/2, data: fingerprint_ban) |> redirect(to: ~p"/admin/fingerprint_bans") end @@ -115,7 +115,7 @@ defmodule PhilomenaWeb.Admin.FingerprintBanController do end end - defp log_details(_conn, action, ban) do + defp log_details(action, ban) do body = case action do :create -> "Created a fingerprint ban #{ban.generated_ban_id}" diff --git a/lib/philomena_web/controllers/admin/subnet_ban_controller.ex b/lib/philomena_web/controllers/admin/subnet_ban_controller.ex index 31f83b07..f4163921 100644 --- a/lib/philomena_web/controllers/admin/subnet_ban_controller.ex +++ b/lib/philomena_web/controllers/admin/subnet_ban_controller.ex @@ -49,7 +49,7 @@ defmodule PhilomenaWeb.Admin.SubnetBanController do {:ok, subnet_ban} -> conn |> put_flash(:info, "Subnet was successfully banned.") - |> moderation_log(details: &log_details/3, data: subnet_ban) + |> moderation_log(details: &log_details/2, data: subnet_ban) |> redirect(to: ~p"/admin/subnet_bans") {:error, changeset} -> @@ -67,7 +67,7 @@ defmodule PhilomenaWeb.Admin.SubnetBanController do {:ok, subnet_ban} -> conn |> put_flash(:info, "Subnet ban successfully updated.") - |> moderation_log(details: &log_details/3, data: subnet_ban) + |> moderation_log(details: &log_details/2, data: subnet_ban) |> redirect(to: ~p"/admin/subnet_bans") {:error, changeset} -> @@ -80,7 +80,7 @@ defmodule PhilomenaWeb.Admin.SubnetBanController do conn |> put_flash(:info, "Subnet ban successfully deleted.") - |> moderation_log(details: &log_details/3, data: subnet_ban) + |> moderation_log(details: &log_details/2, data: subnet_ban) |> redirect(to: ~p"/admin/subnet_bans") end @@ -112,7 +112,7 @@ defmodule PhilomenaWeb.Admin.SubnetBanController do end end - defp log_details(_conn, action, ban) do + defp log_details(action, ban) do body = case action do :create -> "Created a subnet ban #{ban.generated_ban_id}" diff --git a/lib/philomena_web/controllers/admin/user/verification_controller.ex b/lib/philomena_web/controllers/admin/user/verification_controller.ex index 5f8864ee..82b0745a 100644 --- a/lib/philomena_web/controllers/admin/user/verification_controller.ex +++ b/lib/philomena_web/controllers/admin/user/verification_controller.ex @@ -12,7 +12,7 @@ defmodule PhilomenaWeb.Admin.User.VerificationController do conn |> put_flash(:info, "User verification granted.") - |> moderation_log(details: &log_details/3, data: user) + |> moderation_log(details: &log_details/2, data: user) |> redirect(to: ~p"/profiles/#{user}") end @@ -21,7 +21,7 @@ defmodule PhilomenaWeb.Admin.User.VerificationController do conn |> put_flash(:info, "User verification revoked.") - |> moderation_log(details: &log_details/3, data: user) + |> moderation_log(details: &log_details/2, data: user) |> redirect(to: ~p"/profiles/#{user}") end @@ -32,7 +32,7 @@ defmodule PhilomenaWeb.Admin.User.VerificationController do end end - defp log_details(_conn, action, user) do + defp log_details(action, user) do body = case action do :create -> "Granted verification to #{user.name}" diff --git a/lib/philomena_web/controllers/admin/user_ban_controller.ex b/lib/philomena_web/controllers/admin/user_ban_controller.ex index 7def2541..24847076 100644 --- a/lib/philomena_web/controllers/admin/user_ban_controller.ex +++ b/lib/philomena_web/controllers/admin/user_ban_controller.ex @@ -50,7 +50,7 @@ defmodule PhilomenaWeb.Admin.UserBanController do {:ok, user_ban} -> conn |> put_flash(:info, "User was successfully banned.") - |> moderation_log(details: &log_details/3, data: user_ban) + |> moderation_log(details: &log_details/2, data: user_ban) |> redirect(to: ~p"/admin/user_bans") {:error, :user_ban, changeset, _changes} -> @@ -71,7 +71,7 @@ defmodule PhilomenaWeb.Admin.UserBanController do {:ok, user_ban} -> conn |> put_flash(:info, "User ban successfully updated.") - |> moderation_log(details: &log_details/3, data: user_ban) + |> moderation_log(details: &log_details/2, data: user_ban) |> redirect(to: ~p"/admin/user_bans") {:error, changeset} -> @@ -84,7 +84,7 @@ defmodule PhilomenaWeb.Admin.UserBanController do conn |> put_flash(:info, "User ban successfully deleted.") - |> moderation_log(details: &log_details/3, data: user_ban) + |> moderation_log(details: &log_details/2, data: user_ban) |> redirect(to: ~p"/admin/user_bans") end @@ -116,7 +116,7 @@ defmodule PhilomenaWeb.Admin.UserBanController do end end - defp log_details(_conn, action, ban) do + defp log_details(action, ban) do body = case action do :create -> "Created a user ban #{ban.generated_ban_id}" diff --git a/lib/philomena_web/controllers/admin/user_controller.ex b/lib/philomena_web/controllers/admin/user_controller.ex index 5f236108..266291de 100644 --- a/lib/philomena_web/controllers/admin/user_controller.ex +++ b/lib/philomena_web/controllers/admin/user_controller.ex @@ -62,7 +62,7 @@ defmodule PhilomenaWeb.Admin.UserController do {:ok, user} -> conn |> put_flash(:info, "User successfully updated.") - |> moderation_log(details: &log_details/3, data: user) + |> moderation_log(details: &log_details/2, data: user) |> redirect(to: ~p"/profiles/#{user}") {:error, changeset} -> @@ -81,7 +81,7 @@ defmodule PhilomenaWeb.Admin.UserController do assign(conn, :roles, Repo.all(Role)) end - defp log_details(_conn, _action, user) do + defp log_details(_action, user) do %{ body: "Updated user details for #{user.name}", subject_path: ~p"/profiles/#{user}" diff --git a/lib/philomena_web/controllers/conversation/message/approve_controller.ex b/lib/philomena_web/controllers/conversation/message/approve_controller.ex index 3ecade26..1693f432 100644 --- a/lib/philomena_web/controllers/conversation/message/approve_controller.ex +++ b/lib/philomena_web/controllers/conversation/message/approve_controller.ex @@ -20,11 +20,11 @@ defmodule PhilomenaWeb.Conversation.Message.ApproveController do conn |> put_flash(:info, "Conversation message approved.") - |> moderation_log(details: &log_details/3, data: message) + |> moderation_log(details: &log_details/2, data: message) |> redirect(to: "/") end - defp log_details(_conn, _action, message) do + defp log_details(_action, message) do %{ body: "Approved private message in conversation ##{message.conversation_id}", subject_path: "/" diff --git a/lib/philomena_web/controllers/duplicate_report/accept_controller.ex b/lib/philomena_web/controllers/duplicate_report/accept_controller.ex index 4462fb38..3c57af23 100644 --- a/lib/philomena_web/controllers/duplicate_report/accept_controller.ex +++ b/lib/philomena_web/controllers/duplicate_report/accept_controller.ex @@ -20,7 +20,7 @@ defmodule PhilomenaWeb.DuplicateReport.AcceptController do {:ok, report} -> conn |> put_flash(:info, "Successfully accepted report.") - |> moderation_log(details: &log_details/3, data: report.duplicate_report) + |> moderation_log(details: &log_details/2, data: report.duplicate_report) |> redirect(to: ~p"/duplicate_reports") _error -> @@ -30,7 +30,7 @@ defmodule PhilomenaWeb.DuplicateReport.AcceptController do end end - defp log_details(_conn, _action, report) do + defp log_details(_action, report) do %{ body: "Accepted duplicate report, merged #{report.image.id} into #{report.duplicate_of_image.id}", diff --git a/lib/philomena_web/controllers/duplicate_report/accept_reverse_controller.ex b/lib/philomena_web/controllers/duplicate_report/accept_reverse_controller.ex index 873768ff..5e4ae80e 100644 --- a/lib/philomena_web/controllers/duplicate_report/accept_reverse_controller.ex +++ b/lib/philomena_web/controllers/duplicate_report/accept_reverse_controller.ex @@ -20,7 +20,7 @@ defmodule PhilomenaWeb.DuplicateReport.AcceptReverseController do {:ok, report} -> conn |> put_flash(:info, "Successfully accepted report in reverse.") - |> moderation_log(details: &log_details/3, data: report.duplicate_report) + |> moderation_log(details: &log_details/2, data: report.duplicate_report) |> redirect(to: ~p"/duplicate_reports") _error -> @@ -30,7 +30,7 @@ defmodule PhilomenaWeb.DuplicateReport.AcceptReverseController do end end - defp log_details(_conn, _action, report) do + defp log_details(_action, report) do %{ body: "Reverse-accepted duplicate report, merged #{report.image.id} into #{report.duplicate_of_image.id}", diff --git a/lib/philomena_web/controllers/duplicate_report/claim_controller.ex b/lib/philomena_web/controllers/duplicate_report/claim_controller.ex index 446fa367..2abec4b3 100644 --- a/lib/philomena_web/controllers/duplicate_report/claim_controller.ex +++ b/lib/philomena_web/controllers/duplicate_report/claim_controller.ex @@ -20,7 +20,7 @@ defmodule PhilomenaWeb.DuplicateReport.ClaimController do conn |> put_flash(:info, "Successfully claimed report.") - |> moderation_log(details: &log_details/3, data: report) + |> moderation_log(details: &log_details/2, data: report) |> redirect(to: ~p"/duplicate_reports") end @@ -29,11 +29,11 @@ defmodule PhilomenaWeb.DuplicateReport.ClaimController do conn |> put_flash(:info, "Successfully released report.") - |> moderation_log(details: &log_details/3) + |> moderation_log(details: &log_details/2) |> redirect(to: ~p"/duplicate_reports") end - defp log_details(_conn, action, _) do + defp log_details(action, _) do body = case action do :create -> "Claimed a duplicate report" diff --git a/lib/philomena_web/controllers/duplicate_report/reject_controller.ex b/lib/philomena_web/controllers/duplicate_report/reject_controller.ex index 7d428e52..957a92c8 100644 --- a/lib/philomena_web/controllers/duplicate_report/reject_controller.ex +++ b/lib/philomena_web/controllers/duplicate_report/reject_controller.ex @@ -21,11 +21,11 @@ defmodule PhilomenaWeb.DuplicateReport.RejectController do conn |> put_flash(:info, "Successfully rejected report.") - |> moderation_log(details: &log_details/3, data: report) + |> moderation_log(details: &log_details/2, data: report) |> redirect(to: ~p"/duplicate_reports") end - defp log_details(_conn, _action, report) do + defp log_details(_action, report) do %{ body: "Rejected duplicate report (#{report.image.id} -> #{report.duplicate_of_image.id})", subject_path: ~p"/duplicate_reports" diff --git a/lib/philomena_web/controllers/image/anonymous_controller.ex b/lib/philomena_web/controllers/image/anonymous_controller.ex index feed3ff1..e36b5020 100644 --- a/lib/philomena_web/controllers/image/anonymous_controller.ex +++ b/lib/philomena_web/controllers/image/anonymous_controller.ex @@ -22,7 +22,7 @@ defmodule PhilomenaWeb.Image.AnonymousController do conn |> put_flash(:info, "Successfully updated anonymity.") - |> moderation_log(details: &log_details/3, data: image) + |> moderation_log(details: &log_details/2, data: image) |> redirect(to: ~p"/images/#{image}") end @@ -33,7 +33,7 @@ defmodule PhilomenaWeb.Image.AnonymousController do end end - defp log_details(_conn, _action, image) do + defp log_details(_action, image) do %{ body: "Updated anonymity of image >>#{image.id}", subject_path: ~p"/images/#{image}" diff --git a/lib/philomena_web/controllers/image/approve_controller.ex b/lib/philomena_web/controllers/image/approve_controller.ex index b67b9619..bbb3e8da 100644 --- a/lib/philomena_web/controllers/image/approve_controller.ex +++ b/lib/philomena_web/controllers/image/approve_controller.ex @@ -14,11 +14,11 @@ defmodule PhilomenaWeb.Image.ApproveController do conn |> put_flash(:info, "Image has been approved.") - |> moderation_log(details: &log_details/3, data: image) + |> moderation_log(details: &log_details/2, data: image) |> redirect(to: ~p"/admin/approvals") end - defp log_details(_conn, _action, image) do + defp log_details(_action, image) do %{body: "Approved image #{image.id}", subject_path: ~p"/images/#{image}"} end end diff --git a/lib/philomena_web/controllers/image/comment/approve_controller.ex b/lib/philomena_web/controllers/image/comment/approve_controller.ex index c55e734c..617d0280 100644 --- a/lib/philomena_web/controllers/image/comment/approve_controller.ex +++ b/lib/philomena_web/controllers/image/comment/approve_controller.ex @@ -22,11 +22,11 @@ defmodule PhilomenaWeb.Image.Comment.ApproveController do conn |> put_flash(:info, "Comment has been approved.") - |> moderation_log(details: &log_details/3, data: comment) + |> moderation_log(details: &log_details/2, data: comment) |> redirect(to: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}") end - defp log_details(_conn, _action, comment) do + defp log_details(_action, comment) do %{ body: "Approved comment on image >>#{comment.image_id}", subject_path: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}" diff --git a/lib/philomena_web/controllers/image/comment/delete_controller.ex b/lib/philomena_web/controllers/image/comment/delete_controller.ex index 65e80700..2cf8fb39 100644 --- a/lib/philomena_web/controllers/image/comment/delete_controller.ex +++ b/lib/philomena_web/controllers/image/comment/delete_controller.ex @@ -16,7 +16,7 @@ defmodule PhilomenaWeb.Image.Comment.DeleteController do conn |> put_flash(:info, "Comment successfully destroyed!") - |> moderation_log(details: &log_details/3, data: comment) + |> moderation_log(details: &log_details/2, data: comment) |> redirect(to: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}") {:error, _changeset} -> @@ -26,7 +26,7 @@ defmodule PhilomenaWeb.Image.Comment.DeleteController do end end - defp log_details(_conn, _action, comment) do + defp log_details(_action, comment) do %{ body: "Destroyed comment on image >>#{comment.image_id}", subject_path: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}" diff --git a/lib/philomena_web/controllers/image/comment/hide_controller.ex b/lib/philomena_web/controllers/image/comment/hide_controller.ex index 50a10f57..2fe709a5 100644 --- a/lib/philomena_web/controllers/image/comment/hide_controller.ex +++ b/lib/philomena_web/controllers/image/comment/hide_controller.ex @@ -15,7 +15,7 @@ defmodule PhilomenaWeb.Image.Comment.HideController do {:ok, comment} -> conn |> put_flash(:info, "Comment successfully hidden!") - |> moderation_log(details: &log_details/3, data: comment) + |> moderation_log(details: &log_details/2, data: comment) |> redirect(to: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}") _error -> @@ -32,7 +32,7 @@ defmodule PhilomenaWeb.Image.Comment.HideController do {:ok, comment} -> conn |> put_flash(:info, "Comment successfully unhidden!") - |> moderation_log(details: &log_details/3, data: comment) + |> moderation_log(details: &log_details/2, data: comment) |> redirect(to: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}") {:error, _changeset} -> @@ -42,7 +42,7 @@ defmodule PhilomenaWeb.Image.Comment.HideController do end end - defp log_details(_conn, action, comment) do + defp log_details(action, comment) do body = case action do :create -> "Hidden comment on image >>#{comment.image_id} (#{comment.deletion_reason})" diff --git a/lib/philomena_web/controllers/image/comment_lock_controller.ex b/lib/philomena_web/controllers/image/comment_lock_controller.ex index 9256f9b6..432d1283 100644 --- a/lib/philomena_web/controllers/image/comment_lock_controller.ex +++ b/lib/philomena_web/controllers/image/comment_lock_controller.ex @@ -12,7 +12,7 @@ defmodule PhilomenaWeb.Image.CommentLockController do conn |> put_flash(:info, "Successfully locked comments.") - |> moderation_log(details: &log_details/3, data: image) + |> moderation_log(details: &log_details/2, data: image) |> redirect(to: ~p"/images/#{image}") end @@ -21,11 +21,11 @@ defmodule PhilomenaWeb.Image.CommentLockController do conn |> put_flash(:info, "Successfully unlocked comments.") - |> moderation_log(details: &log_details/3, data: image) + |> moderation_log(details: &log_details/2, data: image) |> redirect(to: ~p"/images/#{image}") end - defp log_details(_conn, action, image) do + defp log_details(action, image) do body = case action do :create -> "Locked comments on image >>#{image.id}" diff --git a/lib/philomena_web/controllers/image/delete_controller.ex b/lib/philomena_web/controllers/image/delete_controller.ex index a9ccbad8..c6b22d54 100644 --- a/lib/philomena_web/controllers/image/delete_controller.ex +++ b/lib/philomena_web/controllers/image/delete_controller.ex @@ -19,7 +19,7 @@ defmodule PhilomenaWeb.Image.DeleteController do {:ok, result} -> conn |> put_flash(:info, "Image successfully hidden.") - |> moderation_log(details: &log_details/3, data: result.image) + |> moderation_log(details: &log_details/2, data: result.image) |> redirect(to: ~p"/images/#{image}") _error -> @@ -36,7 +36,7 @@ defmodule PhilomenaWeb.Image.DeleteController do {:ok, image} -> conn |> put_flash(:info, "Hide reason updated.") - |> moderation_log(details: &log_details/3, data: image) + |> moderation_log(details: &log_details/2, data: image) |> redirect(to: ~p"/images/#{image}") {:error, _changeset} -> @@ -66,11 +66,11 @@ defmodule PhilomenaWeb.Image.DeleteController do conn |> put_flash(:info, "Image successfully unhidden.") - |> moderation_log(details: &log_details/3, data: image) + |> moderation_log(details: &log_details/2, data: image) |> redirect(to: ~p"/images/#{image}") end - defp log_details(_conn, action, image) do + defp log_details(action, image) do body = case action do :create -> "Hidden image >>#{image.id} (#{image.deletion_reason})" diff --git a/lib/philomena_web/controllers/image/description_lock_controller.ex b/lib/philomena_web/controllers/image/description_lock_controller.ex index e7ddc628..9065ff6d 100644 --- a/lib/philomena_web/controllers/image/description_lock_controller.ex +++ b/lib/philomena_web/controllers/image/description_lock_controller.ex @@ -12,7 +12,7 @@ defmodule PhilomenaWeb.Image.DescriptionLockController do conn |> put_flash(:info, "Successfully locked description.") - |> moderation_log(details: &log_details/3, data: image) + |> moderation_log(details: &log_details/2, data: image) |> redirect(to: ~p"/images/#{image}") end @@ -21,11 +21,11 @@ defmodule PhilomenaWeb.Image.DescriptionLockController do conn |> put_flash(:info, "Successfully unlocked description.") - |> moderation_log(details: &log_details/3, data: image) + |> moderation_log(details: &log_details/2, data: image) |> redirect(to: ~p"/images/#{image}") end - defp log_details(_conn, action, image) do + defp log_details(action, image) do body = case action do :create -> "Locked description editing on image >>#{image.id}" diff --git a/lib/philomena_web/controllers/image/destroy_controller.ex b/lib/philomena_web/controllers/image/destroy_controller.ex index 986773d0..8685bc77 100644 --- a/lib/philomena_web/controllers/image/destroy_controller.ex +++ b/lib/philomena_web/controllers/image/destroy_controller.ex @@ -15,7 +15,7 @@ defmodule PhilomenaWeb.Image.DestroyController do {:ok, image} -> conn |> put_flash(:info, "Image contents destroyed.") - |> moderation_log(details: &log_details/3, data: image) + |> moderation_log(details: &log_details/2, data: image) |> redirect(to: ~p"/images/#{image}") _error -> @@ -38,7 +38,7 @@ defmodule PhilomenaWeb.Image.DestroyController do end end - defp log_details(_conn, _action, image) do + defp log_details(_action, image) do %{ body: "Hard-deleted image >>#{image.id}", subject_path: ~p"/images/#{image}" diff --git a/lib/philomena_web/controllers/image/feature_controller.ex b/lib/philomena_web/controllers/image/feature_controller.ex index 59df5b73..74214fcb 100644 --- a/lib/philomena_web/controllers/image/feature_controller.ex +++ b/lib/philomena_web/controllers/image/feature_controller.ex @@ -16,7 +16,7 @@ defmodule PhilomenaWeb.Image.FeatureController do conn |> put_flash(:info, "Image marked as featured image.") - |> moderation_log(details: &log_details/3, data: image) + |> moderation_log(details: &log_details/2, data: image) |> redirect(to: ~p"/images/#{image}") end @@ -33,7 +33,7 @@ defmodule PhilomenaWeb.Image.FeatureController do end end - defp log_details(_conn, _action, image) do + defp log_details(_action, image) do %{ body: "Featured image >>#{image.id}", subject_path: ~p"/images/#{image}" diff --git a/lib/philomena_web/controllers/image/hash_controller.ex b/lib/philomena_web/controllers/image/hash_controller.ex index ffbeb109..ab929724 100644 --- a/lib/philomena_web/controllers/image/hash_controller.ex +++ b/lib/philomena_web/controllers/image/hash_controller.ex @@ -12,11 +12,11 @@ defmodule PhilomenaWeb.Image.HashController do conn |> put_flash(:info, "Successfully cleared hash.") - |> moderation_log(details: &log_details/3, data: image) + |> moderation_log(details: &log_details/2, data: image) |> redirect(to: ~p"/images/#{image}") end - defp log_details(_conn, _action, image) do + defp log_details(_action, image) do %{ body: "Cleared hash of image >>#{image.id}", subject_path: ~p"/images/#{image}" diff --git a/lib/philomena_web/controllers/image/repair_controller.ex b/lib/philomena_web/controllers/image/repair_controller.ex index 80a050b7..972d79df 100644 --- a/lib/philomena_web/controllers/image/repair_controller.ex +++ b/lib/philomena_web/controllers/image/repair_controller.ex @@ -13,11 +13,11 @@ defmodule PhilomenaWeb.Image.RepairController do conn |> put_flash(:info, "Repair job enqueued.") - |> moderation_log(details: &log_details/3, data: conn.assigns.image) + |> moderation_log(details: &log_details/2, data: conn.assigns.image) |> redirect(to: ~p"/images/#{conn.assigns.image}") end - defp log_details(_conn, _action, image) do + defp log_details(_action, image) do %{ body: "Repaired image >>#{image.id}", subject_path: ~p"/images/#{image}" diff --git a/lib/philomena_web/controllers/image/scratchpad_controller.ex b/lib/philomena_web/controllers/image/scratchpad_controller.ex index b3cd8e69..56ffe897 100644 --- a/lib/philomena_web/controllers/image/scratchpad_controller.ex +++ b/lib/philomena_web/controllers/image/scratchpad_controller.ex @@ -17,11 +17,11 @@ defmodule PhilomenaWeb.Image.ScratchpadController do conn |> put_flash(:info, "Successfully updated moderation notes.") - |> moderation_log(details: &log_details/3, data: image) + |> moderation_log(details: &log_details/2, data: image) |> redirect(to: ~p"/images/#{image}") end - defp log_details(_conn, _action, image) do + defp log_details(_action, image) do %{ body: "Updated mod notes on image >>#{image.id} (#{image.scratchpad})", subject_path: ~p"/images/#{image}" diff --git a/lib/philomena_web/controllers/image/source_history_controller.ex b/lib/philomena_web/controllers/image/source_history_controller.ex index 022a270d..f82a344f 100644 --- a/lib/philomena_web/controllers/image/source_history_controller.ex +++ b/lib/philomena_web/controllers/image/source_history_controller.ex @@ -14,11 +14,11 @@ defmodule PhilomenaWeb.Image.SourceHistoryController do conn |> put_flash(:info, "Successfully deleted source history.") - |> moderation_log(details: &log_details/3, data: image) + |> moderation_log(details: &log_details/2, data: image) |> redirect(to: ~p"/images/#{image}") end - defp log_details(_conn, _action, image) do + defp log_details(_action, image) do %{ body: "Deleted source history for image >>#{image.id}", subject_path: ~p"/images/#{image}" diff --git a/lib/philomena_web/controllers/image/tag_change_controller.ex b/lib/philomena_web/controllers/image/tag_change_controller.ex index b38735ca..fc35a782 100644 --- a/lib/philomena_web/controllers/image/tag_change_controller.ex +++ b/lib/philomena_web/controllers/image/tag_change_controller.ex @@ -43,7 +43,7 @@ defmodule PhilomenaWeb.Image.TagChangeController do conn |> put_flash(:info, "Successfully deleted tag change from history.") |> moderation_log( - details: &log_details/3, + details: &log_details/2, data: %{image: image, details: tag_change_details(tag_change)} ) |> redirect(to: ~p"/images/#{image}") @@ -58,7 +58,7 @@ defmodule PhilomenaWeb.Image.TagChangeController do defp added_filter(query, _params), do: query - defp log_details(_conn, _action, %{image: image, details: details}) do + defp log_details(_action, %{image: image, details: details}) do %{ body: "Deleted tag change #{details} on >>#{image.id} from history", subject_path: ~p"/images/#{image}" diff --git a/lib/philomena_web/controllers/image/tag_lock_controller.ex b/lib/philomena_web/controllers/image/tag_lock_controller.ex index c80841c7..028cbf4c 100644 --- a/lib/philomena_web/controllers/image/tag_lock_controller.ex +++ b/lib/philomena_web/controllers/image/tag_lock_controller.ex @@ -23,7 +23,7 @@ defmodule PhilomenaWeb.Image.TagLockController do conn |> put_flash(:info, "Successfully updated list of locked tags.") - |> moderation_log(details: &log_details/3, data: image) + |> moderation_log(details: &log_details/2, data: image) |> redirect(to: ~p"/images/#{image}") end @@ -32,7 +32,7 @@ defmodule PhilomenaWeb.Image.TagLockController do conn |> put_flash(:info, "Successfully locked tags.") - |> moderation_log(details: &log_details/3, data: image) + |> moderation_log(details: &log_details/2, data: image) |> redirect(to: ~p"/images/#{image}") end @@ -41,11 +41,11 @@ defmodule PhilomenaWeb.Image.TagLockController do conn |> put_flash(:info, "Successfully unlocked tags.") - |> moderation_log(details: &log_details/3, data: image) + |> moderation_log(details: &log_details/2, data: image) |> redirect(to: ~p"/images/#{image}") end - defp log_details(_conn, action, image) do + defp log_details(action, image) do body = case action do :create -> "Locked tags on image >>#{image.id}" diff --git a/lib/philomena_web/controllers/image/tamper_controller.ex b/lib/philomena_web/controllers/image/tamper_controller.ex index 2cc03745..ede16a46 100644 --- a/lib/philomena_web/controllers/image/tamper_controller.ex +++ b/lib/philomena_web/controllers/image/tamper_controller.ex @@ -25,13 +25,13 @@ defmodule PhilomenaWeb.Image.TamperController do conn |> put_flash(:info, "Vote removed.") |> moderation_log( - details: &log_details/3, + details: &log_details/2, data: %{vote: result, image: image, username: conn.assigns.user.name} ) |> redirect(to: ~p"/images/#{conn.assigns.image}") end - defp log_details(_conn, _action, data) do + defp log_details(_action, data) do image = data.image vote_type = diff --git a/lib/philomena_web/controllers/tag/image_controller.ex b/lib/philomena_web/controllers/tag/image_controller.ex index 96ed3899..b98e1909 100644 --- a/lib/philomena_web/controllers/tag/image_controller.ex +++ b/lib/philomena_web/controllers/tag/image_controller.ex @@ -23,7 +23,7 @@ defmodule PhilomenaWeb.Tag.ImageController do {:ok, tag} -> conn |> put_flash(:info, "Tag image successfully updated.") - |> moderation_log(details: &log_details/3, data: tag) + |> moderation_log(details: &log_details/2, data: tag) |> redirect(to: ~p"/tags/#{tag}") {:error, :tag, changeset, _changes} -> @@ -36,11 +36,11 @@ defmodule PhilomenaWeb.Tag.ImageController do conn |> put_flash(:info, "Tag image successfully removed.") - |> moderation_log(details: &log_details/3, data: tag) + |> moderation_log(details: &log_details/2, data: tag) |> redirect(to: ~p"/tags/#{conn.assigns.tag}") end - defp log_details(_conn, action, tag) do + defp log_details(action, tag) do body = case action do :update -> "Updated image on tag '#{tag.name}'" diff --git a/lib/philomena_web/controllers/tag_controller.ex b/lib/philomena_web/controllers/tag_controller.ex index 162393bb..82ea790a 100644 --- a/lib/philomena_web/controllers/tag_controller.ex +++ b/lib/philomena_web/controllers/tag_controller.ex @@ -97,7 +97,7 @@ defmodule PhilomenaWeb.TagController do {:ok, tag} -> conn |> put_flash(:info, "Tag successfully updated.") - |> moderation_log(details: &log_details/3, data: tag) + |> moderation_log(details: &log_details/2, data: tag) |> redirect(to: ~p"/tags/#{tag}") {:error, changeset} -> @@ -110,7 +110,7 @@ defmodule PhilomenaWeb.TagController do conn |> put_flash(:info, "Tag queued for deletion.") - |> moderation_log(details: &log_details/3, data: tag) + |> moderation_log(details: &log_details/2, data: tag) |> redirect(to: "/") end @@ -172,7 +172,7 @@ defmodule PhilomenaWeb.TagController do end end - defp log_details(_conn, action, tag) do + defp log_details(action, tag) do body = case action do :update -> "Updated details on tag '#{tag.name}'" diff --git a/lib/philomena_web/controllers/topic/hide_controller.ex b/lib/philomena_web/controllers/topic/hide_controller.ex index 8eb947cf..4558f393 100644 --- a/lib/philomena_web/controllers/topic/hide_controller.ex +++ b/lib/philomena_web/controllers/topic/hide_controller.ex @@ -27,7 +27,7 @@ defmodule PhilomenaWeb.Topic.HideController do {:ok, topic} -> conn |> put_flash(:info, "Topic successfully hidden!") - |> moderation_log(details: &log_details/3, data: topic) + |> moderation_log(details: &log_details/2, data: topic) |> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}") {:error, _changeset} -> @@ -44,7 +44,7 @@ defmodule PhilomenaWeb.Topic.HideController do {:ok, topic} -> conn |> put_flash(:info, "Topic successfully restored!") - |> moderation_log(details: &log_details/3, data: topic) + |> moderation_log(details: &log_details/2, data: topic) |> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}") {:error, _changeset} -> @@ -54,7 +54,7 @@ defmodule PhilomenaWeb.Topic.HideController do end end - defp log_details(_conn, action, topic) do + defp log_details(action, topic) do body = case action do :create -> diff --git a/lib/philomena_web/controllers/topic/lock_controller.ex b/lib/philomena_web/controllers/topic/lock_controller.ex index 9cb95c7f..c9b9c21f 100644 --- a/lib/philomena_web/controllers/topic/lock_controller.ex +++ b/lib/philomena_web/controllers/topic/lock_controller.ex @@ -26,7 +26,7 @@ defmodule PhilomenaWeb.Topic.LockController do {:ok, topic} -> conn |> put_flash(:info, "Topic successfully locked!") - |> moderation_log(details: &log_details/3, data: topic) + |> moderation_log(details: &log_details/2, data: topic) |> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}") {:error, _changeset} -> @@ -43,7 +43,7 @@ defmodule PhilomenaWeb.Topic.LockController do {:ok, topic} -> conn |> put_flash(:info, "Topic successfully unlocked!") - |> moderation_log(details: &log_details/3, data: topic) + |> moderation_log(details: &log_details/2, data: topic) |> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}") {:error, _changeset} -> @@ -53,7 +53,7 @@ defmodule PhilomenaWeb.Topic.LockController do end end - defp log_details(_conn, action, topic) do + defp log_details(action, topic) do body = case action do :create -> "Locked topic '#{topic.title}' (#{topic.lock_reason}) in #{topic.forum.name}" diff --git a/lib/philomena_web/controllers/topic/move_controller.ex b/lib/philomena_web/controllers/topic/move_controller.ex index fcd17c21..00fe220b 100644 --- a/lib/philomena_web/controllers/topic/move_controller.ex +++ b/lib/philomena_web/controllers/topic/move_controller.ex @@ -29,7 +29,7 @@ defmodule PhilomenaWeb.Topic.MoveController do conn |> put_flash(:info, "Topic successfully moved!") - |> moderation_log(details: &log_details/3, data: topic) + |> moderation_log(details: &log_details/2, data: topic) |> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}") {:error, _changeset} -> @@ -39,7 +39,7 @@ defmodule PhilomenaWeb.Topic.MoveController do end end - defp log_details(_conn, _action, topic) do + defp log_details(_action, topic) do %{ body: "Topic '#{topic.title}' moved to #{topic.forum.name}", subject_path: ~p"/forums/#{topic.forum}/topics/#{topic}" diff --git a/lib/philomena_web/controllers/topic/post/approve_controller.ex b/lib/philomena_web/controllers/topic/post/approve_controller.ex index 1af98931..65d289ca 100644 --- a/lib/philomena_web/controllers/topic/post/approve_controller.ex +++ b/lib/philomena_web/controllers/topic/post/approve_controller.ex @@ -20,7 +20,7 @@ defmodule PhilomenaWeb.Topic.Post.ApproveController do {:ok, post} -> conn |> put_flash(:info, "Post successfully approved.") - |> moderation_log(details: &log_details/3, data: post) + |> moderation_log(details: &log_details/2, data: post) |> redirect( to: ~p"/forums/#{post.topic.forum}/topics/#{post.topic}?#{[post_id: post.id]}" <> @@ -38,7 +38,7 @@ defmodule PhilomenaWeb.Topic.Post.ApproveController do end end - defp log_details(_conn, _action, post) do + defp log_details(_action, post) do %{ body: "Approved forum post ##{post.id} in topic '#{post.topic.title}'", subject_path: diff --git a/lib/philomena_web/controllers/topic/post/delete_controller.ex b/lib/philomena_web/controllers/topic/post/delete_controller.ex index 9fa2b490..28aad707 100644 --- a/lib/philomena_web/controllers/topic/post/delete_controller.ex +++ b/lib/philomena_web/controllers/topic/post/delete_controller.ex @@ -19,7 +19,7 @@ defmodule PhilomenaWeb.Topic.Post.DeleteController do {:ok, post} -> conn |> put_flash(:info, "Post successfully destroyed!") - |> moderation_log(details: &log_details/3, data: post) + |> moderation_log(details: &log_details/2, data: post) |> redirect( to: ~p"/forums/#{post.topic.forum}/topics/#{post.topic}?#{[post_id: post.id]}" <> @@ -37,7 +37,7 @@ defmodule PhilomenaWeb.Topic.Post.DeleteController do end end - defp log_details(_conn, _action, post) do + defp log_details(_action, post) do %{ body: "Destroyed forum post ##{post.id} in topic '#{post.topic.title}'", subject_path: diff --git a/lib/philomena_web/controllers/topic/post/hide_controller.ex b/lib/philomena_web/controllers/topic/post/hide_controller.ex index da423f3b..882321af 100644 --- a/lib/philomena_web/controllers/topic/post/hide_controller.ex +++ b/lib/philomena_web/controllers/topic/post/hide_controller.ex @@ -20,7 +20,7 @@ defmodule PhilomenaWeb.Topic.Post.HideController do {:ok, post} -> conn |> put_flash(:info, "Post successfully hidden.") - |> moderation_log(details: &log_details/3, data: post) + |> moderation_log(details: &log_details/2, data: post) |> redirect( to: ~p"/forums/#{post.topic.forum}/topics/#{post.topic}?#{[post_id: post.id]}" <> @@ -45,7 +45,7 @@ defmodule PhilomenaWeb.Topic.Post.HideController do {:ok, post} -> conn |> put_flash(:info, "Post successfully unhidden.") - |> moderation_log(details: &log_details/3, data: post) + |> moderation_log(details: &log_details/2, data: post) |> redirect( to: ~p"/forums/#{post.topic.forum}/topics/#{post.topic}?#{[post_id: post.id]}" <> @@ -63,7 +63,7 @@ defmodule PhilomenaWeb.Topic.Post.HideController do end end - defp log_details(_conn, action, post) do + defp log_details(action, post) do body = case action do :create -> diff --git a/lib/philomena_web/controllers/topic/stick_controller.ex b/lib/philomena_web/controllers/topic/stick_controller.ex index a6ee72c4..39f0d562 100644 --- a/lib/philomena_web/controllers/topic/stick_controller.ex +++ b/lib/philomena_web/controllers/topic/stick_controller.ex @@ -25,7 +25,7 @@ defmodule PhilomenaWeb.Topic.StickController do {:ok, topic} -> conn |> put_flash(:info, "Topic successfully stickied!") - |> moderation_log(details: &log_details/3, data: topic) + |> moderation_log(details: &log_details/2, data: topic) |> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}") {:error, _changeset} -> @@ -42,7 +42,7 @@ defmodule PhilomenaWeb.Topic.StickController do {:ok, topic} -> conn |> put_flash(:info, "Topic successfully unstickied!") - |> moderation_log(details: &log_details/3, data: topic) + |> moderation_log(details: &log_details/2, data: topic) |> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}") {:error, _changeset} -> @@ -52,7 +52,7 @@ defmodule PhilomenaWeb.Topic.StickController do end end - defp log_details(_conn, action, topic) do + defp log_details(action, topic) do body = case action do :create -> "Stickied topic '#{topic.title}' in #{topic.forum.name}" From 6f0a2698f10a820608327f6093c1a6e579a98096 Mon Sep 17 00:00:00 2001 From: Luna D Date: Sun, 23 Jun 2024 10:43:16 -0400 Subject: [PATCH 3/8] Remove conn from details_func invocation --- lib/philomena_web/plugs/moderation_log_plug.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/philomena_web/plugs/moderation_log_plug.ex b/lib/philomena_web/plugs/moderation_log_plug.ex index 4ee75938..e69da570 100644 --- a/lib/philomena_web/plugs/moderation_log_plug.ex +++ b/lib/philomena_web/plugs/moderation_log_plug.ex @@ -17,7 +17,7 @@ defmodule PhilomenaWeb.ModerationLogPlug do def init(opts), do: opts @type log_details :: %{subject_path: String.t(), body: String.t()} - @type details_func :: (Plug.Conn.t(), atom(), any() -> log_details()) + @type details_func :: (atom(), any() -> log_details()) @type call_opts :: [details: details_func, data: any()] @doc false @@ -29,7 +29,7 @@ defmodule PhilomenaWeb.ModerationLogPlug do user = conn.assigns.current_user action = Controller.action_name(conn) - %{subject_path: subject_path, body: body} = details_func.(conn, action, userdata) + %{subject_path: subject_path, body: body} = details_func.(action, userdata) mod = Controller.controller_module(conn) [mod_name] = Regex.run(@controller_regex, to_string(mod), capture: :all_but_first) From e23a4c541cd98d3491d33439348a141a75557846 Mon Sep 17 00:00:00 2001 From: "Luna D." Date: Sun, 23 Jun 2024 14:38:56 +0200 Subject: [PATCH 4/8] convert burger menu logic to typescript --- assets/js/{burger.js => burger.ts} | 36 +++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) rename assets/js/{burger.js => burger.ts} (56%) diff --git a/assets/js/burger.js b/assets/js/burger.ts similarity index 56% rename from assets/js/burger.js rename to assets/js/burger.ts index c7a573f4..2d465fb6 100644 --- a/assets/js/burger.js +++ b/assets/js/burger.ts @@ -2,12 +2,15 @@ * Hamburger menu. */ -function switchClasses(element, oldClass, newClass) { +import { $, $$ } from './utils/dom'; +import { assertNotNull } from './utils/assert'; + +function switchClasses(element: HTMLElement, oldClass: string, newClass: string) { element.classList.remove(oldClass); element.classList.add(newClass); } -function open(burger, content, body, root) { +function open(burger: HTMLElement, content: HTMLElement, body: HTMLElement, root: HTMLElement) { switchClasses(content, 'close', 'open'); switchClasses(burger, 'close', 'open'); @@ -15,7 +18,7 @@ function open(burger, content, body, root) { body.classList.add('no-overflow'); } -function close(burger, content, body, root) { +function close(burger: HTMLElement, content: HTMLElement, body: HTMLElement, root: HTMLElement) { switchClasses(content, 'open', 'close'); switchClasses(burger, 'open', 'close'); @@ -26,27 +29,25 @@ function close(burger, content, body, root) { }, 300); } -function copyArtistLinksTo(burger) { - const copy = links => { +function copyArtistLinksTo(burger: HTMLElement) { + const copy = (links: HTMLCollection) => { burger.appendChild(document.createElement('hr')); - [].slice.call(links).forEach(link => { - const burgerLink = link.cloneNode(true); - + for (const link of links) { + const burgerLink = link.cloneNode(true) as HTMLElement; burgerLink.className = ''; burger.appendChild(burgerLink); - }); + } }; - const linksContainers = document.querySelectorAll('.js-burger-links'); - - [].slice.call(linksContainers).forEach(container => copy(container.children)); + $$('.js-burger-links').forEach(container => copy(container.children)); } -function setupBurgerMenu() { - const burger = document.getElementById('burger'); - const toggle = document.getElementById('js-burger-toggle'); - const content = document.getElementById('container'); +export function setupBurgerMenu() { + // Burger menu should exist on all pages. + const burger = assertNotNull($('#burger')); + const toggle = assertNotNull($('#js-burger-toggle')); + const content = assertNotNull($('#container')); const body = document.body; const root = document.documentElement; @@ -63,11 +64,10 @@ function setupBurgerMenu() { open(burger, content, body, root); } }); + content.addEventListener('click', () => { if (content.classList.contains('open')) { close(burger, content, body, root); } }); } - -export { setupBurgerMenu }; From 312999210851a2f052d4185b1d84816a1c964d1a Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 23 Jun 2024 11:31:10 -0400 Subject: [PATCH 5/8] Fix name of function --- assets/js/burger.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/js/burger.ts b/assets/js/burger.ts index 2d465fb6..d82d032f 100644 --- a/assets/js/burger.ts +++ b/assets/js/burger.ts @@ -29,7 +29,7 @@ function close(burger: HTMLElement, content: HTMLElement, body: HTMLElement, roo }, 300); } -function copyArtistLinksTo(burger: HTMLElement) { +function copyUserLinksTo(burger: HTMLElement) { const copy = (links: HTMLCollection) => { burger.appendChild(document.createElement('hr')); @@ -51,7 +51,7 @@ export function setupBurgerMenu() { const body = document.body; const root = document.documentElement; - copyArtistLinksTo(burger); + copyUserLinksTo(burger); toggle.addEventListener('click', event => { event.stopPropagation(); From 2e5b0678cdfdeac3f3f4505807605dfc2f0ab56c Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 23 Jun 2024 11:52:20 -0400 Subject: [PATCH 6/8] Remove obsolete block-all-mixed-content This was removed in all major browsers with no replacement. See https://www.w3.org/TR/mixed-content/#strict-checking for details on the obsolescence. --- lib/philomena_web/plugs/content_security_policy_plug.ex | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/philomena_web/plugs/content_security_policy_plug.ex b/lib/philomena_web/plugs/content_security_policy_plug.ex index 210ff645..34cca2d6 100644 --- a/lib/philomena_web/plugs/content_security_policy_plug.ex +++ b/lib/philomena_web/plugs/content_security_policy_plug.ex @@ -34,8 +34,7 @@ defmodule PhilomenaWeb.ContentSecurityPolicyPlug do {:form_action, ["'self'"]}, {:manifest_src, ["'self'"]}, {:img_src, ["'self'", "blob:", "data:", cdn_uri, camo_uri]}, - {:media_src, ["'self'", "blob:", "data:", cdn_uri, camo_uri]}, - {:block_all_mixed_content, []} + {:media_src, ["'self'", "blob:", "data:", cdn_uri, camo_uri]} ] csp_value = From 0f3c6674b33ee46809d3cf8897ba6c109c85f7bb Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 23 Jun 2024 11:52:48 -0400 Subject: [PATCH 7/8] Remove version key from docker-compose.yml --- docker-compose.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 369705b4..801c1e30 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,3 @@ -version: '3' volumes: postgres_data: {} opensearch_data: {} From 677ecc265ce25418a86beacb5af56cd7e3c08661 Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 23 Jun 2024 12:36:19 -0400 Subject: [PATCH 8/8] Fix API upload --- lib/philomena_web/controllers/api/json/image_controller.ex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/philomena_web/controllers/api/json/image_controller.ex b/lib/philomena_web/controllers/api/json/image_controller.ex index a142aeb4..82a0068b 100644 --- a/lib/philomena_web/controllers/api/json/image_controller.ex +++ b/lib/philomena_web/controllers/api/json/image_controller.ex @@ -41,6 +41,8 @@ defmodule PhilomenaWeb.Api.Json.ImageController do case Images.create_image(attributes, image_params) do {:ok, %{image: image}} -> + image = Repo.preload(image, tags: :aliases) + PhilomenaWeb.Endpoint.broadcast!( "firehose", "image:create",