diff --git a/bookwyrm/connectors/bookwyrm_connector.py b/bookwyrm/connectors/bookwyrm_connector.py index 4064f4b4c..5040041a6 100644 --- a/bookwyrm/connectors/bookwyrm_connector.py +++ b/bookwyrm/connectors/bookwyrm_connector.py @@ -5,11 +5,19 @@ from typing import Any, Iterator from bookwyrm import activitypub, models from bookwyrm.book_search import SearchResult from .abstract_connector import AbstractMinimalConnector +from .connector_manager import ConnectorException class Connector(AbstractMinimalConnector): """this is basically just for search""" + def __init__(self, identifier: str): + if models.SiteSettings.objects.get().disable_federation: + raise ConnectorException( + "Federation is disabled, cannot load BookWyrm connector", identifier + ) + super().__init__(identifier) + def get_or_create_book(self, remote_id: str) -> models.Edition: return activitypub.resolve_remote_id(remote_id, model=models.Edition) diff --git a/bookwyrm/connectors/connector_manager.py b/bookwyrm/connectors/connector_manager.py index ad68af1dc..e5a2399d3 100644 --- a/bookwyrm/connectors/connector_manager.py +++ b/bookwyrm/connectors/connector_manager.py @@ -111,7 +111,11 @@ def first_search_result( def get_connectors() -> Iterator[abstract_connector.AbstractConnector]: """load all connectors""" - for info in models.Connector.objects.filter(active=True).order_by("priority").all(): + queryset = models.Connector.objects.filter(active=True) + if models.SiteSettings.objects.get().disable_federation: + queryset = queryset.exclude(connector_file="bookwyrm_connector") + + for info in queryset.order_by("priority").all(): yield load_connector(info) diff --git a/bookwyrm/forms/admin.py b/bookwyrm/forms/admin.py index c246acb74..a2b35a374 100644 --- a/bookwyrm/forms/admin.py +++ b/bookwyrm/forms/admin.py @@ -184,6 +184,7 @@ class FederationSettings(CustomForm): "disable_federation", ] + class AutoModRuleForm(CustomForm): class Meta: model = models.AutoMod