2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-04-02 18:10:28 +05:30
|
|
|
class Admin::SpamLogsController < Admin::ApplicationController
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2016-04-02 18:10:28 +05:30
|
|
|
def index
|
|
|
|
@spam_logs = SpamLog.order(id: :desc).page(params[:page])
|
|
|
|
end
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2016-04-02 18:10:28 +05:30
|
|
|
|
|
|
|
def destroy
|
|
|
|
spam_log = SpamLog.find(params[:id])
|
|
|
|
|
|
|
|
if params[:remove_user]
|
2017-08-17 22:00:37 +05:30
|
|
|
spam_log.remove_user(deleted_by: current_user)
|
2017-09-10 17:25:29 +05:30
|
|
|
redirect_to admin_spam_logs_path,
|
2019-12-26 22:10:19 +05:30
|
|
|
status: :found,
|
2019-07-07 11:18:12 +05:30
|
|
|
notice: _('User %{username} was successfully removed.') % { username: spam_log.user.username }
|
2016-04-02 18:10:28 +05:30
|
|
|
else
|
|
|
|
spam_log.destroy
|
2016-06-02 11:05:42 +05:30
|
|
|
head :ok
|
2016-04-02 18:10:28 +05:30
|
|
|
end
|
|
|
|
end
|
2016-09-13 17:45:13 +05:30
|
|
|
|
|
|
|
def mark_as_ham
|
|
|
|
spam_log = SpamLog.find(params[:id])
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
if Spam::HamService.new(spam_log).execute
|
2019-07-07 11:18:12 +05:30
|
|
|
redirect_to admin_spam_logs_path, notice: _('Spam log successfully submitted as ham.')
|
2016-09-13 17:45:13 +05:30
|
|
|
else
|
2019-07-07 11:18:12 +05:30
|
|
|
redirect_to admin_spam_logs_path, alert: _('Error with Akismet. Please check the logs for more info.')
|
2016-09-13 17:45:13 +05:30
|
|
|
end
|
|
|
|
end
|
2016-04-02 18:10:28 +05:30
|
|
|
end
|