2024-03-20 22:02:51 +01:00
|
|
|
import { AlbumEntity } from 'src/entities/album.entity';
|
|
|
|
import { AssetEntity } from 'src/entities/asset.entity';
|
|
|
|
import { UserEntity } from 'src/entities/user.entity';
|
2024-08-15 12:57:01 +02:00
|
|
|
import { SharedLinkType } from 'src/enum';
|
2023-02-20 02:50:27 +01:00
|
|
|
import {
|
|
|
|
Column,
|
|
|
|
CreateDateColumn,
|
|
|
|
Entity,
|
|
|
|
Index,
|
|
|
|
ManyToMany,
|
|
|
|
ManyToOne,
|
|
|
|
PrimaryGeneratedColumn,
|
|
|
|
Unique,
|
|
|
|
} from 'typeorm';
|
2023-01-09 21:16:08 +01:00
|
|
|
|
|
|
|
@Entity('shared_links')
|
|
|
|
@Unique('UQ_sharedlink_key', ['key'])
|
|
|
|
export class SharedLinkEntity {
|
|
|
|
@PrimaryGeneratedColumn('uuid')
|
|
|
|
id!: string;
|
|
|
|
|
2023-06-21 03:08:43 +02:00
|
|
|
@Column({ type: 'varchar', nullable: true })
|
|
|
|
description!: string | null;
|
2023-01-09 21:16:08 +01:00
|
|
|
|
2023-10-29 02:35:38 +01:00
|
|
|
@Column({ type: 'varchar', nullable: true })
|
|
|
|
password!: string | null;
|
|
|
|
|
2023-01-09 21:16:08 +01:00
|
|
|
@Column()
|
|
|
|
userId!: string;
|
|
|
|
|
2024-03-07 23:21:23 +01:00
|
|
|
@ManyToOne(() => UserEntity, { onDelete: 'CASCADE', onUpdate: 'CASCADE' })
|
2023-01-31 19:11:49 +01:00
|
|
|
user!: UserEntity;
|
|
|
|
|
2023-01-09 21:16:08 +01:00
|
|
|
@Index('IDX_sharedlink_key')
|
|
|
|
@Column({ type: 'bytea' })
|
|
|
|
key!: Buffer; // use to access the inidividual asset
|
|
|
|
|
|
|
|
@Column()
|
|
|
|
type!: SharedLinkType;
|
|
|
|
|
2023-02-20 02:50:27 +01:00
|
|
|
@CreateDateColumn({ type: 'timestamptz' })
|
2023-05-30 15:15:56 +02:00
|
|
|
createdAt!: Date;
|
2023-01-09 21:16:08 +01:00
|
|
|
|
|
|
|
@Column({ type: 'timestamptz', nullable: true })
|
2023-05-30 15:15:56 +02:00
|
|
|
expiresAt!: Date | null;
|
2023-01-09 21:16:08 +01:00
|
|
|
|
|
|
|
@Column({ type: 'boolean', default: false })
|
|
|
|
allowUpload!: boolean;
|
|
|
|
|
2023-01-22 05:15:16 +01:00
|
|
|
@Column({ type: 'boolean', default: true })
|
|
|
|
allowDownload!: boolean;
|
|
|
|
|
|
|
|
@Column({ type: 'boolean', default: true })
|
|
|
|
showExif!: boolean;
|
|
|
|
|
2023-12-19 18:05:18 +01:00
|
|
|
@ManyToMany(() => AssetEntity, (asset) => asset.sharedLinks, { onDelete: 'CASCADE', onUpdate: 'CASCADE' })
|
2023-01-09 21:16:08 +01:00
|
|
|
assets!: AssetEntity[];
|
|
|
|
|
2023-02-28 01:28:45 +01:00
|
|
|
@Index('IDX_sharedlink_albumId')
|
2023-05-26 15:04:09 +02:00
|
|
|
@ManyToOne(() => AlbumEntity, (album) => album.sharedLinks, { onDelete: 'CASCADE', onUpdate: 'CASCADE' })
|
2023-01-09 21:16:08 +01:00
|
|
|
album?: AlbumEntity;
|
2023-06-21 03:08:43 +02:00
|
|
|
|
|
|
|
@Column({ type: 'varchar', nullable: true })
|
|
|
|
albumId!: string | null;
|
2023-01-09 21:16:08 +01:00
|
|
|
}
|