From: Michael Tremer Date: Sun, 7 Jan 2024 18:12:06 +0000 (+0000) Subject: accounts: Use more than one letter from nicknames for avatars X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=39144fcb0804b0984331e22489d537c8c7c362f8;p=ipfire.org.git accounts: Use more than one letter from nicknames for avatars Signed-off-by: Michael Tremer --- diff --git a/src/backend/accounts.py b/src/backend/accounts.py index 2b2e42be..a92bc338 100644 --- a/src/backend/accounts.py +++ b/src/backend/accounts.py @@ -1034,10 +1034,14 @@ class Account(LDAPObject): initials = [] # If a nickname is set, only use the nickname - if self.nickname: + if self.nickname and len(self.nickname) >= 2: for m in re.findall(r"(\w+)", self.nickname): initials.append(m[0]) + # If we only detected one character, we will use the first two + if len(initials) < 2: + initials = [self.nickname[0], self.nickname[1]] + # Otherwise use the first and last name else: if self.first_name: