Tried to fix a broke filter.
Build LinkLog Development Image / development-image (push) Successful in 10s
Build LinkLog Development Image / development-image (push) Successful in 10s
This commit is contained in:
@@ -6,7 +6,6 @@ from fastapi import APIRouter, Depends, Header, HTTPException, Response, status
|
||||
import logging
|
||||
from pydantic import BaseModel
|
||||
|
||||
from backend.app.api.dependencies import get_optional_current_user
|
||||
from backend.app.services.link_service import create_link, delete_link, find_owned_link_by_title_url, get_link_tags, get_owned_link, list_public_links, list_tags, mark_mastodon_posted, update_link
|
||||
from backend.app.database import get_connection
|
||||
from backend.app.services.plugin_manager import plugin_manager
|
||||
@@ -35,9 +34,8 @@ class LinkUpdate(BaseModel):
|
||||
|
||||
|
||||
@router.get('/tags')
|
||||
def available_tags(user: dict | None = Depends(get_optional_current_user)):
|
||||
user_id = user['id'] if user else None
|
||||
return list_tags(user_id=user_id)
|
||||
def available_tags():
|
||||
return list_tags()
|
||||
|
||||
|
||||
@router.get('/scrape')
|
||||
|
||||
@@ -227,32 +227,9 @@ def list_public_users():
|
||||
return [row['username'] for row in rows]
|
||||
|
||||
|
||||
def list_tags(user_id: str | None = None):
|
||||
def list_tags():
|
||||
with get_connection() as conn:
|
||||
if user_id:
|
||||
rows = conn.execute(
|
||||
'''
|
||||
SELECT tags.name
|
||||
FROM tags
|
||||
LEFT JOIN users ON users.id = tags.created_by
|
||||
WHERE tags.created_by IS NULL
|
||||
OR tags.created_by = ?
|
||||
OR users.is_admin = 1
|
||||
ORDER BY tags.name
|
||||
''',
|
||||
(user_id,),
|
||||
).fetchall()
|
||||
else:
|
||||
rows = conn.execute(
|
||||
'''
|
||||
SELECT tags.name
|
||||
FROM tags
|
||||
LEFT JOIN users ON users.id = tags.created_by
|
||||
WHERE tags.created_by IS NULL
|
||||
OR users.is_admin = 1
|
||||
ORDER BY tags.name
|
||||
''',
|
||||
).fetchall()
|
||||
rows = conn.execute('SELECT name FROM tags ORDER BY name').fetchall()
|
||||
tags = []
|
||||
seen = set()
|
||||
for row in rows:
|
||||
|
||||
@@ -564,17 +564,17 @@ def test_label_visibility_isolation_and_grandfathering():
|
||||
assert '#Cybersecurity' in charlie_label_names
|
||||
assert '#BobOnlyLabel' not in charlie_label_names
|
||||
|
||||
# Bob views /api/tags (authenticated): sees Bob tag & default/grandfathered, NOT Charlie tag
|
||||
# Every user can filter by every available tag, including another user's label.
|
||||
bob_tags = client.get('/api/tags', headers=bob_headers).json()
|
||||
assert '#BobOnlyLabel' in bob_tags
|
||||
assert '#GrandfatheredLabel' in bob_tags
|
||||
assert '#CharlieOnlyLabel' not in bob_tags
|
||||
assert '#CharlieOnlyLabel' in bob_tags
|
||||
|
||||
# Anonymous views /api/tags: sees default/grandfathered, NOT Bob or Charlie tag
|
||||
# The public feed filter has the same complete tag catalog.
|
||||
anon_tags = client.get('/api/tags').json()
|
||||
assert '#GrandfatheredLabel' in anon_tags
|
||||
assert '#BobOnlyLabel' not in anon_tags
|
||||
assert '#CharlieOnlyLabel' not in anon_tags
|
||||
assert '#BobOnlyLabel' in anon_tags
|
||||
assert '#CharlieOnlyLabel' in anon_tags
|
||||
|
||||
# Bob cannot edit or delete grandfathered label
|
||||
assert client.put(f"/api/user/labels/{grandfathered_id}", headers=bob_headers, json={'name': '#RenamedGrandfathered'}).status_code == 404
|
||||
@@ -828,7 +828,11 @@ def test_public_and_admin_pages_render_html():
|
||||
assert 'if (item.is_owner && !showIdentity)' in feed_script
|
||||
assert 'deleteEntry(item, deleteButton)' in feed_script
|
||||
assert 'postToMastodon(item, mastodonButton)' in feed_script
|
||||
assert 'tag.toLowerCase() === pref.tag.toLowerCase()' in feed_script
|
||||
assert 'tag.toLowerCase() === activeTag.toLowerCase()' in feed_script
|
||||
assert 'loadFeed(event.target.value)' in feed_script
|
||||
assert 'Promise.all([loadUsers(), loadTags()]).then(() => loadFeed())' in feed_script
|
||||
assert "fetch('/api/tags', {" in feed_script
|
||||
assert 'Authorization: `Bearer ${accessToken}`' in feed_script
|
||||
assert 'return `${date.getFullYear()} ${months[date.getMonth()]} ${date.getDate()} - ${hours}:${minutes}`' in feed_script
|
||||
assert "entryMeta.className = 'entry-meta'" in feed_script
|
||||
assert "meta.className = 'meta'" in feed_script
|
||||
|
||||
Reference in New Issue
Block a user