1
0
Fork 0

Merge pull request #3125 from hughrun/instance-actor

hide instance actor from users
This commit is contained in:
Mouse Reeve 2023-11-19 19:11:17 -08:00 committed by GitHub
commit d8018cb937
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 115 additions and 69 deletions

View file

@ -11,6 +11,7 @@ from django.utils.decorators import method_decorator
from django.views import View
from bookwyrm import book_search, forms, models
from bookwyrm.settings import INSTANCE_ACTOR_USERNAME
from bookwyrm.suggested_users import suggested_users
from .preferences.edit_user import save_user_form
@ -108,6 +109,7 @@ class GetStartedUsers(View):
.exclude(
id=request.user.id,
)
.exclude(localname=INSTANCE_ACTOR_USERNAME)
.order_by("-similarity")[:5]
)
data = {"no_results": not user_results}

View file

@ -13,7 +13,7 @@ from csp.decorators import csp_update
from bookwyrm import models
from bookwyrm.connectors import connector_manager
from bookwyrm.book_search import search, format_search_result
from bookwyrm.settings import PAGE_LENGTH
from bookwyrm.settings import PAGE_LENGTH, INSTANCE_ACTOR_USERNAME
from bookwyrm.utils import regex
from .helpers import is_api_request
from .helpers import handle_remote_webfinger
@ -113,6 +113,7 @@ def user_search(request):
.filter(
similarity__gt=0.5,
)
.exclude(localname=INSTANCE_ACTOR_USERNAME)
.order_by("-similarity")
)

View file

@ -11,7 +11,7 @@ from django.views.decorators.http import require_POST
from bookwyrm import models
from bookwyrm.activitypub import ActivitypubResponse
from bookwyrm.settings import PAGE_LENGTH
from bookwyrm.settings import PAGE_LENGTH, INSTANCE_ACTOR_USERNAME
from .helpers import get_user_from_username, is_api_request
@ -31,6 +31,10 @@ class User(View):
return ActivitypubResponse(user.to_activity())
# otherwise we're at a UI view
# if it's not an API request, never show the instance actor profile page
if user.localname == INSTANCE_ACTOR_USERNAME:
raise Http404()
shelf_preview = []
# only show shelves that should be visible