ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
feat(extensions): daily scheduled update check + admin notification (#50)
Juan Denis046ae0eacc0b
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 69683fc6..a751ea7b 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -20,6 +20,11 @@ awaiting a stable release:### Added+- **Extensions platform (Phase 7 — scheduled update checks)** — the panel now+ checks the extension registry for updates once a day (a regular scheduled job,+ visible under Jobs) and notifies admins through the Notifications Bus when new+ versions are available — once per release set, not once per day. The+ Marketplace "Update available" badge remains the always-current surface.- **Extensions platform (Phase 7 — per-extension configuration)** — an extensionthat declares a `config_schema` in its manifest now gets a real **Configure**form on the Marketplace Installed tab (text/number/boolean/enum/secret fields);diff --git a/backend/app/jobs/builtin_handlers.py b/backend/app/jobs/builtin_handlers.pyindex cd13d7c2..2a092523 100644--- a/backend/app/jobs/builtin_handlers.py+++ b/backend/app/jobs/builtin_handlers.py@@ -263,6 +263,50 @@ def run_backup_scheduler():BackupService.check_backup_schedules()+def run_extension_update_check():+ """Daily registry check for installed-extension updates (#50).++ Notifies admins through the Notifications Bus — but only when the set of+ available (slug, version) pairs CHANGED since the last notification, so a+ pending update nags once per release, not once per day. The Marketplace+ badge remains the always-current surface.+ """+ import json as _json+ from app.services.plugin_service import check_for_updates+ from app.services.settings_service import SettingsService++ try:+ updates = [u for u in check_for_updates() if u.get('update_available')]+ except Exception as e:+ logger.debug(f'Extension update check skipped: {e}')+ return None+ if not updates:+ return None++ fingerprint = _json.dumps(sorted(+ f"{u.get('slug')}@{u.get('available_version')}" for u in updates))+ marker_key = 'extensions.update_notified'+ if fingerprint == SettingsService.get(marker_key, ''):+ return {'updates': len(updates), 'notified': False}++ summary = ', '.join(+ f"{u.get('slug')} v{u.get('installed_version')} → v{u.get('available_version')}"+ for u in updates[:5])+ if len(updates) > 5:+ summary += f' (+{len(updates) - 5} more)'++ from app.notifications.sdk import NotifySdk+ NotifySdk().send(+ 'extensions.updates_available',+ to='admins',+ data={'count': len(updates), 'summary': summary,+ 'message': f'Updates available: {summary}. '+ f'Review them on the Marketplace → Installed tab.'},+ )+ SettingsService.set(marker_key, fingerprint)+ return {'updates': len(updates), 'notified': True}++# ---------------------------------------------------------------------------# Handler registration + schedule seeding# ---------------------------------------------------------------------------@@ -279,6 +323,7 @@ _BUILTINS = [('builtin.pairing_prune', run_pairing_prune, 'pairing-prune', 3600, 60),('builtin.registrar_expiry', run_registrar_expiry, 'registrar-expiry', 86400, 300),('builtin.backup_scheduler', run_backup_scheduler, 'backup-scheduler', 30, 30),+ ('builtin.extension_updates', run_extension_update_check, 'extension-updates', 86400, 600),]diff --git a/backend/app/notifications/catalog.py b/backend/app/notifications/catalog.pyindex f9fc7b9b..c502a29f 100644--- a/backend/app/notifications/catalog.py+++ b/backend/app/notifications/catalog.py@@ -67,6 +67,13 @@ _CATALOG = {'severity': 'warning','category': 'system',},+ # Daily registry check found newer versions of installed extensions (#50).+ 'extensions.updates_available': {+ 'title': 'Extension updates available ({count})',+ 'template': 'generic',+ 'severity': 'info',+ 'category': 'system',+ },# Managed-sites publishing readiness — nudged when a site is created but the# base-domain / DNS / HTTPS config is only partly set up.'sites.publish.no_base_domain': {diff --git a/backend/tests/test_jobs.py b/backend/tests/test_jobs.pyindex 555541d6..c62bf987 100644--- a/backend/tests/test_jobs.py+++ b/backend/tests/test_jobs.py@@ -174,13 +174,14 @@ class TestBuiltins:assert 'builtin.auto_sync' in kindsassert 'builtin.health_check' in kindsassert 'builtin.backup_scheduler' in kinds- assert len([k for k in kinds if k.startswith('builtin.')]) == 9+ assert 'builtin.extension_updates' in kinds+ assert len([k for k in kinds if k.startswith('builtin.')]) == 10builtin_handlers.seed_builtin_schedules()- assert ScheduledJob.query.count() == 9+ assert ScheduledJob.query.count() == 10# Seeding twice doesn't duplicate.builtin_handlers.seed_builtin_schedules()- assert ScheduledJob.query.count() == 9+ assert ScheduledJob.query.count() == 10class TestApi:diff --git a/backend/tests/test_plugins_pipeline.py b/backend/tests/test_plugins_pipeline.pyindex 7a28ac36..1da5e4fe 100644--- a/backend/tests/test_plugins_pipeline.py+++ b/backend/tests/test_plugins_pipeline.py@@ -267,6 +267,57 @@ def test_plugin_config_rejects_non_object(app, client, auth_headers, plugin_dirsassert r.status_code == 400+# --------------------------------------------------------------------------- #+# Scheduled extension-update check (#50)+# --------------------------------------------------------------------------- #++def test_extension_update_check_notifies_admins_once_per_release(app, monkeypatch):+ """The daily job notifies admins when updates appear, then stays quiet for+ the same release set, and speaks up again when the set changes."""+ from app.jobs import builtin_handlers+ from app.notifications.sdk import NotifySdk++ sent = []+ monkeypatch.setattr(+ NotifySdk, 'send',+ lambda self, event, to=None, data=None, **kw: sent.append((event, to, data)))++ updates = [{'slug': 'serverkit-gui', 'installed_version': '1.0.0',+ 'available_version': '1.1.0', 'update_available': True}]+ monkeypatch.setattr(+ 'app.services.plugin_service.check_for_updates', lambda: updates)++ result = builtin_handlers.run_extension_update_check()+ assert result == {'updates': 1, 'notified': True}+ assert sent and sent[0][0] == 'extensions.updates_available'+ assert sent[0][1] == 'admins'+ assert 'serverkit-gui' in sent[0][2]['summary']++ # Same release set → no second notification.+ result = builtin_handlers.run_extension_update_check()+ assert result == {'updates': 1, 'notified': False}+ assert len(sent) == 1++ # A newer release changes the fingerprint → notify again.+ updates[0]['available_version'] = '1.2.0'+ result = builtin_handlers.run_extension_update_check()+ assert result == {'updates': 1, 'notified': True}+ assert len(sent) == 2+++def test_extension_update_check_quiet_when_no_updates(app, monkeypatch):+ from app.jobs import builtin_handlers+ monkeypatch.setattr('app.services.plugin_service.check_for_updates', lambda: [])+ assert builtin_handlers.run_extension_update_check() is None+++def test_extension_update_schedule_is_seeded():+ """The builtin schedule table includes the daily extension-update check."""+ from app.jobs.builtin_handlers import _BUILTINS+ kinds = {b[0] for b in _BUILTINS}+ assert 'builtin.extension_updates' in kinds++# --------------------------------------------------------------------------- ## Boot repair pass (#48): plugins whose files a panel update wiped# --------------------------------------------------------------------------- #