aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/src/meshbay_hub/api/federation.py
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-08-28 03:43:29 +0200
committerChristophe Besson <cbesson@gmail.com>2026-08-28 03:43:29 +0200
commit2f573b4143212b21d92ff20179356acb8f8fe635 (patch)
treece0c4ff78044a56c0882d7ba94fbea436f0e83c3 /packages/meshbay-hub/src/meshbay_hub/api/federation.py
parente1f1b65cfac031096e4bae24ccf102ca0dbb86d9 (diff)
parentb5b4f188a39fc96c4d32e67151e067b1add6dcfc (diff)
downloadmeshbay-2f573b4143212b21d92ff20179356acb8f8fe635.tar.gz
Merge branch 'feat/hub-disable-public-groups'
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,