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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
5c6b21f1
Commit
5c6b21f1
authored
Nov 05, 2014
by
Valeriy Sizov
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7967 from Bugagazavr/issue-actor
Add issueable actor to hooks
parents
652f4c80
11848feb
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
25 additions
and
4 deletions
+25
-4
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+2
-1
app/models/user.rb
app/models/user.rb
+8
-0
app/services/issues/base_service.rb
app/services/issues/base_service.rb
+1
-1
app/services/merge_requests/base_merge_service.rb
app/services/merge_requests/base_merge_service.rb
+2
-1
app/services/merge_requests/base_service.rb
app/services/merge_requests/base_service.rb
+2
-1
doc/web_hooks/web_hooks.md
doc/web_hooks/web_hooks.md
+10
-0
No files found.
app/models/concerns/issuable.rb
View file @
5c6b21f1
...
@@ -131,9 +131,10 @@ module Issuable
...
@@ -131,9 +131,10 @@ module Issuable
users
.
concat
(
mentions
.
reduce
([],
:|
)).
uniq
users
.
concat
(
mentions
.
reduce
([],
:|
)).
uniq
end
end
def
to_hook_data
def
to_hook_data
(
user
)
{
{
object_kind:
self
.
class
.
name
.
underscore
,
object_kind:
self
.
class
.
name
.
underscore
,
user:
user
.
hook_attrs
,
object_attributes:
hook_attrs
object_attributes:
hook_attrs
}
}
end
end
...
...
app/models/user.rb
View file @
5c6b21f1
...
@@ -498,6 +498,14 @@ class User < ActiveRecord::Base
...
@@ -498,6 +498,14 @@ class User < ActiveRecord::Base
end
end
end
end
def
hook_attrs
{
name:
name
,
username:
username
,
avatar_url:
avatar_url
}
end
def
ensure_namespace_correct
def
ensure_namespace_correct
# Ensure user has namespace
# Ensure user has namespace
self
.
create_namespace!
(
path:
self
.
username
,
name:
self
.
username
)
unless
self
.
namespace
self
.
create_namespace!
(
path:
self
.
username
,
name:
self
.
username
)
unless
self
.
namespace
...
...
app/services/issues/base_service.rb
View file @
5c6b21f1
...
@@ -4,7 +4,7 @@ module Issues
...
@@ -4,7 +4,7 @@ module Issues
private
private
def
execute_hooks
(
issue
,
action
=
'open'
)
def
execute_hooks
(
issue
,
action
=
'open'
)
issue_data
=
issue
.
to_hook_data
issue_data
=
issue
.
to_hook_data
(
current_user
)
issue_url
=
Gitlab
::
UrlBuilder
.
new
(
:issue
).
build
(
issue
.
id
)
issue_url
=
Gitlab
::
UrlBuilder
.
new
(
:issue
).
build
(
issue
.
id
)
issue_data
[
:object_attributes
].
merge!
(
url:
issue_url
,
action:
action
)
issue_data
[
:object_attributes
].
merge!
(
url:
issue_url
,
action:
action
)
issue
.
project
.
execute_hooks
(
issue_data
,
:issue_hooks
)
issue
.
project
.
execute_hooks
(
issue_data
,
:issue_hooks
)
...
...
app/services/merge_requests/base_merge_service.rb
View file @
5c6b21f1
...
@@ -13,7 +13,8 @@ module MergeRequests
...
@@ -13,7 +13,8 @@ module MergeRequests
def
execute_project_hooks
(
merge_request
)
def
execute_project_hooks
(
merge_request
)
if
merge_request
.
project
if
merge_request
.
project
merge_request
.
project
.
execute_hooks
(
merge_request
.
to_hook_data
,
:merge_request_hooks
)
hook_data
=
merge_request
.
to_hook_data
(
current_user
)
merge_request
.
project
.
execute_hooks
(
hook_data
,
:merge_request_hooks
)
end
end
end
end
end
end
...
...
app/services/merge_requests/base_service.rb
View file @
5c6b21f1
...
@@ -7,7 +7,8 @@ module MergeRequests
...
@@ -7,7 +7,8 @@ module MergeRequests
def
execute_hooks
(
merge_request
)
def
execute_hooks
(
merge_request
)
if
merge_request
.
project
if
merge_request
.
project
merge_request
.
project
.
execute_hooks
(
merge_request
.
to_hook_data
,
:merge_request_hooks
)
hook_data
=
merge_request
.
to_hook_data
(
current_user
)
merge_request
.
project
.
execute_hooks
(
hook_data
,
:merge_request_hooks
)
end
end
end
end
end
end
...
...
doc/web_hooks/web_hooks.md
View file @
5c6b21f1
...
@@ -63,6 +63,11 @@ Triggered when a new issue is created or an existing issue was updated/closed/re
...
@@ -63,6 +63,11 @@ Triggered when a new issue is created or an existing issue was updated/closed/re
```
json
```
json
{
{
"object_kind"
:
"issue"
,
"object_kind"
:
"issue"
,
"user"
:
{
"name"
:
"Administrator"
,
"username"
:
"root"
,
"avatar_url"
:
"http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40
\u
0026d=identicon"
},
"object_attributes"
:
{
"object_attributes"
:
{
"id"
:
301
,
"id"
:
301
,
"title"
:
"New API: create/update/delete file"
,
"title"
:
"New API: create/update/delete file"
,
...
@@ -92,6 +97,11 @@ Triggered when a new merge request is created or an existing merge request was u
...
@@ -92,6 +97,11 @@ Triggered when a new merge request is created or an existing merge request was u
```
json
```
json
{
{
"object_kind"
:
"merge_request"
,
"object_kind"
:
"merge_request"
,
"user"
:
{
"name"
:
"Administrator"
,
"username"
:
"root"
,
"avatar_url"
:
"http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40
\u
0026d=identicon"
},
"object_attributes"
:
{
"object_attributes"
:
{
"id"
:
99
,
"id"
:
99
,
"target_branch"
:
"master"
,
"target_branch"
:
"master"
,
...
...
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