Secure Sakani portal and show full album titles

This commit is contained in:
Leon Tonhäuser committed 2026-11-30 19:14:57 +01:00
1 parent c40ccf77cf
commit 69264ce165
49 files changed
+1362 -601

No files matched your search

+13 -1
View File
@@ -24,6 +24,7 @@ export type ClaimedDownload = {
id: string;
usageId: string;
assetId: string;
albumId: string;
filename: string;
intentKind: "new_usage" | "repeat_download" | "legacy";
};
@@ -160,6 +161,8 @@ export function createDownloadDeliveryRepository(
const [usage] = await transaction
.select({
filename: usages.filenameSnapshot,
assetId: usages.immichAssetId,
albumId: usages.immichAlbumIdSnapshot,
billingStatus: usages.billingStatus,
})
.from(usages)
@@ -171,7 +174,7 @@ export function createDownloadDeliveryRepository(
)
.for("update")
.limit(1);
if (!usage) return { outcome: "not_found" } as const;
if (!usage || usage.assetId !== candidate.assetId) return { outcome: "not_found" } as const;
const intentKind = claimedIntentKind(candidate.intentKind);
const deliveredOriginal =
@@ -208,6 +211,7 @@ export function createDownloadDeliveryRepository(
id: candidate.id,
usageId: candidate.usageId,
assetId: candidate.assetId,
albumId: usage.albumId,
filename: usage.filename,
intentKind,
},
@@ -603,6 +607,7 @@ export function createEditorialDownloadOptionsLoader(
return async function loadOptions(
editorialId: string,
assetIds: string[],
allowPriorUsage?: (assetId: string, albumId: string) => Promise<boolean>,
): Promise<EditorialDownloadOptions> {
const normalizedEditorialId = normalizeUuid(editorialId);
const normalizedAssets = [...new Set(assetIds.map(normalizeUuid))];
@@ -636,6 +641,7 @@ export function createEditorialDownloadOptionsLoader(
id: usages.id,
assetId: usages.immichAssetId,
purpose: usages.purpose,
albumId: usages.immichAlbumIdSnapshot,
createdAt: usages.createdAt,
})
.from(usages)
@@ -650,7 +656,13 @@ export function createEditorialDownloadOptionsLoader(
.orderBy(desc(usages.createdAt), desc(usages.id))
.limit(DOWNLOAD_OPTIONS_MAX_USAGES);
const priorUsagesByAsset: Record<string, DownloadDialogUsage[]> = {};
const allowed = new Map<string, boolean>();
for (const row of rows) {
if (allowPriorUsage) {
const scope = `${row.assetId}:${row.albumId}`;
if (!allowed.has(scope)) allowed.set(scope, await allowPriorUsage(row.assetId, row.albumId));
if (!allowed.get(scope)) continue;
}
(priorUsagesByAsset[row.assetId] ??= []).push({
id: row.id,
purpose: row.purpose,