Merge branch 'main' into suggestions-redis
This commit is contained in:
@ -13,6 +13,10 @@ from bookwyrm.utils import regex
|
||||
|
||||
def get_user_from_username(viewer, username):
|
||||
"""helper function to resolve a localname or a username to a user"""
|
||||
if viewer.is_authenticated and viewer.localname == username:
|
||||
# that's yourself, fool
|
||||
return viewer
|
||||
|
||||
# raises 404 if the user isn't found
|
||||
try:
|
||||
return models.User.viewer_aware_objects(viewer).get(localname=username)
|
||||
@ -34,7 +38,7 @@ def is_api_request(request):
|
||||
def is_bookwyrm_request(request):
|
||||
"""check if the request is coming from another bookwyrm instance"""
|
||||
user_agent = request.headers.get("User-Agent")
|
||||
if user_agent is None or re.search(regex.bookwyrm_user_agent, user_agent) is None:
|
||||
if user_agent is None or re.search(regex.BOOKWYRM_USER_AGENT, user_agent) is None:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
Reference in New Issue
Block a user