From e2441a8d284ad3177fac5af9a8bb0c94903f8abb Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Dec 07 2017 11:03:13 +0000 Subject: Let the SSE server to send the notifications so they can be displayed live Fixes https://pagure.io/pagure/issue/2830 Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py index 851b792..5fb8fac 100644 --- a/pagure/lib/__init__.py +++ b/pagure/lib/__init__.py @@ -4483,6 +4483,21 @@ def add_metadata_update_notif(session, obj, messages, user, gitfolder): # Make sure we won't have SQLAlchemy error before we continue session.commit() + REDIS.publish( + 'pagure.%s' % obj.uid, json.dumps({ + 'comment_id': obj_comment.id, + '%s_id' % obj.isa: obj.id, + 'project': obj.project.fullname, + 'comment_added': text2markdown(obj_comment.comment), + 'comment_user': obj_comment.user.user, + 'avatar_url': avatar_url_from_email( + obj_comment.user.default_email, size=16), + 'comment_date': obj_comment.date_created.strftime( + '%Y-%m-%d %H:%M:%S'), + 'notification': True, + }) + ) + if gitfolder: pagure.lib.git.update_git( obj, repo=obj.project, repofolder=gitfolder) diff --git a/pagure/static/issue_ev.js b/pagure/static/issue_ev.js index 1eb0afa..286bb48 100644 --- a/pagure/static/issue_ev.js +++ b/pagure/static/issue_ev.js @@ -131,47 +131,60 @@ remove_deps = function(data, issue_uid, _issue_url) { add_comment = function(data, username) { console.log('Adding comment ' + data.comment_added); var field = $('#comments'); - var _data = '
\ - \ -
\ -
\ -
\ - \ - \ - ' + emojione.toImage(data.comment_added) + '\ + if (data.notification){ + var _data = '
' + + '
' + + '
' + + '
' + + 'seconds ago' + + '
' + + '' + data.comment_added + '' + + '
' + + '
' + + '
'; + } else { + var _data = '
\ + \ +
\ +
\ +
\ + \ + \ + ' + emojione.toImage(data.comment_added) + '\ +
\ +
\ +
\ + \
\ -
\ -
\ - \
\ -
\ -
'; + '; + } field.html(field.html() + _data); }