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
Jérome Perrin
gitlab-ce
Commits
521a0a20
Commit
521a0a20
authored
Jun 20, 2016
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow reply-by-email with diff notes
parent
710c4886
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
10 deletions
+51
-10
app/models/sent_notification.rb
app/models/sent_notification.rb
+28
-1
db/migrate/20160522215720_add_note_type_and_position_to_sent_notification.rb
...215720_add_note_type_and_position_to_sent_notification.rb
+22
-0
lib/gitlab/email/receiver.rb
lib/gitlab/email/receiver.rb
+1
-9
No files found.
app/models/sent_notification.rb
View file @
521a0a20
class
SentNotification
<
ActiveRecord
::
Base
class
SentNotification
<
ActiveRecord
::
Base
serialize
:position
,
Gitlab
::
Diff
::
Position
belongs_to
:project
belongs_to
:project
belongs_to
:noteable
,
polymorphic:
true
belongs_to
:noteable
,
polymorphic:
true
belongs_to
:recipient
,
class_name:
"User"
belongs_to
:recipient
,
class_name:
"User"
...
@@ -7,7 +9,7 @@ class SentNotification < ActiveRecord::Base
...
@@ -7,7 +9,7 @@ class SentNotification < ActiveRecord::Base
validates
:reply_key
,
uniqueness:
true
validates
:reply_key
,
uniqueness:
true
validates
:noteable_id
,
presence:
true
,
unless: :for_commit?
validates
:noteable_id
,
presence:
true
,
unless: :for_commit?
validates
:commit_id
,
presence:
true
,
if: :for_commit?
validates
:commit_id
,
presence:
true
,
if: :for_commit?
validate
s
:line_code
,
line_code:
true
,
allow_blank:
true
validate
:note_valid
after_save
:keep_around_commit
after_save
:keep_around_commit
...
@@ -74,8 +76,33 @@ class SentNotification < ActiveRecord::Base
...
@@ -74,8 +76,33 @@ class SentNotification < ActiveRecord::Base
self
.
reply_key
self
.
reply_key
end
end
def
note_attributes
{
project:
self
.
project
,
author:
self
.
recipient
,
type:
self
.
note_type
,
noteable_type:
self
.
noteable_type
,
noteable_id:
self
.
noteable_id
,
commit_id:
self
.
commit_id
,
line_code:
self
.
line_code
,
position:
self
.
position
.
to_json
}
end
def
create_note
(
note
)
Notes
::
CreateService
.
new
(
self
.
project
,
self
.
recipient
,
self
.
note_attributes
.
merge
(
note:
note
)
).
execute
end
private
private
def
note_valid
Note
.
new
(
note_attributes
.
merge
(
note:
"Test"
)).
valid?
end
def
keep_around_commit
def
keep_around_commit
project
.
repository
.
keep_around
(
self
.
commit_id
)
project
.
repository
.
keep_around
(
self
.
commit_id
)
end
end
...
...
db/migrate/20160522215720_add_note_type_and_position_to_sent_notification.rb
0 → 100644
View file @
521a0a20
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
AddNoteTypeAndPositionToSentNotification
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
# When using the methods "add_concurrent_index" or "add_column_with_default"
# you must disable the use of transactions as these methods can not run in an
# existing transaction. When using "add_concurrent_index" make sure that this
# method is the _only_ method called in the migration, any other changes
# should go in a separate migration. This ensures that upon failure _only_ the
# index creation fails and can be retried or reverted easily.
#
# To disable transactions uncomment the following line and remove these
# comments:
# disable_ddl_transaction!
def
change
add_column
:sent_notifications
,
:note_type
,
:string
add_column
:sent_notifications
,
:position
,
:text
end
end
lib/gitlab/email/receiver.rb
View file @
521a0a20
...
@@ -104,15 +104,7 @@ module Gitlab
...
@@ -104,15 +104,7 @@ module Gitlab
end
end
def
create_note
(
reply
)
def
create_note
(
reply
)
Notes
::
CreateService
.
new
(
sent_notification
.
create_note
(
reply
)
sent_notification
.
project
,
sent_notification
.
recipient
,
note:
reply
,
noteable_type:
sent_notification
.
noteable_type
,
noteable_id:
sent_notification
.
noteable_id
,
commit_id:
sent_notification
.
commit_id
,
line_code:
sent_notification
.
line_code
).
execute
end
end
end
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