From 3933c273c407b56e2cbd7babcdb3b7c0f3b77cc4 Mon Sep 17 00:00:00 2001 From: BrokenEagle Date: Tue, 30 Jan 2018 11:27:06 -0800 Subject: [PATCH] Add mod action for move favorites --- app/models/mod_action.rb | 1 + app/models/post.rb | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/models/mod_action.rb b/app/models/mod_action.rb index 4c6657dab..46b4741ee 100644 --- a/app/models/mod_action.rb +++ b/app/models/mod_action.rb @@ -29,6 +29,7 @@ class ModAction < ApplicationRecord post_ban: 44, post_unban: 45, post_permanent_delete: 46, + post_move_favorites: 47, pool_delete: 62, pool_undelete: 63, artist_ban: 184, diff --git a/app/models/post.rb b/app/models/post.rb index 4833485aa..685911222 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -1330,7 +1330,7 @@ class Post < ApplicationRecord Post.find(parent_id_was).update_has_children_flag if parent_id_was.present? end - def give_favorites_to_parent + def give_favorites_to_parent(options = {}) return if parent.nil? transaction do @@ -1339,6 +1339,10 @@ class Post < ApplicationRecord parent.add_favorite!(fav.user) end end + + unless options[:without_mod_action] + ModAction.log("moved favorites from post ##{id} to post ##{parent.id}",:post_move_favorites) + end end def parent_exists? @@ -1413,7 +1417,7 @@ class Post < ApplicationRecord }, without_protection: true) # XXX This must happen *after* the `is_deleted` flag is set to true (issue #3419). - give_favorites_to_parent if options[:move_favorites] + give_favorites_to_parent(options) if options[:move_favorites] unless options[:without_mod_action] ModAction.log("deleted post ##{id}, reason: #{reason}",:post_delete)