mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-01-07 15:55:29 +00:00
Don't use bookwyrm connectors when federation is disabled
This commit is contained in:
parent
901ca17d16
commit
48d5647018
3 changed files with 14 additions and 1 deletions
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
@ -184,6 +184,7 @@ class FederationSettings(CustomForm):
|
|||
"disable_federation",
|
||||
]
|
||||
|
||||
|
||||
class AutoModRuleForm(CustomForm):
|
||||
class Meta:
|
||||
model = models.AutoMod
|
||||
|
|
Loading…
Reference in a new issue