def _save_cached_profile(user_id: UserId, user: UserSpec, multisite_keys: List[str], non_contact_keys: List[str]) -> None: # Only save contact AND multisite attributes to the profile. Not the # infos that are stored in the custom attribute files. cache = {} for key in user.keys(): if key in multisite_keys or key not in non_contact_keys: cache[key] = user[key] save_cached_profile(user_id, cache)
def get_last_activity(user_id: UserId, user: UserSpec) -> int: return max( [s.last_activity for s in user.get("session_info", {}).values()] + [0])