diff --git a/rhodecode/lib/channelstream.py b/rhodecode/lib/channelstream.py
--- a/rhodecode/lib/channelstream.py
+++ b/rhodecode/lib/channelstream.py
@@ -228,6 +228,7 @@ def post_message(channel, message, usern
if not registry:
registry = get_current_registry()
+ log.debug('Channelstream: sending notification to channel %s', channel)
rhodecode_plugins = getattr(registry, 'rhodecode_plugins', {})
channelstream_config = rhodecode_plugins.get('channelstream', {})
if channelstream_config.get('enabled'):
diff --git a/rhodecode/model/comment.py b/rhodecode/model/comment.py
--- a/rhodecode/model/comment.py
+++ b/rhodecode/model/comment.py
@@ -33,7 +33,7 @@ from pyramid.threadlocal import get_curr
from sqlalchemy.sql.expression import null
from sqlalchemy.sql.functions import coalesce
-from rhodecode.lib import helpers as h, diffs
+from rhodecode.lib import helpers as h, diffs, channelstream
from rhodecode.lib import audit_logger
from rhodecode.lib.channelstream import channelstream_request
from rhodecode.lib.utils2 import extract_mentioned_users, safe_str
@@ -354,43 +354,34 @@ class CommentsModel(BaseModel):
self._log_audit_action(
action, {'data': comment_data}, user, comment)
- registry = get_current_registry()
- rhodecode_plugins = getattr(registry, 'rhodecode_plugins', {})
- channelstream_config = rhodecode_plugins.get('channelstream', {})
msg_url = ''
+ channel = None
if commit_obj:
msg_url = commit_comment_url
repo_name = repo.repo_name
+ channel = u'/repo${}$/commit/{}'.format(
+ repo_name,
+ commit_obj.raw_id
+ )
elif pull_request_obj:
msg_url = pr_comment_url
repo_name = pr_target_repo.repo_name
-
- if channelstream_config.get('enabled'):
- message = '{} {} - ' \
- '' \
- '{}'
- message = message.format(
- user.username, _('made a comment'), msg_url,
- _('Show it now'))
- channel = '/repo${}$/pr/{}'.format(
+ channel = u'/repo${}$/pr/{}'.format(
repo_name,
pull_request_id
)
- payload = {
- 'type': 'message',
- 'timestamp': datetime.utcnow(),
- 'user': 'system',
- 'exclude_users': [user.username],
- 'channel': channel,
- 'message': {
- 'message': message,
- 'level': 'info',
- 'topic': '/notifications'
- }
- }
- channelstream_request(channelstream_config, [payload],
- '/message', raise_exc=False)
+
+ message = '{} {} - ' \
+ '' \
+ '{}'
+ message = message.format(
+ user.username, _('made a comment'), msg_url,
+ _('Show it now'))
+
+ channelstream.post_message(
+ channel, message, user.username,
+ registry=get_current_registry())
return comment
diff --git a/rhodecode/public/js/src/components/rhodecode-app/rhodecode-app.js b/rhodecode/public/js/src/components/rhodecode-app/rhodecode-app.js
--- a/rhodecode/public/js/src/components/rhodecode-app/rhodecode-app.js
+++ b/rhodecode/public/js/src/components/rhodecode-app/rhodecode-app.js
@@ -61,13 +61,22 @@ var rhodeCodeApp = Polymer({
},
checkViewChannels: function () {
- var channels = []
+ // subscribe to different channels data is sent.
+
+ var channels = [];
// subscribe to PR repo channel for PR's'
if (templateContext.pull_request_data.pull_request_id) {
var channelName = '/repo$' + templateContext.repo_name + '$/pr/' +
String(templateContext.pull_request_data.pull_request_id);
channels.push(channelName);
}
+
+ if (templateContext.commit_data.commit_id) {
+ var channelName = '/repo$' + templateContext.repo_name + '$/commit/' +
+ String(templateContext.commit_data.commit_id);
+ channels.push(channelName);
+ }
+
return channels;
},