Don't return trashed assets
This commit is contained in:
parent
10633942c1
commit
07a1904b9d
15
dist/immich.js
vendored
15
dist/immich.js
vendored
File diff suppressed because one or more lines are too long
2
dist/types.js
vendored
2
dist/types.js
vendored
@ -11,4 +11,4 @@ var ImageSize;
|
|||||||
ImageSize["thumbnail"] = "thumbnail";
|
ImageSize["thumbnail"] = "thumbnail";
|
||||||
ImageSize["original"] = "original";
|
ImageSize["original"] = "original";
|
||||||
})(ImageSize || (exports.ImageSize = ImageSize = {}));
|
})(ImageSize || (exports.ImageSize = ImageSize = {}));
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvdHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsSUFBWSxTQUdYO0FBSEQsV0FBWSxTQUFTO0lBQ25CLDRCQUFlLENBQUE7SUFDZiw0QkFBZSxDQUFBO0FBQ2pCLENBQUMsRUFIVyxTQUFTLHlCQUFULFNBQVMsUUFHcEI7QUFZRCxJQUFZLFNBR1g7QUFIRCxXQUFZLFNBQVM7SUFDbkIsb0NBQXVCLENBQUE7SUFDdkIsa0NBQXFCLENBQUE7QUFDdkIsQ0FBQyxFQUhXLFNBQVMseUJBQVQsU0FBUyxRQUdwQiIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBlbnVtIEFzc2V0VHlwZSB7XG4gIGltYWdlID0gJ0lNQUdFJyxcbiAgdmlkZW8gPSAnVklERU8nXG59XG5cbmV4cG9ydCBpbnRlcmZhY2UgQXNzZXQge1xuICBpZDogc3RyaW5nO1xuICB0eXBlOiBBc3NldFR5cGU7XG59XG5cbmV4cG9ydCBpbnRlcmZhY2UgU2hhcmVkTGluayB7XG4gIGtleTogc3RyaW5nO1xuICBhc3NldHM6IEFzc2V0W11cbn1cblxuZXhwb3J0IGVudW0gSW1hZ2VTaXplIHtcbiAgdGh1bWJuYWlsID0gJ3RodW1ibmFpbCcsXG4gIG9yaWdpbmFsID0gJ29yaWdpbmFsJ1xufVxuIl19
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvdHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsSUFBWSxTQUdYO0FBSEQsV0FBWSxTQUFTO0lBQ25CLDRCQUFlLENBQUE7SUFDZiw0QkFBZSxDQUFBO0FBQ2pCLENBQUMsRUFIVyxTQUFTLHlCQUFULFNBQVMsUUFHcEI7QUFjRCxJQUFZLFNBR1g7QUFIRCxXQUFZLFNBQVM7SUFDbkIsb0NBQXVCLENBQUE7SUFDdkIsa0NBQXFCLENBQUE7QUFDdkIsQ0FBQyxFQUhXLFNBQVMseUJBQVQsU0FBUyxRQUdwQiIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBlbnVtIEFzc2V0VHlwZSB7XG4gIGltYWdlID0gJ0lNQUdFJyxcbiAgdmlkZW8gPSAnVklERU8nXG59XG5cbmV4cG9ydCBpbnRlcmZhY2UgQXNzZXQge1xuICBpZDogc3RyaW5nO1xuICB0eXBlOiBBc3NldFR5cGU7XG4gIGlzVHJhc2hlZDogYm9vbGVhbjtcbn1cblxuZXhwb3J0IGludGVyZmFjZSBTaGFyZWRMaW5rIHtcbiAga2V5OiBzdHJpbmc7XG4gIGFzc2V0czogQXNzZXRbXTtcbiAgZXhwaXJlc0F0OiBzdHJpbmcgfCBudWxsO1xufVxuXG5leHBvcnQgZW51bSBJbWFnZVNpemUge1xuICB0aHVtYm5haWwgPSAndGh1bWJuYWlsJyxcbiAgb3JpZ2luYWwgPSAnb3JpZ2luYWwnXG59XG4iXX0=
|
@ -1,4 +1,5 @@
|
|||||||
import { Asset, AssetType, ImageSize, SharedLink } from './types'
|
import { Asset, AssetType, ImageSize, SharedLink } from './types'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
|
|
||||||
class Immich {
|
class Immich {
|
||||||
/**
|
/**
|
||||||
@ -29,7 +30,16 @@ class Immich {
|
|||||||
*/
|
*/
|
||||||
async getShareByKey (key: string) {
|
async getShareByKey (key: string) {
|
||||||
const res = (await this.request('/shared-links') || []) as SharedLink[]
|
const res = (await this.request('/shared-links') || []) as SharedLink[]
|
||||||
return res?.find(x => x.key === key)
|
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
|
||||||
|
} else {
|
||||||
|
return link
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -6,11 +6,13 @@ export enum AssetType {
|
|||||||
export interface Asset {
|
export interface Asset {
|
||||||
id: string;
|
id: string;
|
||||||
type: AssetType;
|
type: AssetType;
|
||||||
|
isTrashed: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SharedLink {
|
export interface SharedLink {
|
||||||
key: string;
|
key: string;
|
||||||
assets: Asset[]
|
assets: Asset[];
|
||||||
|
expiresAt: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ImageSize {
|
export enum ImageSize {
|
||||||
|
Loading…
Reference in New Issue
Block a user