Commit 038cd1ab authored by Rémy Coutable's avatar Rémy Coutable Committed by Markus Koller

Include the user id in the webhook payload

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 1c8deba0
......@@ -1358,6 +1358,7 @@ class User < ApplicationRecord
def hook_attrs
{
id: id,
name: name,
username: username,
avatar_url: avatar_url(only_path: false),
......
---
title: Include the user id in the webhook payload
merge_request: 50287
author:
type: added
......@@ -535,9 +535,11 @@ X-Gitlab-Event: System Hook
{
"object_kind": "merge_request",
"user": {
"id": 1,
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon"
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"email": "admin@example.com"
},
"project": {
"name": "Example",
......
......@@ -257,6 +257,7 @@ X-Gitlab-Event: Issue Hook
"object_kind": "issue",
"event_type": "issue",
"user": {
"id": 1,
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon",
......@@ -420,9 +421,11 @@ X-Gitlab-Event: Note Hook
{
"object_kind": "note",
"user": {
"id": 1,
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon"
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon",
"email": "admin@example.com"
},
"project_id": 5,
"project":{
......@@ -500,9 +503,11 @@ X-Gitlab-Event: Note Hook
{
"object_kind": "note",
"user": {
"id": 1,
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon"
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon",
"email": "admin@example.com"
},
"project_id": 5,
"project":{
......@@ -627,9 +632,11 @@ X-Gitlab-Event: Note Hook
{
"object_kind": "note",
"user": {
"id": 1,
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon"
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon",
"email": "admin@example.com"
},
"project_id": 5,
"project":{
......@@ -733,9 +740,11 @@ X-Gitlab-Event: Note Hook
{
"object_kind": "note",
"user": {
"id": 1,
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon"
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon",
"email": "admin@example.com"
},
"project_id": 5,
"project":{
......@@ -809,9 +818,11 @@ X-Gitlab-Event: Merge Request Hook
{
"object_kind": "merge_request",
"user": {
"id": 1,
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon"
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon",
"email": "admin@example.com"
},
"project": {
"id": 1,
......@@ -970,9 +981,11 @@ X-Gitlab-Event: Wiki Page Hook
{
"object_kind": "wiki_page",
"user": {
"id": 1,
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon"
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon",
"email": "admin@example.com"
},
"project": {
"id": 1,
......@@ -1061,6 +1074,7 @@ X-Gitlab-Event: Pipeline Hook
"url": "http://192.168.64.1:3005/gitlab-org/gitlab-test/merge_requests/1"
},
"user":{
"id": 1,
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon",
......@@ -1102,9 +1116,11 @@ X-Gitlab-Event: Pipeline Hook
"manual": true,
"allow_failure": false,
"user":{
"id": 1,
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon"
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon",
"email": "admin@example.com"
},
"runner": null,
"artifacts_file":{
......@@ -1124,9 +1140,11 @@ X-Gitlab-Event: Pipeline Hook
"manual": false,
"allow_failure": false,
"user":{
"id": 1,
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon"
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon",
"email": "admin@example.com"
},
"runner": {
"id":380987,
......@@ -1151,9 +1169,11 @@ X-Gitlab-Event: Pipeline Hook
"manual": false,
"allow_failure": false,
"user":{
"id": 1,
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon"
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon",
"email": "admin@example.com"
},
"runner": {
"id":380987,
......@@ -1178,9 +1198,11 @@ X-Gitlab-Event: Pipeline Hook
"manual": false,
"allow_failure": false,
"user":{
"id": 1,
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon"
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon",
"email": "admin@example.com"
},
"runner": {
"id":380987,
......@@ -1205,9 +1227,11 @@ X-Gitlab-Event: Pipeline Hook
"manual": false,
"allow_failure": false,
"user":{
"id": 1,
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon"
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon",
"email": "admin@example.com"
},
"runner": null,
"artifacts_file":{
......@@ -1254,7 +1278,8 @@ X-Gitlab-Event: Job Hook
"id": 3,
"name": "User",
"email": "user@gitlab.com",
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon"
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon",
"email": "admin@example.com"
},
"commit": {
"id": 2366,
......@@ -1330,6 +1355,7 @@ X-Gitlab-Event: Deployment Hook
},
"short_sha": "279484c0",
"user": {
"id": 1,
"name": "Administrator",
"username": "root",
"avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
......@@ -1472,6 +1498,7 @@ X-Gitlab-Event: Feature Flag Hook
"http_url":"http://example.com/gitlabhq/gitlab-test.git"
},
"user": {
"id": 1,
"name": "Administrator",
"username": "root",
"avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
......
......@@ -26,6 +26,7 @@ RSpec.describe Gitlab::DataBuilder::Build do
it {
expect(data[:user]).to eq(
{
id: user.id,
name: user.name,
username: user.username,
avatar_url: user.avatar_url(only_path: false),
......
......@@ -41,6 +41,7 @@ RSpec.describe Gitlab::DataBuilder::Pipeline do
expect(project_data).to eq(project.hook_attrs(backward: false))
expect(data[:merge_request]).to be_nil
expect(data[:user]).to eq({
id: user.id,
name: user.name,
username: user.username,
avatar_url: user.avatar_url(only_path: false),
......
......@@ -5089,9 +5089,10 @@ RSpec.describe User do
end
describe '#hook_attrs' do
it 'includes name, username, avatar_url, and email' do
it 'includes id, name, username, avatar_url, and email' do
user = create(:user)
user_attributes = {
id: user.id,
name: user.name,
username: user.username,
avatar_url: user.avatar_url(only_path: false),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment