"""The AFI fixture's two channels bound to Django's `Channel` base. Payload models and wire names come from `fixture`; `authorize` and `group` are the obligations the Django base adds. """ from mizan.channels import Channel, register from fixture import ( CHAT_CHANNEL, USER_ALERTS_CHANNEL, ChatClientMessage, ChatParams, ChatServerMessage, UserAlertsServerMessage, ) class ChatChannel(Channel): Params = ChatParams ClientMessage = ChatClientMessage ServerMessage = ChatServerMessage def authorize(self, params: ChatParams | None = None) -> bool: return True def group(self, params: ChatParams | None = None) -> str: # Params are absent on the schema-export path, where no room is bound. return f"chat:{params.room_id}" if params else "chat" class UserAlertsChannel(Channel): ServerMessage = UserAlertsServerMessage def authorize(self, params: None = None) -> bool: return True def group(self, params: None = None) -> str: return "user_alerts" def register_fixture_channels() -> None: register(ChatChannel, CHAT_CHANNEL) register(UserAlertsChannel, USER_ALERTS_CHANNEL)