Preview auto tags in bookmark form (#737)

This commit is contained in:
Sascha Ißbrücker
2024-06-16 10:04:38 +02:00
committed by GitHub
parent 469883a674
commit 44b49a4cfe
5 changed files with 81 additions and 9 deletions

View File

@@ -11,6 +11,7 @@ from bookmarks.api.serializers import (
UserProfileSerializer,
)
from bookmarks.models import Bookmark, BookmarkSearch, Tag, User
from bookmarks.services import auto_tagging
from bookmarks.services.bookmarks import (
archive_bookmark,
unarchive_bookmark,
@@ -107,8 +108,18 @@ class BookmarkViewSet(
else:
metadata = website_loader.load_website_metadata(url)
# Return tags that would be automatically applied to the bookmark
profile = request.user.profile
auto_tags = []
if profile.auto_tagging_rules:
auto_tags = auto_tagging.get_tags(profile.auto_tagging_rules, url)
return Response(
{"bookmark": existing_bookmark_data, "metadata": metadata.to_dict()},
{
"bookmark": existing_bookmark_data,
"metadata": metadata.to_dict(),
"auto_tags": auto_tags,
},
status=status.HTTP_200_OK,
)