summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/src/meshbay_node/roster.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-node/src/meshbay_node/roster.py')
-rw-r--r--packages/meshbay-node/src/meshbay_node/roster.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/packages/meshbay-node/src/meshbay_node/roster.py b/packages/meshbay-node/src/meshbay_node/roster.py
index 9a52b53..1cc8cae 100644
--- a/packages/meshbay-node/src/meshbay_node/roster.py
+++ b/packages/meshbay-node/src/meshbay_node/roster.py
@@ -22,6 +22,7 @@ The code is what binds a public key to an account without asking the hub
from __future__ import annotations
import hashlib
+import json
import logging
import os
import secrets
@@ -577,6 +578,27 @@ class Roster:
"1" if allowed else "0", set_by)
return allowed
+ # Which group "applications" (Chat, Files, and whatever registers later in
+ # apps.js) are shown to members. Unset means every app that exists — an
+ # existing group's tabs must not disappear because a node was upgraded.
+ SETTING_ENABLED_APPS = "enabled_apps"
+ DEFAULT_APPS = ("chat", "files")
+
+ async def enabled_apps(self, group_id: str) -> list[str]:
+ value = await self.get_setting(group_id, self.SETTING_ENABLED_APPS)
+ if value is None:
+ return list(self.DEFAULT_APPS)
+ try:
+ return list(json.loads(value))
+ except (ValueError, TypeError):
+ return list(self.DEFAULT_APPS)
+
+ async def set_enabled_apps(self, group_id: str, apps: list[str],
+ set_by: str = "") -> list[str]:
+ await self.set_setting(group_id, self.SETTING_ENABLED_APPS,
+ json.dumps(sorted(apps)), set_by)
+ return apps
+
async def create_invite(
self,
group_id: str,