BURs: credit tag edits to DanbooruBot.

Credit tag edits that are performed as part of an alias, implication, or
mass update to DanbooruBot instead of the admin who approved the BUR.
This commit is contained in:
evazion
2019-12-06 22:54:08 -06:00
parent 620b81e7b9
commit 2bffad9311
4 changed files with 10 additions and 18 deletions

View File

@@ -156,7 +156,7 @@ private
tag_implication.reject!(update_topic: false)
when :mass_update
TagBatchChangeJob.perform_later(token[1], token[2], CurrentUser.user, CurrentUser.ip_addr)
TagBatchChangeJob.perform_later(token[1], token[2], User.system, "127.0.0.1")
when :change_category
tag = Tag.find_by_name(token[1])

View File

@@ -77,7 +77,7 @@ class BulkUpdateRequest < ApplicationRecord
transaction do
CurrentUser.scoped(approver) do
AliasAndImplicationImporter.new(script, forum_topic_id, "1", true).process!
update(status: "approved", approver: CurrentUser.user, skip_secondary_validations: true)
update!(status: "approved", approver: approver, skip_secondary_validations: true)
forum_updater.update("The #{bulk_update_request_link} (forum ##{forum_post.id}) has been approved by @#{approver.name}.", "APPROVED")
end
end

View File

@@ -56,15 +56,15 @@ class TagAlias < TagRelationship
tries = 0
begin
CurrentUser.scoped(approver) do
update(status: "processing")
CurrentUser.scoped(User.system) do
update!(status: "processing")
move_aliases_and_implications
move_saved_searches
ensure_category_consistency
update_posts
forum_updater.update(approval_message(approver), "APPROVED") if update_topic
rename_wiki_and_artist
update(status: "active")
update!(status: "active")
end
rescue Exception => e
if tries < 5
@@ -141,9 +141,7 @@ class TagAlias < TagRelationship
Post.raw_tag_match(antecedent_name).find_each do |post|
escaped_antecedent_name = Regexp.escape(antecedent_name)
fixed_tags = post.tag_string.sub(/(?:\A| )#{escaped_antecedent_name}(?:\Z| )/, " #{consequent_name} ").strip
CurrentUser.scoped(creator, "127.0.0.1") do
post.update(tag_string: fixed_tags)
end
post.update(tag_string: fixed_tags)
end
end
end
@@ -152,9 +150,7 @@ class TagAlias < TagRelationship
antecedent_wiki = WikiPage.titled(antecedent_name).first
if antecedent_wiki.present?
if WikiPage.titled(consequent_name).blank?
CurrentUser.scoped(creator, "127.0.0.1") do
antecedent_wiki.update(title: consequent_name, skip_secondary_validations: true)
end
antecedent_wiki.update!(title: consequent_name, skip_secondary_validations: true)
else
forum_updater.update(conflict_message)
end
@@ -162,9 +158,7 @@ class TagAlias < TagRelationship
if antecedent_tag.category == Tag.categories.artist
if antecedent_tag.artist.present? && consequent_tag.artist.blank?
CurrentUser.scoped(creator, "127.0.0.1") do
antecedent_tag.artist.update!(name: consequent_name)
end
antecedent_tag.artist.update!(name: consequent_name)
end
end
end

View File

@@ -134,7 +134,7 @@ class TagImplication < TagRelationship
tries = 0
begin
CurrentUser.scoped(approver) do
CurrentUser.scoped(User.system) do
update(status: "processing")
update_posts
update(status: "active")
@@ -159,9 +159,7 @@ class TagImplication < TagRelationship
Post.without_timeout do
Post.raw_tag_match(antecedent_name).where("true /* TagImplication#update_posts */").find_each do |post|
fixed_tags = "#{post.tag_string} #{descendant_names_string}".strip
CurrentUser.scoped(creator, "127.0.0.1") do
post.update(tag_string: fixed_tags)
end
post.update(tag_string: fixed_tags)
end
end
end