mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2026-08-01 16:29:07 -04:00
- Introduced the Endurain integration, allowing users to connect their self-hosted Endurain instance for activity browsing and GPX import. - Added `EndurainIntegration` model, serializer, and viewset to manage user connections and activities. - Implemented MFA support for Endurain login, including token handling and validation. - Enhanced activity handling in `ActivityViewSet` to prioritize user-provided elevation data over GPX-derived values. - Updated environment configuration and documentation to include Endurain integration details. - Added tests for Endurain services and integration functionality to ensure reliability and correctness. - Improved throttling for Endurain authentication to enhance security and performance.
43 lines
1.8 KiB
Python
43 lines
1.8 KiB
Python
import os
|
|
from rest_framework.response import Response
|
|
from rest_framework import viewsets, status
|
|
from rest_framework.permissions import IsAuthenticated
|
|
from integrations.models import ImmichIntegration, StravaToken, WandererIntegration, EndurainIntegration
|
|
from django.conf import settings
|
|
|
|
|
|
class IntegrationView(viewsets.ViewSet):
|
|
permission_classes = [IsAuthenticated]
|
|
def list(self, request):
|
|
"""
|
|
RESTful GET method for listing all integrations.
|
|
"""
|
|
immich_integrations = ImmichIntegration.objects.filter(user=request.user)
|
|
immich_integration = immich_integrations.first()
|
|
google_map_integration = settings.GOOGLE_MAPS_API_KEY != ''
|
|
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()
|
|
endurain_integration = EndurainIntegration.objects.filter(user=request.user).exists()
|
|
|
|
return Response(
|
|
{
|
|
'immich': {
|
|
'exists': immich_integration is not None,
|
|
'copy_locally': immich_integration.copy_locally if immich_integration else False,
|
|
},
|
|
'google_maps': google_map_integration,
|
|
'strava': {
|
|
'global': strava_integration_global,
|
|
'user': strava_integration_user
|
|
},
|
|
'wanderer': {
|
|
'exists': wanderer_integration,
|
|
},
|
|
'endurain': {
|
|
'exists': endurain_integration,
|
|
}
|
|
},
|
|
status=status.HTTP_200_OK
|
|
)
|