Skip to content

Commit

Permalink
fix: don't crash if user doesn't exist in mailcow
Browse files Browse the repository at this point in the history
  • Loading branch information
missytake committed Apr 11, 2024
1 parent 8eb09cf commit 3785267
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/mailadm/conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,11 @@ def get_expired_users(self, sysdate):
if user.ttl < mailadm.util.parse_expiry_code("27d"):
expired_users.append(user)
continue
last_login = self.get_mailcow_connection().get_user(user.addr).last_login
mc_user = self.get_mailcow_connection().get_user(user.addr)
if not mc_user:
logging.warning("user %s doesn't exist in mailcow", user.addr)
continue
last_login = mc_user.last_login
# expire users who weren't online for longer than 25% of their TTL:
if sysdate - last_login > user.ttl * 0.25:
expired_users.append(user)
Expand Down

0 comments on commit 3785267

Please sign in to comment.