Always have Public channel available

This commit is contained in:
Jack Kingsman
2026-01-13 12:06:38 -08:00
parent 760bd0f7d6
commit 3ea98e309c
2 changed files with 11 additions and 5 deletions
+8 -5
View File
@@ -187,18 +187,21 @@ async def ensure_default_channels() -> None:
"""
Ensure default channels exist in the database.
These will be configured on the radio when needed for sending.
The Public channel is protected - it always exists with the canonical name.
"""
# Public channel - no hashtag, specific key
# Public channel - no hashtag, specific well-known key
PUBLIC_CHANNEL_KEY_HEX = "8B3387E9C5CDEA6AC9E5EDBAA115CD72"
existing = await ChannelRepository.get_by_name("Public")
if not existing:
logger.info("Creating default Public channel")
# Check by KEY (not name) since that's what's fixed
existing = await ChannelRepository.get_by_key(PUBLIC_CHANNEL_KEY_HEX)
if not existing or existing.name != "Public":
logger.info("Ensuring default Public channel exists with correct name")
await ChannelRepository.upsert(
key=PUBLIC_CHANNEL_KEY_HEX,
name="Public",
is_hashtag=False,
on_radio=False,
on_radio=existing.on_radio if existing else False,
)