Can now serve track from remote library

This commit is contained in:
Eliot Berriot 2018-04-07 15:34:35 +02:00
parent b29ca44797
commit 9612b1bace
No known key found for this signature in database
GPG key ID: DD6965E2476E5C27
22 changed files with 272 additions and 140 deletions

View file

@ -0,0 +1,23 @@
from django.conf import settings
from rest_framework.permissions import BasePermission
from funkwhale_api.federation import actors
class Listen(BasePermission):
def has_permission(self, request, view):
if not settings.PROTECT_AUDIO_FILES:
return True
user = getattr(request, 'user', None)
if user and user.is_authenticated:
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()