diff --git a/lnbits/core/crud.py b/lnbits/core/crud.py index 46f765967..efb594a14 100644 --- a/lnbits/core/crud.py +++ b/lnbits/core/crud.py @@ -88,9 +88,9 @@ async def add_installed_extension( await (conn or db).execute( """ - INSERT INTO installed_extensions (id, version, name, short_description, icon, icon_url, stars, meta) VALUES (?, ?, ?, ?, ?, ?, ?, ?) + INSERT INTO installed_extensions (id, version, name, short_description, icon, stars, meta) VALUES (?, ?, ?, ?, ?, ?, ?) ON CONFLICT (id) DO - UPDATE SET (version, name, active, short_description, icon, icon_url, stars, meta) = (?, ?, ?, ?, ?, ?, ?, ?) + UPDATE SET (version, name, active, short_description, icon, stars, meta) = (?, ?, ?, ?, ?, ?, ?) """, ( ext.id, @@ -98,7 +98,6 @@ async def add_installed_extension( ext.name, ext.short_description, ext.icon, - ext.icon_url, ext.stars, json.dumps(meta), version, @@ -106,7 +105,6 @@ async def add_installed_extension( False, ext.short_description, ext.icon, - ext.icon_url, ext.stars, json.dumps(meta), ), diff --git a/lnbits/core/migrations.py b/lnbits/core/migrations.py index 1cdaebaab..9ce3e51bd 100644 --- a/lnbits/core/migrations.py +++ b/lnbits/core/migrations.py @@ -294,7 +294,6 @@ async def m010_create_installed_extensions_table(db): name TEXT NOT NULL, short_description TEXT, icon TEXT, - icon_url TEXT, stars INT NOT NULL DEFAULT 0, active BOOLEAN DEFAULT false, meta TEXT NOT NULL DEFAULT '{}' diff --git a/lnbits/core/views/api.py b/lnbits/core/views/api.py index e28cdd3cc..6393385f1 100644 --- a/lnbits/core/views/api.py +++ b/lnbits/core/views/api.py @@ -736,7 +736,7 @@ async def api_install_extension( status_code=HTTPStatus.NOT_FOUND, detail="Release not found" ) ext_info = InstallableExtension( - id=data.ext_id, name=data.ext_id, installed_release=release + id=data.ext_id, name=data.ext_id, installed_release=release, icon=release.icon ) ext_info.download_archive() diff --git a/lnbits/extension_manager.py b/lnbits/extension_manager.py index 9c6cd14cd..7955c791d 100644 --- a/lnbits/extension_manager.py +++ b/lnbits/extension_manager.py @@ -106,10 +106,12 @@ class ExtensionRelease(BaseModel): version: str archive: str source_repo: str + is_github_release = False hash: Optional[str] html_url: Optional[str] description: Optional[str] details_html: Optional[str] = None + icon: Optional[str] @classmethod def from_github_release( @@ -121,6 +123,7 @@ class ExtensionRelease(BaseModel): version=r.tag_name, archive=r.zipball_url, source_repo=source_repo, + is_github_release=True, # description=r.body, # bad for JSON html_url=r.html_url, ) @@ -181,7 +184,7 @@ class GitHubRepo(BaseModel): class ExtensionConfig(BaseModel): name: str short_description: str - tile: str + tile: str = "" class InstallableExtension(BaseModel): @@ -189,7 +192,6 @@ class InstallableExtension(BaseModel): name: str short_description: Optional[str] = None icon: Optional[str] = None - icon_url: Optional[str] = None dependencies: List[str] = [] is_admin_only: bool = False stars: int = 0 @@ -287,9 +289,13 @@ class InstallableExtension(BaseModel): self.name = config_json.get("name") self.short_description = config_json.get("short_description") - self.icon = config_json.get("icon") - if self.installed_release and config_json.get("tile"): - self.icon_url = icon_to_github_url( + + if ( + self.installed_release + and self.installed_release.is_github_release + and config_json.get("tile") + ): + self.icon = icon_to_github_url( self.installed_release.source_repo, config_json.get("tile") ) @@ -345,7 +351,7 @@ class InstallableExtension(BaseModel): short_description=config.short_description, version="0", stars=repo.stargazers_count, - icon_url=icon_to_github_url( + icon=icon_to_github_url( f"{github_release.organisation}/{github_release.repository}", config.tile, ), @@ -427,6 +433,7 @@ class InstallableExtension(BaseModel): description=e.short_description, details_html=e.details, html_url=e.html_url, + icon=e.icon, ) ]