##// END OF EJS Templates
integrations: expose actor user_id, and username in webhook integration templates args....
marcink -
r1709:48d816ce default
parent child Browse files
Show More
@@ -24,7 +24,8 b' from rhodecode.lib.utils2 import Attribu'
24
24
25 # this is a user object to be used for events caused by the system (eg. shell)
25 # this is a user object to be used for events caused by the system (eg. shell)
26 SYSTEM_USER = AttributeDict(dict(
26 SYSTEM_USER = AttributeDict(dict(
27 username='__SYSTEM__'
27 username='__SYSTEM__',
28 user_id='__SYSTEM_ID__'
28 ))
29 ))
29
30
30 log = logging.getLogger(__name__)
31 log = logging.getLogger(__name__)
@@ -61,7 +62,8 b' class RhodecodeEvent(object):'
61 instance = auth_user.get_instance()
62 instance = auth_user.get_instance()
62 if not instance:
63 if not instance:
63 return AttributeDict(dict(
64 return AttributeDict(dict(
64 username=auth_user.username
65 username=auth_user.username,
66 user_id=auth_user.user_id,
65 ))
67 ))
66 return instance
68 return instance
67
69
@@ -93,7 +95,8 b' class RhodecodeEvent(object):'
93 'utc_timestamp': self.utc_timestamp,
95 'utc_timestamp': self.utc_timestamp,
94 'actor_ip': self.actor_ip,
96 'actor_ip': self.actor_ip,
95 'actor': {
97 'actor': {
96 'username': self.actor.username
98 'username': self.actor.username,
99 'user_id': self.actor.user_id
97 },
100 },
98 'server_url': self.server_url
101 'server_url': self.server_url
99 }
102 }
@@ -35,7 +35,7 b' from rhodecode.integrations.types.base i'
35
35
36 log = logging.getLogger(__name__)
36 log = logging.getLogger(__name__)
37
37
38 # updating this required to update the `base_vars` passed in url calling func
38 # updating this required to update the `common_vars` passed in url calling func
39 WEBHOOK_URL_VARS = [
39 WEBHOOK_URL_VARS = [
40 'repo_name',
40 'repo_name',
41 'repo_type',
41 'repo_type',
@@ -50,6 +50,10 b' WEBHOOK_URL_VARS = ['
50 'pull_request_id',
50 'pull_request_id',
51 'pull_request_url',
51 'pull_request_url',
52
52
53 # user who triggers the call
54 'username',
55 'user_id',
56
53 ]
57 ]
54 URL_VARS = ', '.join('${' + x + '}' for x in WEBHOOK_URL_VARS)
58 URL_VARS = ', '.join('${' + x + '}' for x in WEBHOOK_URL_VARS)
55
59
@@ -70,6 +74,8 b' class WebhookHandler(object):'
70 'repo_type': data['repo']['repo_type'],
74 'repo_type': data['repo']['repo_type'],
71 'repo_id': data['repo']['repo_id'],
75 'repo_id': data['repo']['repo_id'],
72 'repo_url': data['repo']['url'],
76 'repo_url': data['repo']['url'],
77 'username': data['actor']['username'],
78 'user_id': data['actor']['user_id']
73 }
79 }
74
80
75 return string.Template(
81 return string.Template(
@@ -32,7 +32,11 b' def base_data():'
32 'repo_name': 'foo',
32 'repo_name': 'foo',
33 'repo_type': 'hg',
33 'repo_type': 'hg',
34 'repo_id': '12',
34 'repo_id': '12',
35 'url': 'http://repo.url/foo'
35 'url': 'http://repo.url/foo',
36 },
37 'actor': {
38 'username': 'actor_name',
39 'user_id': 1
36 }
40 }
37 }
41 }
38
42
General Comments 0
You need to be logged in to leave comments. Login now