mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 22:59:17 +02:00
Dedicated permission to access library data via activity pub
This commit is contained in:
parent
b75872866c
commit
4ce9f9bf08
2 changed files with 64 additions and 0 deletions
19
api/funkwhale_api/federation/permissions.py
Normal file
19
api/funkwhale_api/federation/permissions.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
from django.conf import settings
|
||||
|
||||
from rest_framework.permissions import BasePermission
|
||||
|
||||
from . import actors
|
||||
|
||||
|
||||
class LibraryFollower(BasePermission):
|
||||
|
||||
def has_permission(self, request, view):
|
||||
if not settings.FEDERATION_MUSIC_NEEDS_APPROVAL:
|
||||
return True
|
||||
|
||||
actor = getattr(request, 'actor', None)
|
||||
if actor is None:
|
||||
return False
|
||||
|
||||
library = actors.SYSTEM_ACTORS['library'].get_actor_instance()
|
||||
return library.followers.filter(url=actor.url).exists()
|
Loading…
Add table
Add a link
Reference in a new issue