remove lnbits_disabled_extensions, fix is_admin_only

This commit is contained in:
jacksn 2023-03-05 13:36:36 +01:00
parent c81d3e06c8
commit 83f04534e7
2 changed files with 4 additions and 13 deletions

View File

@ -54,8 +54,6 @@ class Extension(NamedTuple):
class ExtensionManager: class ExtensionManager:
def __init__(self): def __init__(self):
self._disabled: List[str] = settings.lnbits_disabled_extensions
self._admin_only: List[str] = settings.lnbits_admin_extensions
p = Path(settings.lnbits_path, "extensions") p = Path(settings.lnbits_path, "extensions")
os.makedirs(p, exist_ok=True) os.makedirs(p, exist_ok=True)
self._extension_folders: List[Path] = [f for f in p.iterdir() if f.is_dir()] self._extension_folders: List[Path] = [f for f in p.iterdir() if f.is_dir()]
@ -64,23 +62,18 @@ class ExtensionManager:
def extensions(self) -> List[Extension]: def extensions(self) -> List[Extension]:
output: List[Extension] = [] output: List[Extension] = []
if "all" in self._disabled: for extension_folder in self._extension_folders:
return output extension_code = extension_folder.parts[-1]
for extension in [
ext for ext in self._extension_folders if ext not in self._disabled
]:
try: try:
with open(extension / "config.json") as json_file: with open(extension_folder / "config.json") as json_file:
config = json.load(json_file) config = json.load(json_file)
is_valid = True is_valid = True
is_admin_only = True if extension in self._admin_only else False is_admin_only = extension_code in settings.lnbits_admin_extensions
except Exception: except Exception:
config = {} config = {}
is_valid = False is_valid = False
is_admin_only = False is_admin_only = False
*_, extension_code = extension.parts
output.append( output.append(
Extension( Extension(
extension_code, extension_code,

View File

@ -43,7 +43,6 @@ class UsersSettings(LNbitsSettings):
class ExtensionsSettings(LNbitsSettings): class ExtensionsSettings(LNbitsSettings):
lnbits_admin_extensions: List[str] = Field(default=[]) lnbits_admin_extensions: List[str] = Field(default=[])
lnbits_disabled_extensions: List[str] = Field(default=[])
lnbits_extensions_manifests: List[str] = Field( lnbits_extensions_manifests: List[str] = Field(
default=[ default=[
"https://raw.githubusercontent.com/lnbits/lnbits-extensions/main/extensions.json" "https://raw.githubusercontent.com/lnbits/lnbits-extensions/main/extensions.json"
@ -212,7 +211,6 @@ class EditableSettings(
"lnbits_allowed_users", "lnbits_allowed_users",
"lnbits_theme_options", "lnbits_theme_options",
"lnbits_admin_extensions", "lnbits_admin_extensions",
"lnbits_disabled_extensions",
pre=True, pre=True,
) )
def validate_editable_settings(cls, val): def validate_editable_settings(cls, val):