##// 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 25 # this is a user object to be used for events caused by the system (eg. shell)
26 26 SYSTEM_USER = AttributeDict(dict(
27 username='__SYSTEM__'
27 username='__SYSTEM__',
28 user_id='__SYSTEM_ID__'
28 29 ))
29 30
30 31 log = logging.getLogger(__name__)
@@ -61,7 +62,8 b' class RhodecodeEvent(object):'
61 62 instance = auth_user.get_instance()
62 63 if not instance:
63 64 return AttributeDict(dict(
64 username=auth_user.username
65 username=auth_user.username,
66 user_id=auth_user.user_id,
65 67 ))
66 68 return instance
67 69
@@ -93,7 +95,8 b' class RhodecodeEvent(object):'
93 95 'utc_timestamp': self.utc_timestamp,
94 96 'actor_ip': self.actor_ip,
95 97 'actor': {
96 'username': self.actor.username
98 'username': self.actor.username,
99 'user_id': self.actor.user_id
97 100 },
98 101 'server_url': self.server_url
99 102 }
@@ -35,7 +35,7 b' from rhodecode.integrations.types.base i'
35 35
36 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 39 WEBHOOK_URL_VARS = [
40 40 'repo_name',
41 41 'repo_type',
@@ -50,6 +50,10 b' WEBHOOK_URL_VARS = ['
50 50 'pull_request_id',
51 51 'pull_request_url',
52 52
53 # user who triggers the call
54 'username',
55 'user_id',
56
53 57 ]
54 58 URL_VARS = ', '.join('${' + x + '}' for x in WEBHOOK_URL_VARS)
55 59
@@ -70,6 +74,8 b' class WebhookHandler(object):'
70 74 'repo_type': data['repo']['repo_type'],
71 75 'repo_id': data['repo']['repo_id'],
72 76 'repo_url': data['repo']['url'],
77 'username': data['actor']['username'],
78 'user_id': data['actor']['user_id']
73 79 }
74 80
75 81 return string.Template(
@@ -32,7 +32,11 b' def base_data():'
32 32 'repo_name': 'foo',
33 33 'repo_type': 'hg',
34 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