]> git.ipfire.org Git - ipfire.org.git/commitdiff
accounts: Use more than one letter from nicknames for avatars
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 7 Jan 2024 18:12:06 +0000 (18:12 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 7 Jan 2024 18:12:06 +0000 (18:12 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/backend/accounts.py

index 2b2e42be1d68f3963152be0459ef4106c623334f..a92bc338f59d097fd7cd7886b43bb1091a3fa409 100644 (file)
@@ -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: