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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
e2615799
Commit
e2615799
authored
Sep 20, 2016
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'rs-dry-akismet-service' into 'master'
Reduce duplication in AkismetService See merge request !6362
parents
667d2350
d834ee2c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
27 deletions
+16
-27
app/services/akismet_service.rb
app/services/akismet_service.rb
+16
-27
No files found.
app/services/akismet_service.rb
View file @
e2615799
...
@@ -29,25 +29,25 @@ class AkismetService
...
@@ -29,25 +29,25 @@ class AkismetService
end
end
def
submit_ham
def
submit_ham
return
false
unless
akismet_enabled?
submit
(
:ham
)
end
params
=
{
def
submit_spam
type:
'comment'
,
submit
(
:spam
)
text:
text
,
end
author:
owner
.
name
,
author_email:
owner
.
email
}
begin
private
akismet_client
.
submit_ham
(
options
[
:ip_address
],
options
[
:user_agent
],
params
)
true
def
akismet_client
rescue
=>
e
@akismet_client
||=
::
Akismet
::
Client
.
new
(
current_application_settings
.
akismet_api_key
,
Rails
.
logger
.
error
(
"Unable to connect to Akismet:
#{
e
}
, skipping!"
)
Gitlab
.
config
.
gitlab
.
url
)
false
end
end
def
akismet_enabled?
current_application_settings
.
akismet_enabled
end
end
def
submit
_spam
def
submit
(
type
)
return
false
unless
akismet_enabled?
return
false
unless
akismet_enabled?
params
=
{
params
=
{
...
@@ -58,22 +58,11 @@ class AkismetService
...
@@ -58,22 +58,11 @@ class AkismetService
}
}
begin
begin
akismet_client
.
submit_spam
(
options
[
:ip_address
],
options
[
:user_agent
],
params
)
akismet_client
.
public_send
(
type
,
options
[
:ip_address
],
options
[
:user_agent
],
params
)
true
true
rescue
=>
e
rescue
=>
e
Rails
.
logger
.
error
(
"Unable to connect to Akismet:
#{
e
}
, skipping!"
)
Rails
.
logger
.
error
(
"Unable to connect to Akismet:
#{
e
}
, skipping!"
)
false
false
end
end
end
end
private
def
akismet_client
@akismet_client
||=
::
Akismet
::
Client
.
new
(
current_application_settings
.
akismet_api_key
,
Gitlab
.
config
.
gitlab
.
url
)
end
def
akismet_enabled?
current_application_settings
.
akismet_enabled
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