1
0
Fork 0
mirror of https://github.com/alangrainger/immich-public-proxy.git synced 2024-12-28 03:41:58 +00:00

Fix #4 shared albums

This commit is contained in:
Alan Grainger 2024-10-30 19:53:09 +01:00
parent 43612fa89f
commit 6df65ec5b6
4 changed files with 32 additions and 7 deletions

15
dist/immich.js vendored

File diff suppressed because one or more lines are too long

2
dist/types.js vendored
View file

@ -11,4 +11,4 @@ var ImageSize;
ImageSize["thumbnail"] = "thumbnail";
ImageSize["original"] = "original";
})(ImageSize || (exports.ImageSize = ImageSize = {}));
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvdHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsSUFBWSxTQUdYO0FBSEQsV0FBWSxTQUFTO0lBQ25CLDRCQUFlLENBQUE7SUFDZiw0QkFBZSxDQUFBO0FBQ2pCLENBQUMsRUFIVyxTQUFTLHlCQUFULFNBQVMsUUFHcEI7QUFjRCxJQUFZLFNBR1g7QUFIRCxXQUFZLFNBQVM7SUFDbkIsb0NBQXVCLENBQUE7SUFDdkIsa0NBQXFCLENBQUE7QUFDdkIsQ0FBQyxFQUhXLFNBQVMseUJBQVQsU0FBUyxRQUdwQiIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBlbnVtIEFzc2V0VHlwZSB7XG4gIGltYWdlID0gJ0lNQUdFJyxcbiAgdmlkZW8gPSAnVklERU8nXG59XG5cbmV4cG9ydCBpbnRlcmZhY2UgQXNzZXQge1xuICBpZDogc3RyaW5nO1xuICB0eXBlOiBBc3NldFR5cGU7XG4gIGlzVHJhc2hlZDogYm9vbGVhbjtcbn1cblxuZXhwb3J0IGludGVyZmFjZSBTaGFyZWRMaW5rIHtcbiAga2V5OiBzdHJpbmc7XG4gIGFzc2V0czogQXNzZXRbXTtcbiAgZXhwaXJlc0F0OiBzdHJp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uZXhwb3J0IGVudW0gSW1hZ2VTaXplIHtcbiAgdGh1bWJuYWlsID0gJ3RodW1ibmFpbCcsXG4gIG9yaWdpbmFsID0gJ29yaWdpbmFsJ1xufVxuIl19

View file

@ -1,4 +1,4 @@
import { Asset, AssetType, ImageSize, SharedLink } from './types'
import { Album, Asset, AssetType, ImageSize, SharedLink } from './types'
import dayjs from 'dayjs'
import { log } from './index'
@ -37,12 +37,20 @@ class Immich {
const res = (await this.request('/shared-links') || []) as SharedLink[]
const link = res.find(x => x.key === key)
if (link) {
// Filter assets to exclude trashed assets
link.assets = link.assets.filter(x => !x.isTrashed)
if (link.expiresAt && dayjs(link.expiresAt) < dayjs()) {
// This link has expired
log('Expired link ' + key)
} else {
if (link.type === 'ALBUM') {
// Fetch the assets from the album and populate the SharedLink assets array
const albumId = link.album?.id
if (albumId) {
const album = (await this.request('/albums/' + encodeURIComponent(albumId))) as Album
link.assets = album.assets || []
}
}
// Filter assets to exclude trashed assets
link.assets = link.assets.filter(x => !x.isTrashed)
return link
}
}

View file

@ -11,10 +11,18 @@ export interface Asset {
export interface SharedLink {
key: string;
type: string;
assets: Asset[];
album?: {
id: string;
}
expiresAt: string | null;
}
export interface Album {
assets: Asset[]
}
export enum ImageSize {
thumbnail = 'thumbnail',
original = 'original'