aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/src/meshbay_hub/api/federation.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/api/federation.py')
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/api/federation.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/api/federation.py b/packages/meshbay-hub/src/meshbay_hub/api/federation.py
index b6b4acf..7f1262d 100644
--- a/packages/meshbay-hub/src/meshbay_hub/api/federation.py
+++ b/packages/meshbay-hub/src/meshbay_hub/api/federation.py
@@ -31,7 +31,7 @@ from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
from meshbay_common import MHP_VERSION
-from meshbay_hub import __version__
+from meshbay_hub import __version__, hub_settings
from meshbay_hub.api.deps import require_admin
from meshbay_hub.auth import _hub_id, _hub_sk_pem, hub_public_key_pem
from meshbay_hub.db.engine import get_db
@@ -104,9 +104,15 @@ async def export_directory(
except Exception as e:
raise HTTPException(status_code=401, detail=str(e))
- result = await db.execute(
- select(Group).where(Group.visibility == "public", Group.status == "active"))
- groups = result.scalars().all()
+ # A hub with public groups switched off advertises nothing to its peers —
+ # the local directory is empty (groups.list_public_groups), and the exported
+ # one has to match or peers keep showing groups this hub no longer serves.
+ if not await hub_settings.public_groups_allowed(db):
+ groups = []
+ else:
+ result = await db.execute(
+ select(Group).where(Group.visibility == "public", Group.status == "active"))
+ groups = result.scalars().all()
return {
"hub_id": _hub_id,