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
78cee84a
Commit
78cee84a
authored
Jan 09, 2020
by
charlieablett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor Akismet service
- Takes serialisable string arguments instead of an object
parent
67e3add6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
9 deletions
+15
-9
app/services/akismet_service.rb
app/services/akismet_service.rb
+10
-7
app/services/ham_service.rb
app/services/ham_service.rb
+3
-1
app/services/spam_service.rb
app/services/spam_service.rb
+2
-1
No files found.
app/services/akismet_service.rb
View file @
78cee84a
# frozen_string_literal: true
# frozen_string_literal: true
class
AkismetService
class
AkismetService
attr_accessor
:
owner
,
:
text
,
:options
attr_accessor
:text
,
:options
def
initialize
(
owner
,
text
,
options
=
{})
def
initialize
(
owner_name
,
owner_email
,
text
,
options
=
{})
@owner
=
owner
@owner_name
=
owner_name
@owner_email
=
owner_email
@text
=
text
@text
=
text
@options
=
options
@options
=
options
end
end
...
@@ -16,8 +17,8 @@ class AkismetService
...
@@ -16,8 +17,8 @@ class AkismetService
type:
'comment'
,
type:
'comment'
,
text:
text
,
text:
text
,
created_at:
DateTime
.
now
,
created_at:
DateTime
.
now
,
author:
owner
.
name
,
author:
owner
_
name
,
author_email:
owner
.
email
,
author_email:
owner
_
email
,
referrer:
options
[
:referrer
]
referrer:
options
[
:referrer
]
}
}
...
@@ -40,6 +41,8 @@ class AkismetService
...
@@ -40,6 +41,8 @@ class AkismetService
private
private
attr_accessor
:owner_name
,
:owner_email
def
akismet_client
def
akismet_client
@akismet_client
||=
::
Akismet
::
Client
.
new
(
Gitlab
::
CurrentSettings
.
akismet_api_key
,
@akismet_client
||=
::
Akismet
::
Client
.
new
(
Gitlab
::
CurrentSettings
.
akismet_api_key
,
Gitlab
.
config
.
gitlab
.
url
)
Gitlab
.
config
.
gitlab
.
url
)
...
@@ -55,8 +58,8 @@ class AkismetService
...
@@ -55,8 +58,8 @@ class AkismetService
params
=
{
params
=
{
type:
'comment'
,
type:
'comment'
,
text:
text
,
text:
text
,
author:
owner
.
name
,
author:
owner
_
name
,
author_email:
owner
.
email
author_email:
owner
_
email
}
}
begin
begin
...
...
app/services/ham_service.rb
View file @
78cee84a
...
@@ -18,8 +18,10 @@ class HamService
...
@@ -18,8 +18,10 @@ class HamService
private
private
def
akismet
def
akismet
user
=
spam_log
.
user
@akismet
||=
AkismetService
.
new
(
@akismet
||=
AkismetService
.
new
(
spam_log
.
user
,
user
.
name
,
user
.
email
,
spam_log
.
text
,
spam_log
.
text
,
ip_address:
spam_log
.
source_ip
,
ip_address:
spam_log
.
source_ip
,
user_agent:
spam_log
.
user_agent
user_agent:
spam_log
.
user_agent
...
...
app/services/spam_service.rb
View file @
78cee84a
...
@@ -56,7 +56,8 @@ class SpamService
...
@@ -56,7 +56,8 @@ class SpamService
def
akismet
def
akismet
@akismet
||=
AkismetService
.
new
(
@akismet
||=
AkismetService
.
new
(
spammable_owner
,
spammable_owner
.
name
,
spammable_owner
.
email
,
spammable
.
spammable_text
,
spammable
.
spammable_text
,
options
options
)
)
...
...
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