mirror of
https://git.ugnet.gay/CrossTalk/azul.git
synced 2026-11-25 08:40:05 +00:00
fix the fix
This commit is contained in:
1 parent
6451bb9426
commit
5a896451fc
3 files changed
+34
-4
No files matched your search
+32
-2
@@ -13,8 +13,38 @@ def render(req: web.Request, tmpl_name: str, ctxt: Optional[Dict[str, Any]] = No
|
||||
tmpl = req.app['jinja_env'].get_template(tmpl_name)
|
||||
template_context = dict(ctxt or {})
|
||||
backend = req.app.get('backend')
|
||||
if backend is not None:
|
||||
template_context['display_email'] = display_email
|
||||
|
||||
def display_email(user: Any, fallback: Optional[str] = None) -> str:
|
||||
if isinstance(user, str):
|
||||
identifier = user
|
||||
if backend is None:
|
||||
return fallback or (identifier if '@' in identifier else '')
|
||||
user = backend.user_service.get(identifier)
|
||||
if user is None and fallback:
|
||||
uuid = backend.user_service.get_uuid(fallback)
|
||||
if uuid is not None:
|
||||
user = backend.user_service.get(uuid)
|
||||
if user is None:
|
||||
return fallback or (identifier if '@' in identifier else '')
|
||||
elif user is None and fallback and backend is not None:
|
||||
uuid = backend.user_service.get_uuid(fallback)
|
||||
if uuid is not None:
|
||||
user = backend.user_service.get(uuid)
|
||||
|
||||
if user is None:
|
||||
return fallback or ''
|
||||
|
||||
if backend is not None:
|
||||
return backend.util_get_display_email(user)
|
||||
|
||||
if getattr(user, 'alias_active', False):
|
||||
username = getattr(user, 'username', None)
|
||||
if username:
|
||||
return '{}@crosstalk.im'.format(username)
|
||||
|
||||
return getattr(user, 'email', None) or fallback or ''
|
||||
|
||||
template_context['display_email'] = display_email
|
||||
content = tmpl.render(**template_context)
|
||||
return web.Response(status = status, content_type = content_type, text = content)
|
||||
|
||||
|
||||
Reference in new issue
Block a user