From c33845402e63f268f159644808b91014eed08d70 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 08 2021 13:20:58 +0000 Subject: [PATCH 1/2] Be consistent in the messages send The JSON representation of the User object has an 'emails' field not an 'email' and that field is not present in the public JSON representation of the User objects (thus not in notifications sent on the message bus). We can thus drop entirely the 'email' field that was present until now. Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/hooks/default.py b/pagure/hooks/default.py index 5813f7c..104083f 100644 --- a/pagure/hooks/default.py +++ b/pagure/hooks/default.py @@ -180,7 +180,6 @@ def send_notifications( else: author = { "fullname": author, - "email": None, "name": None, "url_path": None, } From 8919ec73a669c3dfc01864a0de0f72852fcc9c4c Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 08 2021 13:20:58 +0000 Subject: [PATCH 2/2] Ensure the author info sent always fit the expected schema Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/hooks/default.py b/pagure/hooks/default.py index 104083f..e1872d0 100644 --- a/pagure/hooks/default.py +++ b/pagure/hooks/default.py @@ -128,11 +128,15 @@ def send_action_notification( """Send out-going notifications about the branch/tag.""" email = pagure.lib.git.get_author_email(rev, repodir) name = pagure.lib.git.get_author(rev, repodir) - author = pagure.lib.query.search_user(session, email=email) - if author: + author = pagure.lib.query.search_user(session, email=email) or name + if not isinstance(author, six.string_types): author = author.to_json(public=True) else: - author = name + author = { + "fullname": author, + "name": None, + "url_path": None, + } topic = "git.%s.%s" % (subject, action) msg = dict(