aliases/implications: log manual deletions by admins.

Log when an admin manually deletes an alias or implication outside of a
BUR. This is usually only necessary when a BUR is bugged.
This commit is contained in:
evazion
2021-09-06 00:21:00 -05:00
parent 28edd5a22a
commit 4dcfd1d141
8 changed files with 23 additions and 9 deletions

View File

@@ -46,8 +46,10 @@ class ModAction < ApplicationRecord
forum_post_delete: 102,
tag_alias_create: 120,
tag_alias_update: 121, # XXX unused
tag_alias_delete: 122,
tag_implication_create: 140,
tag_implication_update: 141, # XXX unused
tag_implication_delete: 142,
ip_ban_create: 160,
ip_ban_delete: 162,
ip_ban_undelete: 163,

View File

@@ -43,6 +43,6 @@ class TagAlias < TagRelationship
tag_relationships << TagAlias.active.find_by(antecedent_name: consequent_name, consequent_name: antecedent_name)
tag_relationships << TagImplication.active.find_by(antecedent_name: antecedent_name, consequent_name: consequent_name)
tag_relationships << TagImplication.active.find_by(antecedent_name: consequent_name, consequent_name: antecedent_name)
tag_relationships.each { |rel| rel.reject! if rel.present? }
tag_relationships.each { |rel| rel.reject!(User.system) if rel.present? }
end
end

View File

@@ -43,8 +43,16 @@ class TagRelationship < ApplicationRecord
status == "active"
end
def reject!
# Mark an alias or implication as deleted, and log a mod action if the
# deletion was manually performed by an admin, as opposed to automatically by
# DanbooruBot as part of a BUR.
def reject!(rejector = CurrentUser.user)
update!(status: "deleted")
if rejector != User.system
category = relationship == "tag alias" ? :tag_alias_delete : :tag_implication_delete
ModAction.log("deleted #{relationship} #{antecedent_name} -> #{consequent_name}", category, rejector)
end
end
module SearchMethods