Files
remnawave-bedolaga-telegram…/app/utils/internal_squads.py
2025-12-08 04:20:21 +03:00

22 lines
732 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from typing import List, Optional
from app.database.models import Subscription, User
def resolve_user_internal_squads(
user: Optional[User], subscription: Optional[Subscription]
) -> List[str]:
"""Возвращает список Internal Squads для пользователя.
Приоритет у персональных сквадов пользователя. Если они не заданы,
используется список сквадов из подписки.
"""
if user and getattr(user, "active_internal_squads", None) is not None:
return list(user.active_internal_squads or [])
if subscription:
return list(subscription.connected_squads or [])
return []