mod actions: fix messages to use consistent format.
Fix mod actions to use the same message format everywhere. Before mod actions were formatted in various inconsistent ways: * "deleted post #1234" * "comment #1234 updated by <user>" * "<user> updated forum #1234" * "<user> level changed Member -> Builder" Now all mod actions consistently use this format: * "deleted post #1234" * "updated comment #1234" * "updated forum #1234" * "promoted <user> from Member to Builder" This way mod actions are formatted consistently with other actions on the /user_actions page, where everything is written as "<user> did X". Also add a fix script to fix existing mod actions.
This commit is contained in:
@@ -82,11 +82,11 @@ class Ban < ApplicationRecord
|
||||
end
|
||||
|
||||
def create_ban_mod_action
|
||||
ModAction.log(%{Banned <@#{user_name}> #{humanized_duration}: #{reason}}, :user_ban)
|
||||
ModAction.log(%{banned <@#{user_name}> #{humanized_duration}: #{reason}}, :user_ban, banner)
|
||||
end
|
||||
|
||||
def create_unban_mod_action
|
||||
ModAction.log(%{Unbanned <@#{user_name}>}, :user_unban)
|
||||
ModAction.log(%{unbanned <@#{user_name}>}, :user_unban)
|
||||
end
|
||||
|
||||
def self.available_includes
|
||||
|
||||
@@ -18,12 +18,12 @@ class Comment < ApplicationRecord
|
||||
before_create :autoreport_spam
|
||||
before_save :handle_reports_on_deletion
|
||||
after_create :update_last_commented_at_on_create
|
||||
after_update(:if => ->(rec) {(!rec.is_deleted? || !rec.saved_change_to_is_deleted?) && CurrentUser.id != rec.creator_id}) do |rec|
|
||||
ModAction.log("comment ##{rec.id} updated by #{CurrentUser.user.name}", :comment_update)
|
||||
after_update(:if => ->(rec) {(!rec.is_deleted? || !rec.saved_change_to_is_deleted?) && CurrentUser.id != rec.creator_id}) do |comment|
|
||||
ModAction.log("updated #{comment.dtext_shortlink}", :comment_update, comment.updater)
|
||||
end
|
||||
after_save :update_last_commented_at_on_destroy, :if => ->(rec) {rec.is_deleted? && rec.saved_change_to_is_deleted?}
|
||||
after_save(:if => ->(rec) {rec.is_deleted? && rec.saved_change_to_is_deleted? && CurrentUser.id != rec.creator_id}) do |rec|
|
||||
ModAction.log("comment ##{rec.id} deleted by #{CurrentUser.user.name}", :comment_delete)
|
||||
after_save(:if => ->(rec) {rec.is_deleted? && rec.saved_change_to_is_deleted? && CurrentUser.id != rec.creator_id}) do |comment|
|
||||
ModAction.log("deleted #{comment.dtext_shortlink}", :comment_delete, comment.updater)
|
||||
end
|
||||
|
||||
deletable
|
||||
|
||||
@@ -56,13 +56,13 @@ class CommentVote < ApplicationRecord
|
||||
comment.update_columns(score: comment.score - score)
|
||||
|
||||
if updater != user
|
||||
ModAction.log("#{updater.name} deleted comment vote ##{id} on comment ##{comment_id}", :comment_vote_delete, updater)
|
||||
ModAction.log("deleted comment vote ##{id} on comment ##{comment_id}", :comment_vote_delete, updater)
|
||||
end
|
||||
else
|
||||
comment.update_columns(score: comment.score + score)
|
||||
|
||||
if updater != user
|
||||
ModAction.log("#{updater.name} undeleted comment vote ##{id} on comment ##{comment_id}", :comment_vote_undelete, updater)
|
||||
ModAction.log("undeleted comment vote ##{id} on comment ##{comment_id}", :comment_vote_undelete, updater)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -24,11 +24,11 @@ class ForumPost < ApplicationRecord
|
||||
after_create :update_topic_updated_at_on_create
|
||||
after_update :update_topic_updated_at_on_update_for_original_posts
|
||||
after_destroy :update_topic_updated_at_on_destroy
|
||||
after_update(:if => ->(rec) {rec.updater_id != rec.creator_id}) do |rec|
|
||||
ModAction.log("#{CurrentUser.user.name} updated forum ##{rec.id}", :forum_post_update)
|
||||
after_update(:if => ->(rec) {rec.updater_id != rec.creator_id}) do |forum_post|
|
||||
ModAction.log("updated #{forum_post.dtext_shortlink}", :forum_post_update, forum_post.updater)
|
||||
end
|
||||
after_destroy(:if => ->(rec) {rec.updater_id != rec.creator_id}) do |rec|
|
||||
ModAction.log("#{CurrentUser.user.name} deleted forum ##{rec.id}", :forum_post_delete)
|
||||
after_destroy(:if => ->(rec) {rec.updater_id != rec.creator_id}) do |forum_post|
|
||||
ModAction.log("deleted #{forum_post.dtext_shortlink}", :forum_post_delete, forum_post.updater)
|
||||
end
|
||||
after_create_commit :async_send_discord_notification
|
||||
|
||||
|
||||
@@ -52,11 +52,11 @@ class IpBan < ApplicationRecord
|
||||
|
||||
def create_mod_action
|
||||
if new_record?
|
||||
ModAction.log("#{creator.name} created ip ban for #{ip_addr}", :ip_ban_create)
|
||||
ModAction.log("created ip ban for #{ip_addr}", :ip_ban_create, creator)
|
||||
elsif is_deleted? == true && is_deleted_was == false
|
||||
ModAction.log("#{CurrentUser.user.name} deleted ip ban for #{ip_addr}", :ip_ban_delete)
|
||||
ModAction.log("deleted ip ban for #{ip_addr}", :ip_ban_delete)
|
||||
elsif is_deleted? == false && is_deleted_was == true
|
||||
ModAction.log("#{CurrentUser.user.name} undeleted ip ban for #{ip_addr}", :ip_ban_undelete)
|
||||
ModAction.log("undeleted ip ban for #{ip_addr}", :ip_ban_undelete)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1462,7 +1462,7 @@ class Post < ApplicationRecord
|
||||
if category == "iqdb"
|
||||
update_iqdb
|
||||
|
||||
ModAction.log("<@#{user.name}> regenerated IQDB for post ##{id}", :post_regenerate_iqdb, user)
|
||||
ModAction.log("regenerated IQDB for post ##{id}", :post_regenerate_iqdb, user)
|
||||
else
|
||||
media_file = media_asset.variant(:original).open_file
|
||||
media_asset.distribute_files!(media_file)
|
||||
@@ -1484,7 +1484,7 @@ class Post < ApplicationRecord
|
||||
purge_cached_urls!
|
||||
update_iqdb
|
||||
|
||||
ModAction.log("<@#{user.name}> regenerated image samples for post ##{id}", :post_regenerate, user)
|
||||
ModAction.log("regenerated image samples for post ##{id}", :post_regenerate, user)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -81,9 +81,9 @@ class PostVote < ApplicationRecord
|
||||
return if new_record? || updater.nil? || updater == user
|
||||
|
||||
if is_deleted_changed?(from: false, to: true)
|
||||
ModAction.log("#{updater.name} deleted post vote ##{id} on post ##{post_id}", :post_vote_delete, updater)
|
||||
ModAction.log("deleted post vote ##{id} on post ##{post_id}", :post_vote_delete, updater)
|
||||
elsif is_deleted_changed?(from: true, to: false)
|
||||
ModAction.log("#{updater.name} undeleted post vote ##{id} on post ##{post_id}", :post_vote_undelete, updater)
|
||||
ModAction.log("undeleted post vote ##{id} on post ##{post_id}", :post_vote_undelete, updater)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -11,10 +11,10 @@ class UserFeedback < ApplicationRecord
|
||||
validates :category, presence: true, inclusion: { in: %w[positive negative neutral] }
|
||||
after_create :create_dmail, unless: :disable_dmail_notification
|
||||
after_update(:if => ->(rec) { CurrentUser.id != rec.creator_id}) do |rec|
|
||||
ModAction.log(%{#{CurrentUser.user.name} updated user feedback for "#{rec.user.name}":#{Routes.user_path(rec.user)}}, :user_feedback_update)
|
||||
ModAction.log(%{updated user feedback for "#{rec.user.name}":#{Routes.user_path(rec.user)}}, :user_feedback_update)
|
||||
end
|
||||
after_destroy(:if => ->(rec) { CurrentUser.id != rec.creator_id}) do |rec|
|
||||
ModAction.log(%{#{CurrentUser.user.name} deleted user feedback for "#{rec.user.name}":#{Routes.user_path(rec.user)}}, :user_feedback_delete)
|
||||
ModAction.log(%{deleted user feedback for "#{rec.user.name}":#{Routes.user_path(rec.user)}}, :user_feedback_delete)
|
||||
end
|
||||
|
||||
deletable
|
||||
|
||||
Reference in New Issue
Block a user