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