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:
evazion
2022-09-18 20:30:41 -05:00
parent 72e95b6ca3
commit 2119a8efc5
21 changed files with 224 additions and 33 deletions

View File

@@ -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