mirror of
https://github.com/zulip/zulip.git
synced 2025-10-26 17:43:58 +00:00
user status: Restructure code.
We now have single function that handle both away and not-away. This refactoring sets us up to piggyback "info" more easily onto status updates. The only thing that changes here is that we don't delete database rows any more when users revoke their away status. Instead we just set the status to NORMAL.
This commit is contained in:
@@ -15,22 +15,20 @@ def get_away_user_ids(realm_id: int) -> Set[int]:
|
||||
|
||||
return set(user_ids)
|
||||
|
||||
def set_away_status(user_profile_id: int,
|
||||
client_id: int) -> None:
|
||||
def update_user_status(user_profile_id: int,
|
||||
status: int,
|
||||
client_id: int) -> None:
|
||||
|
||||
timestamp = timezone_now()
|
||||
status = UserStatus.AWAY
|
||||
|
||||
defaults = dict(
|
||||
client_id=client_id,
|
||||
timestamp=timestamp,
|
||||
)
|
||||
|
||||
defaults['status'] = status
|
||||
|
||||
UserStatus.objects.update_or_create(
|
||||
user_profile_id=user_profile_id,
|
||||
defaults=dict(
|
||||
client_id=client_id,
|
||||
timestamp=timestamp,
|
||||
status=status,
|
||||
),
|
||||
defaults=defaults,
|
||||
)
|
||||
|
||||
def revoke_away_status(user_profile_id: int) -> None:
|
||||
UserStatus.objects.filter(
|
||||
user_profile_id=user_profile_id,
|
||||
).delete()
|
||||
|
||||
Reference in New Issue
Block a user