mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 07:49:16 +02:00
Added scan endpoint to trigger a scan for a library
This commit is contained in:
parent
077a17b093
commit
dda1cd2531
4 changed files with 46 additions and 5 deletions
|
@ -25,6 +25,7 @@ from . import models
|
|||
from . import permissions
|
||||
from . import renderers
|
||||
from . import serializers
|
||||
from . import tasks
|
||||
from . import utils
|
||||
from . import webfinger
|
||||
|
||||
|
@ -186,7 +187,7 @@ class LibraryViewSet(
|
|||
)
|
||||
|
||||
@list_route(methods=['get'])
|
||||
def scan(self, request, *args, **kwargs):
|
||||
def fetch(self, request, *args, **kwargs):
|
||||
account = request.GET.get('account')
|
||||
if not account:
|
||||
return response.Response(
|
||||
|
@ -195,6 +196,19 @@ class LibraryViewSet(
|
|||
data = library.scan_from_account_name(account)
|
||||
return response.Response(data)
|
||||
|
||||
@detail_route(methods=['post'])
|
||||
def scan(self, request, *args, **kwargs):
|
||||
library = self.get_object()
|
||||
serializer = serializers.APILibraryScanSerializer(
|
||||
data=request.data
|
||||
)
|
||||
serializer.is_valid(raise_exception=True)
|
||||
id = tasks.scan_library.delay(
|
||||
library_id=library.pk,
|
||||
until=serializer.validated_data['until']
|
||||
)
|
||||
return response.Response({'task': id})
|
||||
|
||||
@list_route(methods=['get'])
|
||||
def following(self, request, *args, **kwargs):
|
||||
library_actor = actors.SYSTEM_ACTORS['library'].get_actor_instance()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue