Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
5fbb5d4f
Commit
5fbb5d4f
authored
Jan 29, 2020
by
charlieablett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move HamService into spam folder
Part of a general tidy of spam logic
parent
a796a807
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
31 deletions
+33
-31
app/controllers/admin/spam_logs_controller.rb
app/controllers/admin/spam_logs_controller.rb
+1
-1
app/services/ham_service.rb
app/services/ham_service.rb
+0
-30
app/services/spam/ham_service.rb
app/services/spam/ham_service.rb
+32
-0
No files found.
app/controllers/admin/spam_logs_controller.rb
View file @
5fbb5d4f
...
...
@@ -24,7 +24,7 @@ class Admin::SpamLogsController < Admin::ApplicationController
def
mark_as_ham
spam_log
=
SpamLog
.
find
(
params
[
:id
])
if
HamService
.
new
(
spam_log
).
mark_as_ham!
if
Spam
::
HamService
.
new
(
spam_log
).
mark_as_ham!
redirect_to
admin_spam_logs_path
,
notice:
_
(
'Spam log successfully submitted as ham.'
)
else
redirect_to
admin_spam_logs_path
,
alert:
_
(
'Error with Akismet. Please check the logs for more info.'
)
...
...
app/services/ham_service.rb
deleted
100644 → 0
View file @
a796a807
# frozen_string_literal: true
class
HamService
attr_accessor
:spam_log
def
initialize
(
spam_log
)
@spam_log
=
spam_log
end
def
mark_as_ham!
if
akismet
.
submit_ham
spam_log
.
update_attribute
(
:submitted_as_ham
,
true
)
else
false
end
end
private
def
akismet
user
=
spam_log
.
user
@akismet
||=
AkismetService
.
new
(
user
.
name
,
user
.
email
,
spam_log
.
text
,
ip_address:
spam_log
.
source_ip
,
user_agent:
spam_log
.
user_agent
)
end
end
app/services/spam/ham_service.rb
0 → 100644
View file @
5fbb5d4f
# frozen_string_literal: true
module
Spam
class
HamService
attr_accessor
:spam_log
def
initialize
(
spam_log
)
@spam_log
=
spam_log
end
def
mark_as_ham!
if
akismet
.
submit_ham
spam_log
.
update_attribute
(
:submitted_as_ham
,
true
)
else
false
end
end
private
def
akismet
user
=
spam_log
.
user
@akismet
||=
AkismetService
.
new
(
user
.
name
,
user
.
email
,
spam_log
.
text
,
ip_address:
spam_log
.
source_ip
,
user_agent:
spam_log
.
user_agent
)
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment