discourse-akismet/jobs/regular/check_akismet_post_voting_comment.rb
Juan David Martínez Cubillos 664cc3f828
FEATURE: Implement Akismet flag and review system for PostVotingComments (#112)
* FEATURE: Implement Akismet flag and review system for PostVotingComments

* polished bugs and completed reviewables implementation

* adding test plugin dependecies

* rubocop fix

* syntax tree fix

* deleted comments

* added requested changes

* linter fixes

* refactored #before_check in post voting bouncer
2024-01-11 16:04:57 -05:00

21 lines
710 B
Ruby

# frozen_string_literal: true
module Jobs
class CheckAkismetPostVotingComment < ::Jobs::Base
def execute(args)
return if !SiteSetting.akismet_enabled?
return if !(comment = PostVotingComment.find_by(id: args[:comment_id]))
return if Reviewable.exists?(target: comment)
DistributedMutex.synchronize("akismet_post_voting_comment_#{comment.id}") do
if comment.custom_fields[DiscourseAkismet::Bouncer::AKISMET_STATE] ==
DiscourseAkismet::Bouncer::PENDING_STATE
DiscourseAkismet::PostVotingCommentsBouncer.new.perform_check(
DiscourseAkismet::AntiSpamService.client,
comment,
)
end
end
end
end
end