avoid email domain missing error, fixes #229

This commit is contained in:
Johannes Wilm 2023-10-16 12:26:55 +02:00
parent ceb7cade62
commit c8f7ecbe54

View file

@ -74,8 +74,8 @@ class LibRAvatarProvider:
@classmethod
def get_avatar_url(cls, user, width, _height=None):
email = getattr(user, settings.AVATAR_GRAVATAR_FIELD).encode("utf-8")
_, domain = email.split(b"@")
try:
_, domain = email.split(b"@")
answers = dns.resolver.query("_avatars._tcp." + domain, "SRV")
hostname = re.sub(r"\.$", "", str(answers[0].target))
# query returns "example.com." and while http requests are fine with this,