Add mod action for move favorites
This commit is contained in:
@@ -29,6 +29,7 @@ class ModAction < ApplicationRecord
|
|||||||
post_ban: 44,
|
post_ban: 44,
|
||||||
post_unban: 45,
|
post_unban: 45,
|
||||||
post_permanent_delete: 46,
|
post_permanent_delete: 46,
|
||||||
|
post_move_favorites: 47,
|
||||||
pool_delete: 62,
|
pool_delete: 62,
|
||||||
pool_undelete: 63,
|
pool_undelete: 63,
|
||||||
artist_ban: 184,
|
artist_ban: 184,
|
||||||
|
|||||||
@@ -1330,7 +1330,7 @@ class Post < ApplicationRecord
|
|||||||
Post.find(parent_id_was).update_has_children_flag if parent_id_was.present?
|
Post.find(parent_id_was).update_has_children_flag if parent_id_was.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def give_favorites_to_parent
|
def give_favorites_to_parent(options = {})
|
||||||
return if parent.nil?
|
return if parent.nil?
|
||||||
|
|
||||||
transaction do
|
transaction do
|
||||||
@@ -1339,6 +1339,10 @@ class Post < ApplicationRecord
|
|||||||
parent.add_favorite!(fav.user)
|
parent.add_favorite!(fav.user)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
unless options[:without_mod_action]
|
||||||
|
ModAction.log("moved favorites from post ##{id} to post ##{parent.id}",:post_move_favorites)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def parent_exists?
|
def parent_exists?
|
||||||
@@ -1413,7 +1417,7 @@ class Post < ApplicationRecord
|
|||||||
}, without_protection: true)
|
}, without_protection: true)
|
||||||
|
|
||||||
# XXX This must happen *after* the `is_deleted` flag is set to true (issue #3419).
|
# 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]
|
unless options[:without_mod_action]
|
||||||
ModAction.log("deleted post ##{id}, reason: #{reason}",:post_delete)
|
ModAction.log("deleted post ##{id}, reason: #{reason}",:post_delete)
|
||||||
|
|||||||
Reference in New Issue
Block a user