1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-08-06 05:35:19 +02:00

Refactor location handling in Immich integration components for consistency

This commit is contained in:
Sean Morley 2025-06-26 09:58:11 -04:00
parent 1f94b39b27
commit 10418f85cc
3 changed files with 8 additions and 8 deletions

View file

@ -297,7 +297,7 @@ class ImmichIntegrationView(viewsets.ViewSet):
is_authorized = True is_authorized = True
# Level 3: Owner access # Level 3: Owner access
elif request.user.is_authenticated and request.user.id == owner_id: elif request.user.is_authenticated and request.user == owner_id:
is_authorized = True is_authorized = True
# Level 4: Shared collection access - check if user has access to any collection # Level 4: Shared collection access - check if user has access to any collection
@ -314,7 +314,7 @@ class ImmichIntegrationView(viewsets.ViewSet):
}, status=status.HTTP_403_FORBIDDEN) }, status=status.HTTP_403_FORBIDDEN)
else: else:
# No LocationImage exists; allow only the integration owner # No LocationImage exists; allow only the integration owner
if not request.user.is_authenticated or request.user.id != owner_id: if not request.user.is_authenticated or request.user != owner_id:
return Response({ return Response({
'message': 'Image is not linked to any location and you are not the owner.', 'message': 'Image is not linked to any location and you are not the owner.',
'error': True, 'error': True,

View file

@ -12,7 +12,7 @@
let immichNextURL: string = ''; let immichNextURL: string = '';
let loading = false; let loading = false;
export let adventure: Location | null = null; export let location: Location | null = null;
export let copyImmichLocally: boolean = false; export let copyImmichLocally: boolean = false;
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
@ -21,7 +21,7 @@
let currentAlbum: string = ''; let currentAlbum: string = '';
let selectedDate: string = let selectedDate: string =
(adventure as Location | null)?.visits (location as Location | null)?.visits
.map((v) => new Date(v.end_date || v.start_date)) .map((v) => new Date(v.end_date || v.start_date))
.sort((a, b) => +b - +a)[0] .sort((a, b) => +b - +a)[0]
?.toISOString() ?.toISOString()
@ -57,8 +57,8 @@
} }
async function saveImmichRemoteUrl(imageId: string) { async function saveImmichRemoteUrl(imageId: string) {
if (!adventure) { if (!location) {
console.error('No adventure provided to save the image URL'); console.error('No location provided to save the image URL');
return; return;
} }
let res = await fetch('/api/images', { let res = await fetch('/api/images', {
@ -68,7 +68,7 @@
}, },
body: JSON.stringify({ body: JSON.stringify({
immich_id: imageId, immich_id: imageId,
adventure: adventure.id location: location.id
}) })
}); });
if (res.ok) { if (res.ok) {

View file

@ -847,7 +847,7 @@
{#if immichIntegration} {#if immichIntegration}
<ImmichSelect <ImmichSelect
adventure={location} {location}
on:fetchImage={(e) => { on:fetchImage={(e) => {
url = e.detail; url = e.detail;
fetchImage(); fetchImage();