Fixed stream monitor instantiating its own subscription repository.
CD / Build (push) Successful in 8s
CI / Formatting (push) Successful in 5s
CI / Linting (push) Successful in 5s
CI / Type Checking (push) Successful in 9s
CI / Spelling (push) Successful in 6s

This commit is contained in:
2026-03-11 15:36:43 -04:00
parent 282b16b51c
commit b8447e190c
2 changed files with 6 additions and 4 deletions
+1
View File
@@ -73,6 +73,7 @@ class OwncastSentry(Plugin):
self.stream_monitor = StreamMonitor( self.stream_monitor = StreamMonitor(
self.owncast_client, self.owncast_client,
self.stream_repo, self.stream_repo,
self.subscription_repo,
self.notification_service, self.notification_service,
self.log, self.log,
) )
+5 -4
View File
@@ -18,7 +18,6 @@ import asyncio
import time import time
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from .database import SubscriptionRepository
from .health_checker import UpdateResult from .health_checker import UpdateResult
from .models import StreamState from .models import StreamState
from .utils import ( from .utils import (
@@ -31,7 +30,7 @@ from .utils import (
if TYPE_CHECKING: if TYPE_CHECKING:
import logging import logging
from .database import StreamRepository from .database import StreamRepository, SubscriptionRepository
from .notification_service import NotificationService from .notification_service import NotificationService
from .owncast_client import OwncastClient from .owncast_client import OwncastClient
@@ -43,6 +42,7 @@ class StreamMonitor:
self, self,
owncast_client: OwncastClient, owncast_client: OwncastClient,
stream_repo: StreamRepository, stream_repo: StreamRepository,
subscription_repo: SubscriptionRepository,
notification_service: NotificationService, notification_service: NotificationService,
logger: logging.Logger, logger: logging.Logger,
) -> None: ) -> None:
@@ -50,11 +50,13 @@ class StreamMonitor:
:param owncast_client: Client for making API calls to Owncast instances. :param owncast_client: Client for making API calls to Owncast instances.
:param stream_repo: Repository for stream data. :param stream_repo: Repository for stream data.
:param subscription_repo: Repository for subscription data.
:param notification_service: Service for sending notifications. :param notification_service: Service for sending notifications.
:param logger: Logger instance for debugging. :param logger: Logger instance for debugging.
""" """
self.owncast_client = owncast_client self.owncast_client = owncast_client
self.stream_repo = stream_repo self.stream_repo = stream_repo
self.subscription_repo = subscription_repo
self.notification_service = notification_service self.notification_service = notification_service
self.log = logger self.log = logger
@@ -336,8 +338,7 @@ class StreamMonitor:
await self.notification_service.send_cleanup_deletion(domain) await self.notification_service.send_cleanup_deletion(domain)
# Delete all subscriptions for this domain # Delete all subscriptions for this domain
subscription_repo = SubscriptionRepository(self.stream_repo.db) deleted_count = await self.subscription_repo.delete_all_for_domain(domain)
deleted_count = await subscription_repo.delete_all_for_domain(domain)
# Delete the stream record # Delete the stream record
await self.stream_repo.delete(domain) await self.stream_repo.delete(domain)