mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
* refactor(server): delete assets endpoint * fix: formatting * chore: cleanup * chore: open api * chore(mobile): replace DeleteAssetDTO with BulkIdsDTOs * feat: trash an asset * chore(server): formatting * chore: open api * chore: wording * chore: open-api * feat(server): add withDeleted to getAssets queries * WIP: mobile-recycle-bin * feat(server): recycle-bin to system config * feat(web): use recycle-bin system config * chore(server): domain assetcore removed * chore(server): rename recycle-bin to trash * chore(web): rename recycle-bin to trash * chore(server): always send soft deleted assets for getAllByUserId * chore(web): formatting * feat(server): permanent delete assets older than trashed period * feat(web): trash empty placeholder image * feat(server): empty trash * feat(web): empty trash * WIP: mobile-recycle-bin * refactor(server): empty / restore trash to separate endpoint * test(server): handle failures * test(server): fix e2e server-info test * test(server): deletion test refactor * feat(mobile): use map settings from server-config to enable / disable map * feat(mobile): trash asset * fix(server): operations on assets in trash * feat(web): show trash statistics * fix(web): handle trash enabled * fix(mobile): restore updates from trash * fix(server): ignore trashed assets for person * fix(server): add / remove search index when trashed / restored * chore(web): format * fix(server): asset service test * fix(server): include trashed assts for duplicates from uploads * feat(mobile): no dialog for trash, always dialog for permanent delete * refactor(mobile): use isar where instead of dart filter * refactor(mobile): asset provide - handle deletes in single db txn * chore(mobile): review changes * feat(web): confirmation before empty trash * server: review changes * fix(server): handle library changes * fix: filter external assets from getting trashed / deleted * fix(server): empty-bin * feat: broadcast config update events through ws * change order of trash button on mobile * styling * fix(mobile): do not show trashed toast for local only assets --------- Co-authored-by: Jason Rasmussen <jrasm91@gmail.com> Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
158 lines
4.0 KiB
TypeScript
158 lines
4.0 KiB
TypeScript
import {
|
|
Column,
|
|
CreateDateColumn,
|
|
DeleteDateColumn,
|
|
Entity,
|
|
Index,
|
|
JoinColumn,
|
|
JoinTable,
|
|
ManyToMany,
|
|
ManyToOne,
|
|
OneToMany,
|
|
OneToOne,
|
|
PrimaryGeneratedColumn,
|
|
UpdateDateColumn,
|
|
} from 'typeorm';
|
|
import { AlbumEntity } from './album.entity';
|
|
import { AssetFaceEntity } from './asset-face.entity';
|
|
import { ExifEntity } from './exif.entity';
|
|
import { LibraryEntity } from './library.entity';
|
|
import { SharedLinkEntity } from './shared-link.entity';
|
|
import { SmartInfoEntity } from './smart-info.entity';
|
|
import { TagEntity } from './tag.entity';
|
|
import { UserEntity } from './user.entity';
|
|
|
|
export const ASSET_CHECKSUM_CONSTRAINT = 'UQ_assets_owner_library_checksum';
|
|
|
|
@Entity('assets')
|
|
// Checksums must be unique per user and library
|
|
@Index(ASSET_CHECKSUM_CONSTRAINT, ['owner', 'library', 'checksum'], {
|
|
unique: true,
|
|
})
|
|
@Index('IDX_day_of_month', { synchronize: false })
|
|
@Index('IDX_month', { synchronize: false })
|
|
// For all assets, each originalpath must be unique per user and library
|
|
export class AssetEntity {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id!: string;
|
|
|
|
@Column()
|
|
deviceAssetId!: string;
|
|
|
|
@ManyToOne(() => UserEntity, { onDelete: 'CASCADE', onUpdate: 'CASCADE', nullable: false })
|
|
owner!: UserEntity;
|
|
|
|
@Column()
|
|
ownerId!: string;
|
|
|
|
@ManyToOne(() => LibraryEntity, { onDelete: 'CASCADE', onUpdate: 'CASCADE', nullable: false })
|
|
library!: LibraryEntity;
|
|
|
|
@Column()
|
|
libraryId!: string;
|
|
|
|
@Column()
|
|
deviceId!: string;
|
|
|
|
@Column()
|
|
type!: AssetType;
|
|
|
|
@Column()
|
|
originalPath!: string;
|
|
|
|
@Column({ type: 'varchar', nullable: true })
|
|
resizePath!: string | null;
|
|
|
|
@Column({ type: 'varchar', nullable: true, default: '' })
|
|
webpPath!: string | null;
|
|
|
|
@Column({ type: 'bytea', nullable: true })
|
|
thumbhash!: Buffer | null;
|
|
|
|
@Column({ type: 'varchar', nullable: true, default: '' })
|
|
encodedVideoPath!: string | null;
|
|
|
|
@CreateDateColumn({ type: 'timestamptz' })
|
|
createdAt!: Date;
|
|
|
|
@UpdateDateColumn({ type: 'timestamptz' })
|
|
updatedAt!: Date;
|
|
|
|
@DeleteDateColumn({ type: 'timestamptz', nullable: true })
|
|
deletedAt!: Date | null;
|
|
|
|
@Column({ type: 'timestamptz' })
|
|
fileCreatedAt!: Date;
|
|
|
|
@Column({ type: 'timestamp' })
|
|
localDateTime!: Date;
|
|
|
|
@Column({ type: 'timestamptz' })
|
|
fileModifiedAt!: Date;
|
|
|
|
@Column({ type: 'boolean', default: false })
|
|
isFavorite!: boolean;
|
|
|
|
@Column({ type: 'boolean', default: false })
|
|
isArchived!: boolean;
|
|
|
|
@Column({ type: 'boolean', default: false })
|
|
isExternal!: boolean;
|
|
|
|
@Column({ type: 'boolean', default: false })
|
|
isReadOnly!: boolean;
|
|
|
|
@Column({ type: 'boolean', default: false })
|
|
isOffline!: boolean;
|
|
|
|
@Column({ type: 'bytea' })
|
|
@Index()
|
|
checksum!: Buffer; // sha1 checksum
|
|
|
|
@Column({ type: 'varchar', nullable: true })
|
|
duration!: string | null;
|
|
|
|
@Column({ type: 'boolean', default: true })
|
|
isVisible!: boolean;
|
|
|
|
@OneToOne(() => AssetEntity, { nullable: true, onUpdate: 'CASCADE', onDelete: 'SET NULL' })
|
|
@JoinColumn()
|
|
livePhotoVideo!: AssetEntity | null;
|
|
|
|
@Column({ nullable: true })
|
|
livePhotoVideoId!: string | null;
|
|
|
|
@Column({ type: 'varchar' })
|
|
originalFileName!: string;
|
|
|
|
@Column({ type: 'varchar', nullable: true })
|
|
sidecarPath!: string | null;
|
|
|
|
@OneToOne(() => ExifEntity, (exifEntity) => exifEntity.asset)
|
|
exifInfo?: ExifEntity;
|
|
|
|
@OneToOne(() => SmartInfoEntity, (smartInfoEntity) => smartInfoEntity.asset)
|
|
smartInfo?: SmartInfoEntity;
|
|
|
|
@ManyToMany(() => TagEntity, (tag) => tag.assets, { cascade: true })
|
|
@JoinTable({ name: 'tag_asset' })
|
|
tags!: TagEntity[];
|
|
|
|
@ManyToMany(() => SharedLinkEntity, (link) => link.assets, { cascade: true })
|
|
@JoinTable({ name: 'shared_link__asset' })
|
|
sharedLinks!: SharedLinkEntity[];
|
|
|
|
@ManyToMany(() => AlbumEntity, (album) => album.assets, { onDelete: 'CASCADE', onUpdate: 'CASCADE' })
|
|
albums?: AlbumEntity[];
|
|
|
|
@OneToMany(() => AssetFaceEntity, (assetFace) => assetFace.asset)
|
|
faces!: AssetFaceEntity[];
|
|
}
|
|
|
|
export enum AssetType {
|
|
IMAGE = 'IMAGE',
|
|
VIDEO = 'VIDEO',
|
|
AUDIO = 'AUDIO',
|
|
OTHER = 'OTHER',
|
|
}
|