diff --git a/backend/server/integrations/views/integration_view.py b/backend/server/integrations/views/integration_view.py index 2e35934..7a391bd 100644 --- a/backend/server/integrations/views/integration_view.py +++ b/backend/server/integrations/views/integration_view.py @@ -2,6 +2,7 @@ import os from rest_framework.response import Response from rest_framework import viewsets, status from rest_framework.permissions import IsAuthenticated +from django.utils import timezone from integrations.models import ImmichIntegration, StravaToken, WandererIntegration from django.conf import settings @@ -17,6 +18,12 @@ class IntegrationView(viewsets.ViewSet): strava_integration_global = settings.STRAVA_CLIENT_ID != '' and settings.STRAVA_CLIENT_SECRET != '' strava_integration_user = StravaToken.objects.filter(user=request.user).exists() wanderer_integration = WandererIntegration.objects.filter(user=request.user).exists() + is_wanderer_expired = False + + if wanderer_integration: + token_expiry = WandererIntegration.objects.filter(user=request.user).first().token_expiry + if token_expiry and token_expiry < timezone.now(): + is_wanderer_expired = True return Response( { @@ -26,7 +33,10 @@ class IntegrationView(viewsets.ViewSet): 'global': strava_integration_global, 'user': strava_integration_user }, - 'wanderer': wanderer_integration + 'wanderer': { + 'exists': wanderer_integration, + 'expired': is_wanderer_expired + } }, status=status.HTTP_200_OK ) diff --git a/backend/server/integrations/views/wanderer_view.py b/backend/server/integrations/views/wanderer_view.py index aec5794..ffd8802 100644 --- a/backend/server/integrations/views/wanderer_view.py +++ b/backend/server/integrations/views/wanderer_view.py @@ -113,8 +113,8 @@ class WandererIntegrationViewSet(viewsets.ViewSet): "is_connected": True, }) - @action(detail=False, methods=["get"], url_path='list') - def list_trails(self, request): + @action(detail=False, methods=["get"], url_path='trails') + def trails(self, request): inst = self._get_obj() # Check if we need to prompt for password @@ -131,9 +131,12 @@ class WandererIntegrationViewSet(viewsets.ViewSet): }) raise ValidationError({"detail": str(e)}) - url = f"{inst.server_url.rstrip('/')}/api/v1/list" + # Pass along all query parameters except password + params = {k: v for k, v in request.query_params.items() if k != "password"} + + url = f"{inst.server_url.rstrip('/')}/api/v1/trail" try: - response = session.get(url, timeout=10) + response = session.get(url, params=params, timeout=10) response.raise_for_status() except requests.RequestException as exc: raise ValidationError({"detail": f"Error fetching trails: {exc}"}) diff --git a/frontend/src/lib/components/TrailCard.svelte b/frontend/src/lib/components/TrailCard.svelte new file mode 100644 index 0000000..f4062c0 --- /dev/null +++ b/frontend/src/lib/components/TrailCard.svelte @@ -0,0 +1,108 @@ + + +
+ {stripHtml(trail.description).substring(0, 150)}... +
++ Select a trail from your Wanderer account: +
+ + ++ {wandererFetchedTrails.length} trail(s) found for "{searchQuery}" +
+ {/if} + + ++ Wanderer integration is not enabled or has expired. +
+ {/if} + +