BigW Consortium Gitlab

spam_logs_controller.rb 752 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 11 12 13
      spam_log.remove_user
      redirect_to admin_spam_logs_path, notice: "User #{spam_log.user.username} was successfully removed."
    else
      spam_log.destroy
14
      head :ok
15 16
    end
  end
17

18
  def mark_as_ham
19 20
    spam_log = SpamLog.find(params[:id])

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