mirror of https://github.com/zulip/zulip.git
Error reporting emails: Indicate user role.
Adds user role to the user's information in the error reporting emails, as some bugs are role-dependent. Fixes: #15344
This commit is contained in:
parent
b4dd118aa1
commit
be6b2b248f
|
@ -24,7 +24,7 @@ def logger_repr(report: Dict[str, Any]) -> str:
|
|||
|
||||
def user_info_str(report: Dict[str, Any]) -> str:
|
||||
if report.get('user') and report['user'].get('user_full_name'):
|
||||
user_info = "{user[user_full_name]} <{user[user_email]}>".format(**report)
|
||||
user_info = "{user[user_full_name]} <{user[user_email]}> ({user[user_role]})".format(**report)
|
||||
else:
|
||||
user_info = "Anonymous user (not logged in)"
|
||||
|
||||
|
|
|
@ -41,18 +41,22 @@ def add_request_metadata(report: Dict[str, Any], request: HttpRequest) -> None:
|
|||
if isinstance(user_profile, AnonymousUser):
|
||||
user_full_name = None
|
||||
user_email = None
|
||||
user_role = None
|
||||
else:
|
||||
user_full_name = user_profile.full_name
|
||||
user_email = user_profile.email
|
||||
user_role = user_profile.get_role_name()
|
||||
except Exception:
|
||||
# Unexpected exceptions here should be handled gracefully
|
||||
traceback.print_exc()
|
||||
user_full_name = None
|
||||
user_email = None
|
||||
user_role = None
|
||||
|
||||
report['user'] = {
|
||||
'user_email': user_email,
|
||||
'user_full_name': user_full_name,
|
||||
'user_role': user_role,
|
||||
}
|
||||
|
||||
exception_filter = get_exception_reporter_filter(request)
|
||||
|
|
|
@ -117,6 +117,7 @@ class AdminNotifyHandlerTest(ZulipTestCase):
|
|||
report = self.run_handler(record)
|
||||
self.assertIn("user", report)
|
||||
self.assertIn("user_email", report["user"])
|
||||
self.assertIn("user_role", report["user"])
|
||||
self.assertIn("message", report)
|
||||
self.assertIn("stack_trace", report)
|
||||
self.assertEqual(report['stack_trace'], 'message\nmoremesssage\nmore')
|
||||
|
@ -132,6 +133,7 @@ class AdminNotifyHandlerTest(ZulipTestCase):
|
|||
report = self.run_handler(record)
|
||||
self.assertIn("user", report)
|
||||
self.assertIn("user_email", report["user"])
|
||||
self.assertIn("user_role", report["user"])
|
||||
self.assertIn("message", report)
|
||||
self.assertIn("stack_trace", report)
|
||||
|
||||
|
@ -150,6 +152,7 @@ class AdminNotifyHandlerTest(ZulipTestCase):
|
|||
self.assertIn("host", report)
|
||||
self.assertIn("user", report)
|
||||
self.assertIn("user_email", report["user"])
|
||||
self.assertIn("user_role", report["user"])
|
||||
self.assertIn("message", report)
|
||||
self.assertIn("stack_trace", report)
|
||||
|
||||
|
@ -163,6 +166,7 @@ class AdminNotifyHandlerTest(ZulipTestCase):
|
|||
self.assertIn("host", report)
|
||||
self.assertIn("user", report)
|
||||
self.assertIn("user_email", report["user"])
|
||||
self.assertIn("user_role", report["user"])
|
||||
self.assertIn("message", report)
|
||||
self.assertIn("stack_trace", report)
|
||||
|
||||
|
@ -175,6 +179,7 @@ class AdminNotifyHandlerTest(ZulipTestCase):
|
|||
self.assertIn("host", report)
|
||||
self.assertIn("user", report)
|
||||
self.assertIn("user_email", report["user"])
|
||||
self.assertIn("user_role", report["user"])
|
||||
self.assertIn("message", report)
|
||||
self.assertIn("stack_trace", report)
|
||||
|
||||
|
@ -193,6 +198,7 @@ class AdminNotifyHandlerTest(ZulipTestCase):
|
|||
self.assertIn("host", report)
|
||||
self.assertIn("user", report)
|
||||
self.assertIn("user_email", report["user"])
|
||||
self.assertIn("user_role", report["user"])
|
||||
self.assertIn("message", report)
|
||||
self.assertEqual(report["stack_trace"], 'No stack trace available')
|
||||
|
||||
|
@ -203,6 +209,7 @@ class AdminNotifyHandlerTest(ZulipTestCase):
|
|||
self.assertIn("host", report)
|
||||
self.assertIn("user", report)
|
||||
self.assertIn("user_email", report["user"])
|
||||
self.assertIn("user_role", report["user"])
|
||||
self.assertIn("message", report)
|
||||
self.assertIn("stack_trace", report)
|
||||
|
||||
|
|
Loading…
Reference in New Issue