blob: 234c591ffb79e156cffc9fc2864f2ed5a6ad1132 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# frozen_string_literal: true
module SpammableActions::AkismetMarkAsSpamAction
extend ActiveSupport::Concern
include SpammableActions::Attributes
included do
before_action :authorize_submit_spammable!, only: :mark_as_spam
end
def mark_as_spam
if Spam::AkismetMarkAsSpamService.new(target: spammable).execute
redirect_to spammable_path, notice: _("%{spammable_titlecase} was submitted to Akismet successfully.") % { spammable_titlecase: spammable.spammable_entity_type.titlecase }
else
redirect_to spammable_path, alert: _('Error with Akismet. Please check the logs for more info.')
end
end
private
def authorize_submit_spammable!
access_denied! unless current_user.can_admin_all_resources?
end
def spammable_path
raise NotImplementedError, "#{self.class} does not implement #{__method__}"
end
end
|