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
ae4fbae2
Commit
ae4fbae2
authored
Oct 08, 2015
by
Jonathan Rochkind
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Send an email (to support) when a user is reported for spam
parent
0de7c83a
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
81 additions
and
1 deletion
+81
-1
app/controllers/abuse_reports_controller.rb
app/controllers/abuse_reports_controller.rb
+3
-0
app/controllers/admin/application_settings_controller.rb
app/controllers/admin/application_settings_controller.rb
+1
-0
app/mailers/abuse_report_mailer.rb
app/mailers/abuse_report_mailer.rb
+8
-0
app/views/abuse_report_mailer/notify.text.haml
app/views/abuse_report_mailer/notify.text.haml
+5
-0
app/views/admin/application_settings/_form.html.haml
app/views/admin/application_settings/_form.html.haml
+4
-0
db/migrate/20151008143519_add_admin_notification_email_setting.rb
...te/20151008143519_add_admin_notification_email_setting.rb
+5
-0
db/schema.rb
db/schema.rb
+2
-1
spec/controllers/abuse_reports_controller_spec.rb
spec/controllers/abuse_reports_controller_spec.rb
+53
-0
No files found.
app/controllers/abuse_reports_controller.rb
View file @
ae4fbae2
...
@@ -11,6 +11,9 @@ class AbuseReportsController < ApplicationController
...
@@ -11,6 +11,9 @@ class AbuseReportsController < ApplicationController
if
@abuse_report
.
save
if
@abuse_report
.
save
message
=
"Thank you for your report. A GitLab administrator will look into it shortly."
message
=
"Thank you for your report. A GitLab administrator will look into it shortly."
redirect_to
root_path
,
notice:
message
redirect_to
root_path
,
notice:
message
if
current_application_settings
.
admin_notification_email
.
present?
AbuseReportMailer
.
delay
.
notify
(
@abuse_report
,
current_application_settings
.
admin_notification_email
)
end
else
else
render
:new
render
:new
end
end
...
...
app/controllers/admin/application_settings_controller.rb
View file @
ae4fbae2
...
@@ -55,6 +55,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
...
@@ -55,6 +55,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
:default_snippet_visibility
,
:default_snippet_visibility
,
:restricted_signup_domains_raw
,
:restricted_signup_domains_raw
,
:version_check_enabled
,
:version_check_enabled
,
:admin_notification_email
,
:user_oauth_applications
,
:user_oauth_applications
,
:ci_enabled
,
:ci_enabled
,
restricted_visibility_levels:
[],
restricted_visibility_levels:
[],
...
...
app/mailers/abuse_report_mailer.rb
0 → 100644
View file @
ae4fbae2
class
AbuseReportMailer
<
BaseMailer
def
notify
(
abuse_report
,
to_email
)
@abuse_report
=
abuse_report
mail
(
to:
to_email
,
subject:
"[Gitlab] Abuse report filed for `
#{
@abuse_report
.
user
.
username
}
`"
)
end
end
app/views/abuse_report_mailer/notify.text.haml
0 → 100644
View file @
ae4fbae2
An abuse report was filed on `
#{
@abuse_report
.
user
.
username
}
` by `
#{
@abuse_report
.
reporter
.
username
}
`.
\
=
@abuse_report
.
message
\
Abuse report admin screen:
#{
abuse_reports_url
}
\ No newline at end of file
app/views/admin/application_settings/_form.html.haml
View file @
ae4fbae2
...
@@ -47,6 +47,10 @@
...
@@ -47,6 +47,10 @@
=
f
.
label
:version_check_enabled
do
=
f
.
label
:version_check_enabled
do
=
f
.
check_box
:version_check_enabled
=
f
.
check_box
:version_check_enabled
Version check enabled
Version check enabled
.form-group
=
f
.
label
:admin_notification_email
,
class:
'control-label col-sm-2'
.col-sm-10
=
f
.
text_field
:admin_notification_email
,
class:
'form-control'
%fieldset
%fieldset
%legend
Account and Limit Settings
%legend
Account and Limit Settings
...
...
db/migrate/20151008143519_add_admin_notification_email_setting.rb
0 → 100644
View file @
ae4fbae2
class
AddAdminNotificationEmailSetting
<
ActiveRecord
::
Migration
def
change
add_column
:application_settings
,
:admin_notification_email
,
:string
end
end
db/schema.rb
View file @
ae4fbae2
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#
#
# It's strongly recommended that you check this file into your version control system.
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
2015
0930095736
)
do
ActiveRecord
::
Schema
.
define
(
version:
2015
1008143519
)
do
# These are extensions that must be enabled in order to support this database
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
enable_extension
"plpgsql"
...
@@ -47,6 +47,7 @@ ActiveRecord::Schema.define(version: 20150930095736) do
...
@@ -47,6 +47,7 @@ ActiveRecord::Schema.define(version: 20150930095736) do
t
.
text
"import_sources"
t
.
text
"import_sources"
t
.
text
"help_page_text"
t
.
text
"help_page_text"
t
.
boolean
"ci_enabled"
,
default:
true
,
null:
false
t
.
boolean
"ci_enabled"
,
default:
true
,
null:
false
t
.
string
"admin_notification_email"
end
end
create_table
"audit_events"
,
force:
true
do
|
t
|
create_table
"audit_events"
,
force:
true
do
|
t
|
...
...
spec/controllers/abuse_reports_controller_spec.rb
0 → 100644
View file @
ae4fbae2
require
'spec_helper'
describe
AbuseReportsController
do
let
(
:reporter
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:message
)
{
"This user is a spammer"
}
before
do
sign_in
(
reporter
)
end
describe
"with admin notification_email set"
do
let
(
:admin_email
)
{
"admin@example.com"
}
before
(
:example
)
{
allow
(
current_application_settings
).
to
receive
(
:admin_notification_email
).
and_return
(
admin_email
)
}
it
"sends a notification email"
do
post
(
:create
,
abuse_report:
{
user_id:
user
.
id
,
message:
message
}
)
expect
(
response
).
to
have_http_status
(
:redirect
)
expect
(
flash
[
:notice
]).
to
start_with
(
"Thank you for your report"
)
email
=
ActionMailer
::
Base
.
deliveries
.
last
expect
(
email
).
to
be_present
expect
(
email
.
subject
).
to
eq
(
"[Gitlab] Abuse report filed for `
#{
user
.
username
}
`"
)
expect
(
email
.
to
).
to
eq
([
admin_email
])
expect
(
email
.
body
).
to
include
(
message
)
end
end
describe
"without admin notification email set"
do
before
(
:example
)
{
allow
(
current_application_settings
).
to
receive
(
:admin_notification_email
).
and_return
(
nil
)
}
it
"does not send a notification email"
do
expect
do
post
(
:create
,
abuse_report:
{
user_id:
user
.
id
,
message:
message
}
)
end
.
to_not
change
{
ActionMailer
::
Base
.
deliveries
}
expect
(
response
).
to
have_http_status
(
:redirect
)
expect
(
flash
[
:notice
]).
to
start_with
(
"Thank you for your report"
)
end
end
end
\ No newline at end of file
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