BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
69708dab
Commit
69708dab
authored
Aug 21, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Block blocked users from replying to threads by email.
parent
35224d5e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
0 deletions
+15
-0
email_receiver_worker.rb
app/workers/email_receiver_worker.rb
+2
-0
receiver.rb
lib/gitlab/email/receiver.rb
+3
-0
receiver_spec.rb
spec/lib/gitlab/email/receiver_spec.rb
+10
-0
No files found.
app/workers/email_receiver_worker.rb
View file @
69708dab
...
...
@@ -31,6 +31,8 @@ class EmailReceiverWorker
reason
=
"The email was marked as 'auto generated', which we can't accept. Please create your comment through the web interface."
when
Gitlab
::
Email
::
Receiver
::
UserNotFoundError
reason
=
"We couldn't figure out what user corresponds to the email. Please create your comment through the web interface."
when
Gitlab
::
Email
::
Receiver
::
UserBlockedError
reason
=
"Your account has been blocked. If you believe this is in error, contact a staff member."
when
Gitlab
::
Email
::
Receiver
::
UserNotAuthorizedError
reason
=
"You are not allowed to respond to the thread you are replying to. If you believe this is in error, contact a staff member."
when
Gitlab
::
Email
::
Receiver
::
NoteableNotFoundError
...
...
lib/gitlab/email/receiver.rb
View file @
69708dab
...
...
@@ -8,6 +8,7 @@ module Gitlab
class
EmptyEmailError
<
ProcessingError
;
end
class
AutoGeneratedEmailError
<
ProcessingError
;
end
class
UserNotFoundError
<
ProcessingError
;
end
class
UserBlockedError
<
ProcessingError
;
end
class
UserNotAuthorizedError
<
ProcessingError
;
end
class
NoteableNotFoundError
<
ProcessingError
;
end
class
InvalidNoteError
<
ProcessingError
;
end
...
...
@@ -27,6 +28,8 @@ module Gitlab
raise
UserNotFoundError
unless
author
raise
UserBlockedError
if
author
.
blocked?
project
=
sent_notification
.
project
raise
UserNotAuthorizedError
unless
project
&&
author
.
can?
(
:create_note
,
project
)
...
...
spec/lib/gitlab/email/receiver_spec.rb
View file @
69708dab
...
...
@@ -58,6 +58,16 @@ describe Gitlab::Email::Receiver do
end
end
context
"when the user has been blocked"
do
before
do
user
.
block
end
it
"raises a UserBlockedError"
do
expect
{
receiver
.
execute
}.
to
raise_error
(
Gitlab
::
Email
::
Receiver
::
UserBlockedError
)
end
end
context
"when the user is not authorized to create a note"
do
before
do
project
.
update_attribute
(
:visibility_level
,
Project
::
PRIVATE
)
...
...
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