spam_logs_controller.rb 827 Bytes
Newer Older
1 2
class Admin::SpamLogsController < Admin::ApplicationController
  def index
3
    @spam_logs = SpamLog.order(id: :desc).page(params[:page])
4 5 6
  end

  def destroy
7
    spam_log = SpamLog.find(params[:id])
8 9

    if params[:remove_user]
10
      spam_log.remove_user(deleted_by: current_user)
11 12 13
      redirect_to admin_spam_logs_path,
                  status: 302,
                  notice: "User #{spam_log.user.username} was successfully removed."
14 15
    else
      spam_log.destroy
16
      head :ok
17 18
    end
  end
19

20
  def mark_as_ham
21 22
    spam_log = SpamLog.find(params[:id])

23
    if HamService.new(spam_log).mark_as_ham!
24 25
      redirect_to admin_spam_logs_path, notice: 'Spam log successfully submitted as ham.'
    else
26
      redirect_to admin_spam_logs_path, alert: 'Error with Akismet. Please check the logs for more info.'
27
    end
28
  end
29
end