mirror of
https://ghfast.top/https://github.com/discourse/discourse-akismet.git
synced 2026-07-16 11:46:29 +08:00
* FIX: Submit feedback in every case and avoid a race condition when submitting feedback/deleting an user * Update spec/models/reviewable_akismet_user_spec.rb Co-Authored-By: Robin Ward <robin.ward@gmail.com> * Update spec/models/reviewable_akismet_post_spec.rb Co-Authored-By: Robin Ward <robin.ward@gmail.com>
22 lines
613 B
Ruby
22 lines
613 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Jobs
|
|
class UpdateAkismetStatus < Jobs::Base
|
|
def execute(args)
|
|
return unless SiteSetting.akismet_enabled?
|
|
|
|
akismet_feedback = args[:feedback]
|
|
status = args[:status]
|
|
raise Discourse::InvalidParameters.new(:feedback) unless akismet_feedback
|
|
raise Discourse::InvalidParameters.new(:status) unless status
|
|
|
|
DiscourseAkismet.with_client do |client|
|
|
if status == 'ham'
|
|
client.submit_ham(akismet_feedback)
|
|
elsif status == 'spam'
|
|
client.submit_spam(akismet_feedback)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|