feat(v3.13.0): settings live DB reads, remove Directus/Appwrite, admin stats

Settings fixes:
- MAX_SITES_PER_USER, USER_RATE_LIMIT_PER_MIN/HR now read from DB settings
  table (DB > ENV > default), so dashboard/settings changes apply without
  restart. Sync cache refreshed on every save or delete.
- /api/me reports the live DB value for max_sites_per_user.

Admin improvements:
- Admin users bypass per-user rate limiting entirely (role=admin or ADMIN_EMAILS).
- Admin Overview now shows platform stats: registered users, new users (7d),
  total user sites, available tools.

Plugin cleanup:
- Appwrite and Directus plugins removed from the active registry (8 plugins
  now: WordPress, WooCommerce, WordPress Specialist, Gitea, n8n, Supabase,
  OpenPanel, Coolify). Plugin code is retained for future re-enabling.
- Settings page plugin visibility list updated to match.

Mobile onboarding:
- Stepper steps on narrow viewports stack vertically with correct full border
  and rounded corners on each step.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-20 23:33:20 +02:00
parent f203ca88de
commit 43fd2201a0
223 changed files with 36183 additions and 4115 deletions

View File

@@ -360,3 +360,80 @@ class TestMetadataHelpers:
def test_allowed_mimes_includes_common_types():
for m in ("image/jpeg", "image/png", "image/webp", "application/pdf"):
assert m in ALLOWED_MIMES
# --- set_featured fallback (issue #90 gap 5) -------------------------------
class TestSetFeaturedFallback:
@pytest.mark.asyncio
async def test_falls_back_to_pages_when_post_id_invalid(self):
from plugins.wordpress.handlers.media import _set_featured_with_fallback
client = _client()
async def fake_set_featured(_c, _post_id, _media_id):
raise RuntimeError("Invalid post ID")
with (
patch(
"plugins.wordpress.handlers.media.wp_set_featured_media",
new=AsyncMock(side_effect=fake_set_featured),
),
patch.object(client, "post", new=AsyncMock(return_value={"id": 87})) as mock_post,
):
ctx = await _set_featured_with_fallback(client, 87, 94)
assert ctx == "page"
mock_post.assert_awaited_once_with("pages/87", json_data={"featured_media": 94})
@pytest.mark.asyncio
async def test_falls_back_to_thumbnail_supporting_cpt(self):
from plugins.wordpress.handlers.media import _set_featured_with_fallback
client = _client()
async def fail_post(path, **_):
if path.startswith(("posts/", "pages/")):
raise RuntimeError("Invalid post ID")
return {"id": 200}
async def fake_get(path, **_):
assert path == "types"
return {
"post": {"rest_base": "posts", "supports": {"thumbnail": True}},
"page": {"rest_base": "pages", "supports": {"thumbnail": True}},
"portfolio": {"rest_base": "portfolio", "supports": {"thumbnail": True}},
"no_thumb_cpt": {"rest_base": "no_thumb_cpt", "supports": {}},
}
with (
patch(
"plugins.wordpress.handlers.media.wp_set_featured_media",
new=AsyncMock(side_effect=RuntimeError("Invalid post ID")),
),
patch.object(client, "post", new=AsyncMock(side_effect=fail_post)) as mock_post,
patch.object(client, "get", new=AsyncMock(side_effect=fake_get)),
):
ctx = await _set_featured_with_fallback(client, 200, 9)
assert ctx == "portfolio"
# Should have tried pages/200 then portfolio/200 (no_thumb_cpt skipped).
called_paths = [c.args[0] for c in mock_post.await_args_list]
assert "pages/200" in called_paths
assert "portfolio/200" in called_paths
assert "no_thumb_cpt/200" not in called_paths
@pytest.mark.asyncio
async def test_returns_none_when_nothing_accepts(self):
from plugins.wordpress.handlers.media import _set_featured_with_fallback
client = _client()
with (
patch(
"plugins.wordpress.handlers.media.wp_set_featured_media",
new=AsyncMock(side_effect=RuntimeError("Invalid post ID")),
),
patch.object(client, "post", new=AsyncMock(side_effect=RuntimeError("nope"))),
patch.object(client, "get", new=AsyncMock(return_value={})),
):
ctx = await _set_featured_with_fallback(client, 9999, 1)
assert ctx is None

View File

@@ -8,7 +8,7 @@ from unittest.mock import AsyncMock, patch
import pytest
from plugins.ai_image.providers.base import GenerationRequest, ProviderError
from plugins.ai_image.providers.base import GenerationRequest
from plugins.ai_image.providers.openrouter import (
_MODEL_PRICING,
OpenRouterProvider,
@@ -145,13 +145,35 @@ class TestGenerateAttributesCost:
class TestDeprecatedModelGuard:
@pytest.mark.asyncio
async def test_preview_model_raises_model_deprecated(self):
async def test_preview_model_silently_substitutes_to_ga(self, caplog):
"""Issue #90 — deprecated model id is auto-rewritten to the GA alias."""
provider = OpenRouterProvider()
with pytest.raises(ProviderError) as e:
await provider.generate(
"k",
GenerationRequest(prompt="x", model="google/gemini-2.5-flash-image-preview"),
b64 = base64.b64encode(_PNG_1x1).decode()
ok = _fake_resp(
status=200,
json_data={
"choices": [
{
"message": {
"images": [{"image_url": {"url": f"data:image/png;base64,{b64}"}}]
}
}
]
},
)
sess = _mock_session([ok])
with patch("plugins.ai_image.providers.openrouter.aiohttp.ClientSession") as cls:
cls.return_value = AsyncMock(
__aenter__=AsyncMock(return_value=sess),
__aexit__=AsyncMock(return_value=False),
)
assert e.value.code == "PROVIDER_MODEL_DEPRECATED"
assert "google/gemini-2.5-flash-image" in str(e.value.message)
assert e.value.details.get("replacement_model") == "google/gemini-2.5-flash-image"
with caplog.at_level("WARNING", logger="mcphub.ai_image.openrouter"):
result = await provider.generate(
"k",
GenerationRequest(prompt="x", model="google/gemini-2.5-flash-image-preview"),
)
assert result.meta["model"] == "google/gemini-2.5-flash-image"
assert any(
"is deprecated" in rec.message and "google/gemini-2.5-flash-image" in rec.message
for rec in caplog.records
)