diff --git a/dist/immich.js b/dist/immich.js index 00757e3..9baa255 100644 --- a/dist/immich.js +++ b/dist/immich.js @@ -40,16 +40,25 @@ class Immich { */ getShareByKey(key) { return tslib_1.__awaiter(this, void 0, void 0, function* () { + var _a; const res = ((yield this.request('/shared-links')) || []); 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 && (0, dayjs_1.default)(link.expiresAt) < (0, dayjs_1.default)()) { // This link has expired (0, index_1.log)('Expired link ' + key); } else { + if (link.type === 'ALBUM') { + // Fetch the assets from the album and populate the SharedLink assets array + const albumId = (_a = link.album) === null || _a === void 0 ? void 0 : _a.id; + if (albumId) { + const album = (yield this.request('/albums/' + encodeURIComponent(albumId))); + link.assets = album.assets || []; + } + } + // Filter assets to exclude trashed assets + link.assets = link.assets.filter(x => !x.isTrashed); return link; } } @@ -108,4 +117,4 @@ class Immich { } const immich = new Immich(); exports.default = immich; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW1taWNoLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2ltbWljaC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSxtQ0FBaUU7QUFDakUsMERBQXlCO0FBQ3pCLG1DQUE2QjtBQUU3QixNQUFNLE1BQU07SUFDVjs7O09BR0c7SUFDRyxPQUFPLENBQUUsUUFBZ0I7O1lBQzdCLE1BQU0sR0FBRyxHQUFHLE1BQU0sS0FBSyxDQUFDLE9BQU8sQ0FBQyxHQUFHLENBQUMsVUFBVSxHQUFHLE1BQU0sR0FBRyxRQUFRLEVBQUU7Z0JBQ2xFLE9BQU8sRUFBRTtvQkFDUCxXQUFXLEVBQUUsT0FBTyxDQUFDLEdBQUcsQ0FBQyxPQUFPLElBQUksRUFBRTtpQkFDdkM7YUFDRixDQUFDLENBQUE7WUFDRixJQUFJLEdBQUcsQ0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0vJHtpZH1gICsgKHNpemUgPyBgP3NpemU9JHtzaXplfWAgOiAnJylcbiAgfVxuXG4gIC8qKlxuICAgKiBSZXR1cm4gdGhlIHZpZGVvIGRhdGEgVVJMIGZvciBhIHZpZGVvXG4gICAqL1xuICB2aWRlb1VybCAoa2V5OiBzdHJpbmcsIGlkOiBzdHJpbmcpIHtcbiAgICByZXR1cm4gYC92aWRlby8ke2tleX0vJHtpZH1gXG4gIH1cblxuICAvKipcbiAgICogQ2hlY2sgaWYgYSBwcm92aWRlZCBJRCBtYXRjaGVzIHRoZSBJbW1pY2ggSUQgZm9ybWF0XG4gICAqL1xuICBpc0lkIChpZDogc3RyaW5nKSB7XG4gICAgcmV0dXJuICEhaWQubWF0Y2goL15bMC05YS1mXXs4fS1bMC05YS1mXXs0fS1bMC05YS1mXXs0fS1bMC05YS1mXXs0fS1bMC05YS1mXXsxMn0kLylcbiAgfVxuXG4gIC8qKlxuICAgKiBDaGVjayBpZiBhIHByb3ZpZGVkIGtleSBtYXRjaGVzIHRoZSBJbW1pY2ggc2hhcmVkLWxpbmsga2V5IGZvcm1hdFxuICAgKi9cbiAgaXNLZXkgKGtleTogc3RyaW5nKSB7XG4gICAgcmV0dXJuICEha2V5Lm1hdGNoKC9eW1xcdy1dKyQvKVxuICB9XG59XG5cbmNvbnN0IGltbWljaCA9IG5ldyBJbW1pY2goKVxuXG5leHBvcnQgZGVmYXVsdCBpbW1pY2hcbiJdfQ== \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW1taWNoLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2ltbWljaC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSxtQ0FBd0U7QUFDeEUsMERBQXlCO0FBQ3pCLG1DQUE2QjtBQUU3QixNQUFNLE1BQU07SUFDVjs7O09BR0c7SUFDRyxPQUFPLENBQUUsUUFBZ0I7O1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hvdG9VcmwgKGtleTogc3RyaW5nLCBpZDogc3RyaW5nLCBzaXplPzogSW1hZ2VTaXplKSB7XG4gICAgcmV0dXJuIGAvcGhvdG8vJHtrZXl9LyR7aWR9YCArIChzaXplID8gYD9zaXplPSR7c2l6ZX1gIDogJycpXG4gIH1cblxuICAvKipcbiAgICogUmV0dXJuIHRoZSB2aWRlbyBkYXRhIFVSTCBmb3IgYSB2aWRlb1xuICAgKi9cbiAgdmlkZW9VcmwgKGtleTogc3RyaW5nLCBpZDogc3RyaW5nKSB7XG4gICAgcmV0dXJuIGAvdmlkZW8vJHtrZXl9LyR7aWR9YFxuICB9XG5cbiAgLyoqXG4gICAqIENoZWNrIGlmIGEgcHJvdmlkZWQgSUQgbWF0Y2hlcyB0aGUgSW1taWNoIElEIGZvcm1hdFxuICAgKi9cbiAgaXNJZCAoaWQ6IHN0cmluZykge1xuICAgIHJldHVybiAhIWlkLm1hdGNoKC9eWzAtOWEtZl17OH0tWzAtOWEtZl17NH0tWzAtOWEtZl17NH0tWzAtOWEtZl17NH0tWzAtOWEtZl17MTJ9JC8pXG4gIH1cblxuICAvKipcbiAgICogQ2hlY2sgaWYgYSBwcm92aWRlZCBrZXkgbWF0Y2hlcyB0aGUgSW1taWNoIHNoYXJlZC1saW5rIGtleSBmb3JtYXRcbiAgICovXG4gIGlzS2V5IChrZXk6IHN0cmluZykge1xuICAgIHJldHVybiAhIWtleS5tYXRjaCgvXltcXHctXSskLylcbiAgfVxufVxuXG5jb25zdCBpbW1pY2ggPSBuZXcgSW1taWNoKClcblxuZXhwb3J0IGRlZmF1bHQgaW1taWNoXG4iXX0= \ No newline at end of file diff --git a/dist/types.js b/dist/types.js index a14bfb7..fdf5409 100644 --- a/dist/types.js +++ b/dist/types.js @@ -11,4 +11,4 @@ var ImageSize; ImageSize["thumbnail"] = "thumbnail"; ImageSize["original"] = "original"; })(ImageSize || (exports.ImageSize = ImageSize = {})); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uI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sV0FBWSxTQUFTO0lBQ25CLDRCQUFlLENBQUE7SUFDZiw0QkFBZSxDQUFBO0FBQ2pCLENBQUMsRUFIVyxTQUFTLHlCQUFULFNBQVMsUUFHcEI7QUFzQkQsSUFBWSxTQUdYO0FBSEQsV0FBWSxTQUFTO0lBQ25CLG9DQUF1QixDQUFBO0lBQ3ZCLGtDQUFxQixDQUFBO0FBQ3ZCLENBQUMsRUFIVyxTQUFTLHlCQUFULFNBQVMsUUFHcEIiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgZW51bSBBc3NldFR5cGUge1xuICBpbWFnZSA9ICdJTUFHRScsXG4gIHZpZGVvID0gJ1ZJREVPJ1xufVxuXG5leHBvcnQgaW50ZXJmYWNlIEFzc2V0IHtcbiAgaWQ6IHN0cmluZztcbiAgdHlwZTogQXNzZXRUeXBlO1xuICBpc1RyYXNoZWQ6IGJvb2xlYW47XG59XG5cbmV4cG9ydCBpbnRlcmZhY2UgU2hhcmVkTGluayB7XG4gIGtleTogc3RyaW5nO1xuICB0eXBlOiBzdHJpbmc7XG4gIGFzc2V0czogQXNzZXRbXTtcbiAgYWxidW0/OiB7XG4gICAgaWQ6IHN0cmluZztcbiAgfVxuICBleHBpcmVzQXQ6IHN0cmluZyB8IG51bGw7XG59XG5cbmV4cG9ydCBpbnRlcmZhY2UgQWxidW0ge1xuICBhc3NldHM6IEFzc2V0W11cbn1cblxuZXhwb3J0IGVudW0gSW1hZ2VTaXplIHtcbiAgdGh1bWJuYWlsID0gJ3RodW1ibmFpbCcsXG4gIG9yaWdpbmFsID0gJ29yaWdpbmFsJ1xufVxuIl19 \ No newline at end of file diff --git a/src/immich.ts b/src/immich.ts index 4879e03..3228dd9 100644 --- a/src/immich.ts +++ b/src/immich.ts @@ -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 } } diff --git a/src/types.ts b/src/types.ts index 2a0b4a9..ceadb0b 100644 --- a/src/types.ts +++ b/src/types.ts @@ -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'