From cb0bbde98158ff0818daec9bc386e45f441fce29 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Tue, 10 Jul 2018 13:56:32 +0100 Subject: [PATCH 1/3] tweak dinsic display names --- synapse/rest/client/v2_alpha/register.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/synapse/rest/client/v2_alpha/register.py b/synapse/rest/client/v2_alpha/register.py index fe9c02f305..bfd7d30a23 100644 --- a/synapse/rest/client/v2_alpha/register.py +++ b/synapse/rest/client/v2_alpha/register.py @@ -421,9 +421,17 @@ class RegisterRestServlet(RestServlet): # XXX: a nasty heuristic to turn an email address into # a displayname, as part of register_mxid_from_3pid parts = address.replace('.', ' ').split('@') + org_parts = parts[1].split(' ') + + if org_parts[0] == "matrix" and org_parts[1] == "org": + org = "Tchap Admin" + elif org_parts[-2] == "gouv": + org = org_parts[-3] or org_parts[-2] + else: + org = org_parts[-2] + desired_display_name = ( - capwords(parts[0]) + - " [" + capwords(parts[1].split(' ')[0]) + "]" + capwords(parts[0]) + " [" + capwords(org) + "]" ) elif ( self.hs.config.register_mxid_from_3pid == 'msisdn' and From 9d57abcadd25e9dd9244e40d88fdb5ddac6f672c Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Tue, 10 Jul 2018 13:58:01 +0100 Subject: [PATCH 2/3] fix bounds error --- synapse/rest/client/v2_alpha/register.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synapse/rest/client/v2_alpha/register.py b/synapse/rest/client/v2_alpha/register.py index bfd7d30a23..b4b598a789 100644 --- a/synapse/rest/client/v2_alpha/register.py +++ b/synapse/rest/client/v2_alpha/register.py @@ -426,7 +426,7 @@ class RegisterRestServlet(RestServlet): if org_parts[0] == "matrix" and org_parts[1] == "org": org = "Tchap Admin" elif org_parts[-2] == "gouv": - org = org_parts[-3] or org_parts[-2] + org = org_parts[-3] if len(org_parts) > 2 else org_parts[-2] else: org = org_parts[-2] From 11728561f39816cd754d5d51b8deaf72754d479f Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Tue, 10 Jul 2018 15:21:14 +0100 Subject: [PATCH 3/3] improve domain matches --- synapse/rest/client/v2_alpha/register.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/synapse/rest/client/v2_alpha/register.py b/synapse/rest/client/v2_alpha/register.py index b4b598a789..97e4891f3f 100644 --- a/synapse/rest/client/v2_alpha/register.py +++ b/synapse/rest/client/v2_alpha/register.py @@ -423,9 +423,9 @@ class RegisterRestServlet(RestServlet): parts = address.replace('.', ' ').split('@') org_parts = parts[1].split(' ') - if org_parts[0] == "matrix" and org_parts[1] == "org": + if org_parts[-2] == "matrix" and org_parts[-1] == "org": org = "Tchap Admin" - elif org_parts[-2] == "gouv": + elif org_parts[-2] == "gouv" and org_parts[-1] == "fr": org = org_parts[-3] if len(org_parts) > 2 else org_parts[-2] else: org = org_parts[-2]