##// END OF EJS Templates
channelstream: push events with comments on single commits....
marcink -
r1970:ef3d81a8 default
parent child Browse files
Show More
@@ -228,6 +228,7 b' def post_message(channel, message, usern'
228 if not registry:
228 if not registry:
229 registry = get_current_registry()
229 registry = get_current_registry()
230
230
231 log.debug('Channelstream: sending notification to channel %s', channel)
231 rhodecode_plugins = getattr(registry, 'rhodecode_plugins', {})
232 rhodecode_plugins = getattr(registry, 'rhodecode_plugins', {})
232 channelstream_config = rhodecode_plugins.get('channelstream', {})
233 channelstream_config = rhodecode_plugins.get('channelstream', {})
233 if channelstream_config.get('enabled'):
234 if channelstream_config.get('enabled'):
@@ -33,7 +33,7 b' from pyramid.threadlocal import get_curr'
33 from sqlalchemy.sql.expression import null
33 from sqlalchemy.sql.expression import null
34 from sqlalchemy.sql.functions import coalesce
34 from sqlalchemy.sql.functions import coalesce
35
35
36 from rhodecode.lib import helpers as h, diffs
36 from rhodecode.lib import helpers as h, diffs, channelstream
37 from rhodecode.lib import audit_logger
37 from rhodecode.lib import audit_logger
38 from rhodecode.lib.channelstream import channelstream_request
38 from rhodecode.lib.channelstream import channelstream_request
39 from rhodecode.lib.utils2 import extract_mentioned_users, safe_str
39 from rhodecode.lib.utils2 import extract_mentioned_users, safe_str
@@ -354,43 +354,34 b' class CommentsModel(BaseModel):'
354 self._log_audit_action(
354 self._log_audit_action(
355 action, {'data': comment_data}, user, comment)
355 action, {'data': comment_data}, user, comment)
356
356
357 registry = get_current_registry()
358 rhodecode_plugins = getattr(registry, 'rhodecode_plugins', {})
359 channelstream_config = rhodecode_plugins.get('channelstream', {})
360 msg_url = ''
357 msg_url = ''
358 channel = None
361 if commit_obj:
359 if commit_obj:
362 msg_url = commit_comment_url
360 msg_url = commit_comment_url
363 repo_name = repo.repo_name
361 repo_name = repo.repo_name
362 channel = u'/repo${}$/commit/{}'.format(
363 repo_name,
364 commit_obj.raw_id
365 )
364 elif pull_request_obj:
366 elif pull_request_obj:
365 msg_url = pr_comment_url
367 msg_url = pr_comment_url
366 repo_name = pr_target_repo.repo_name
368 repo_name = pr_target_repo.repo_name
367
369 channel = u'/repo${}$/pr/{}'.format(
368 if channelstream_config.get('enabled'):
369 message = '<strong>{}</strong> {} - ' \
370 '<a onclick="window.location=\'{}\';' \
371 'window.location.reload()">' \
372 '<strong>{}</strong></a>'
373 message = message.format(
374 user.username, _('made a comment'), msg_url,
375 _('Show it now'))
376 channel = '/repo${}$/pr/{}'.format(
377 repo_name,
370 repo_name,
378 pull_request_id
371 pull_request_id
379 )
372 )
380 payload = {
373
381 'type': 'message',
374 message = '<strong>{}</strong> {} - ' \
382 'timestamp': datetime.utcnow(),
375 '<a onclick="window.location=\'{}\';' \
383 'user': 'system',
376 'window.location.reload()">' \
384 'exclude_users': [user.username],
377 '<strong>{}</strong></a>'
385 'channel': channel,
378 message = message.format(
386 'message': {
379 user.username, _('made a comment'), msg_url,
387 'message': message,
380 _('Show it now'))
388 'level': 'info',
381
389 'topic': '/notifications'
382 channelstream.post_message(
390 }
383 channel, message, user.username,
391 }
384 registry=get_current_registry())
392 channelstream_request(channelstream_config, [payload],
393 '/message', raise_exc=False)
394
385
395 return comment
386 return comment
396
387
@@ -61,13 +61,22 b' var rhodeCodeApp = Polymer({'
61 },
61 },
62
62
63 checkViewChannels: function () {
63 checkViewChannels: function () {
64 var channels = []
64 // subscribe to different channels data is sent.
65
66 var channels = [];
65 // subscribe to PR repo channel for PR's'
67 // subscribe to PR repo channel for PR's'
66 if (templateContext.pull_request_data.pull_request_id) {
68 if (templateContext.pull_request_data.pull_request_id) {
67 var channelName = '/repo$' + templateContext.repo_name + '$/pr/' +
69 var channelName = '/repo$' + templateContext.repo_name + '$/pr/' +
68 String(templateContext.pull_request_data.pull_request_id);
70 String(templateContext.pull_request_data.pull_request_id);
69 channels.push(channelName);
71 channels.push(channelName);
70 }
72 }
73
74 if (templateContext.commit_data.commit_id) {
75 var channelName = '/repo$' + templateContext.repo_name + '$/commit/' +
76 String(templateContext.commit_data.commit_id);
77 channels.push(channelName);
78 }
79
71 return channels;
80 return channels;
72 },
81 },
73
82
General Comments 0
You need to be logged in to leave comments. Login now