Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

fix(immich): check all trips when verifying shared photo access

jubnlae0d48ac83e1
diff --git a/server/src/services/immichService.ts b/server/src/services/immichService.ts
index aceb8c007..042908687 100644
--- a/server/src/services/immichService.ts
+++ b/server/src/services/immichService.ts
@@ -236,12 +236,12 @@ export function togglePhotoSharing(tripId: string, userId: number, assetId: stri
* the same trip that contains the photo.
*/
export function canAccessUserPhoto(requestingUserId: number, ownerUserId: number, assetId: string): boolean {
- const row = db.prepare(`
+ const rows = db.prepare(`
SELECT tp.trip_id FROM trip_photos tp
WHERE tp.immich_asset_id = ? AND tp.user_id = ? AND tp.shared = 1
- `).get(assetId, ownerUserId) as { trip_id: number } | undefined;
- if (!row) return false;
- return !!canAccessTrip(String(row.trip_id), requestingUserId);
+ `).all(assetId, ownerUserId) as { trip_id: number }[];
+ if (rows.length === 0) return false;
+ return rows.some(row => !!canAccessTrip(String(row.trip_id), requestingUserId));
}
export async function getAssetInfo(