2023-07-27 05:31:52 +00:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2019-04-07 12:50:36 +00:00
|
|
|
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
|
2022-07-02 06:12:11 +00:00
|
|
|
import { id } from '../id.js';
|
2023-08-16 08:51:28 +00:00
|
|
|
import { MiUser } from './User.js';
|
|
|
|
import { MiDriveFolder } from './DriveFolder.js';
|
2019-04-07 12:50:36 +00:00
|
|
|
|
2023-08-16 08:51:28 +00:00
|
|
|
@Entity('drive_file')
|
2020-02-14 19:29:57 +00:00
|
|
|
@Index(['userId', 'folderId', 'id'])
|
2023-08-16 08:51:28 +00:00
|
|
|
export class MiDriveFile {
|
2019-04-07 12:50:36 +00:00
|
|
|
@PrimaryColumn(id())
|
|
|
|
public id: string;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column('timestamp with time zone', {
|
2021-12-09 14:58:30 +00:00
|
|
|
comment: 'The created date of the DriveFile.',
|
2019-04-07 12:50:36 +00:00
|
|
|
})
|
|
|
|
public createdAt: Date;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column({
|
|
|
|
...id(),
|
|
|
|
nullable: true,
|
2021-12-09 14:58:30 +00:00
|
|
|
comment: 'The owner ID.',
|
2019-04-07 12:50:36 +00:00
|
|
|
})
|
2023-08-16 08:51:28 +00:00
|
|
|
public userId: MiUser['id'] | null;
|
2019-04-07 12:50:36 +00:00
|
|
|
|
2023-08-16 08:51:28 +00:00
|
|
|
@ManyToOne(type => MiUser, {
|
2021-12-09 14:58:30 +00:00
|
|
|
onDelete: 'SET NULL',
|
2019-04-07 12:50:36 +00:00
|
|
|
})
|
|
|
|
@JoinColumn()
|
2023-08-16 08:51:28 +00:00
|
|
|
public user: MiUser | null;
|
2019-04-07 12:50:36 +00:00
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column('varchar', {
|
|
|
|
length: 128, nullable: true,
|
2021-12-09 14:58:30 +00:00
|
|
|
comment: 'The host of owner. It will be null if the user in local.',
|
2019-04-07 12:50:36 +00:00
|
|
|
})
|
|
|
|
public userHost: string | null;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column('varchar', {
|
|
|
|
length: 32,
|
2021-12-09 14:58:30 +00:00
|
|
|
comment: 'The MD5 hash of the DriveFile.',
|
2019-04-07 12:50:36 +00:00
|
|
|
})
|
|
|
|
public md5: string;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
|
|
|
length: 256,
|
2021-12-09 14:58:30 +00:00
|
|
|
comment: 'The file name of the DriveFile.',
|
2019-04-07 12:50:36 +00:00
|
|
|
})
|
|
|
|
public name: string;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column('varchar', {
|
|
|
|
length: 128,
|
2021-12-09 14:58:30 +00:00
|
|
|
comment: 'The content type (MIME) of the DriveFile.',
|
2019-04-07 12:50:36 +00:00
|
|
|
})
|
|
|
|
public type: string;
|
|
|
|
|
|
|
|
@Column('integer', {
|
2021-12-09 14:58:30 +00:00
|
|
|
comment: 'The file size (bytes) of the DriveFile.',
|
2019-04-07 12:50:36 +00:00
|
|
|
})
|
|
|
|
public size: number;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
|
|
|
length: 512, nullable: true,
|
2021-12-09 14:58:30 +00:00
|
|
|
comment: 'The comment of the DriveFile.',
|
2019-04-07 12:50:36 +00:00
|
|
|
})
|
|
|
|
public comment: string | null;
|
|
|
|
|
2020-07-18 15:24:07 +00:00
|
|
|
@Column('varchar', {
|
|
|
|
length: 128, nullable: true,
|
2021-12-09 14:58:30 +00:00
|
|
|
comment: 'The BlurHash string.',
|
2020-07-18 15:24:07 +00:00
|
|
|
})
|
|
|
|
public blurhash: string | null;
|
|
|
|
|
2019-04-07 12:50:36 +00:00
|
|
|
@Column('jsonb', {
|
|
|
|
default: {},
|
2021-12-09 14:58:30 +00:00
|
|
|
comment: 'The any properties of the DriveFile. For example, it includes image width/height.',
|
2019-04-07 12:50:36 +00:00
|
|
|
})
|
2021-12-03 02:19:28 +00:00
|
|
|
public properties: { width?: number; height?: number; orientation?: number; avgColor?: string };
|
2019-04-07 12:50:36 +00:00
|
|
|
|
|
|
|
@Column('boolean')
|
|
|
|
public storedInternal: boolean;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
|
|
|
length: 512,
|
2021-12-09 14:58:30 +00:00
|
|
|
comment: 'The URL of the DriveFile.',
|
2019-04-07 12:50:36 +00:00
|
|
|
})
|
|
|
|
public url: string;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
|
|
|
length: 512, nullable: true,
|
2021-12-09 14:58:30 +00:00
|
|
|
comment: 'The URL of the thumbnail of the DriveFile.',
|
2019-04-07 12:50:36 +00:00
|
|
|
})
|
|
|
|
public thumbnailUrl: string | null;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
|
|
|
length: 512, nullable: true,
|
2021-12-09 14:58:30 +00:00
|
|
|
comment: 'The URL of the webpublic of the DriveFile.',
|
2019-04-07 12:50:36 +00:00
|
|
|
})
|
|
|
|
public webpublicUrl: string | null;
|
|
|
|
|
2022-01-19 17:40:13 +00:00
|
|
|
@Column('varchar', {
|
|
|
|
length: 128, nullable: true,
|
|
|
|
})
|
|
|
|
public webpublicType: string | null;
|
|
|
|
|
2019-04-07 12:50:36 +00:00
|
|
|
@Index({ unique: true })
|
|
|
|
@Column('varchar', {
|
2019-04-08 16:31:48 +00:00
|
|
|
length: 256, nullable: true,
|
2019-04-07 12:50:36 +00:00
|
|
|
})
|
2019-04-08 16:31:48 +00:00
|
|
|
public accessKey: string | null;
|
2019-04-07 12:50:36 +00:00
|
|
|
|
|
|
|
@Index({ unique: true })
|
|
|
|
@Column('varchar', {
|
|
|
|
length: 256, nullable: true,
|
|
|
|
})
|
|
|
|
public thumbnailAccessKey: string | null;
|
|
|
|
|
|
|
|
@Index({ unique: true })
|
|
|
|
@Column('varchar', {
|
|
|
|
length: 256, nullable: true,
|
|
|
|
})
|
|
|
|
public webpublicAccessKey: string | null;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column('varchar', {
|
|
|
|
length: 512, nullable: true,
|
2021-12-09 14:58:30 +00:00
|
|
|
comment: 'The URI of the DriveFile. it will be null when the DriveFile is local.',
|
2019-04-07 12:50:36 +00:00
|
|
|
})
|
|
|
|
public uri: string | null;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
|
|
|
length: 512, nullable: true,
|
|
|
|
})
|
|
|
|
public src: string | null;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column({
|
|
|
|
...id(),
|
|
|
|
nullable: true,
|
2021-12-09 14:58:30 +00:00
|
|
|
comment: 'The parent folder ID. If null, it means the DriveFile is located in root.',
|
2019-04-07 12:50:36 +00:00
|
|
|
})
|
2023-08-16 08:51:28 +00:00
|
|
|
public folderId: MiDriveFolder['id'] | null;
|
2019-04-07 12:50:36 +00:00
|
|
|
|
2023-08-16 08:51:28 +00:00
|
|
|
@ManyToOne(type => MiDriveFolder, {
|
2021-12-09 14:58:30 +00:00
|
|
|
onDelete: 'SET NULL',
|
2019-04-07 12:50:36 +00:00
|
|
|
})
|
|
|
|
@JoinColumn()
|
2023-08-16 08:51:28 +00:00
|
|
|
public folder: MiDriveFolder | null;
|
2019-04-07 12:50:36 +00:00
|
|
|
|
2020-08-14 06:24:55 +00:00
|
|
|
@Index()
|
2019-04-07 12:50:36 +00:00
|
|
|
@Column('boolean', {
|
|
|
|
default: false,
|
2021-12-09 14:58:30 +00:00
|
|
|
comment: 'Whether the DriveFile is NSFW.',
|
2019-04-07 12:50:36 +00:00
|
|
|
})
|
|
|
|
public isSensitive: boolean;
|
|
|
|
|
2022-07-07 12:06:37 +00:00
|
|
|
@Index()
|
|
|
|
@Column('boolean', {
|
|
|
|
default: false,
|
|
|
|
comment: 'Whether the DriveFile is NSFW. (predict)',
|
|
|
|
})
|
|
|
|
public maybeSensitive: boolean;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column('boolean', {
|
|
|
|
default: false,
|
|
|
|
})
|
|
|
|
public maybePorn: boolean;
|
|
|
|
|
2019-04-07 12:50:36 +00:00
|
|
|
/**
|
|
|
|
* 外部の(信頼されていない)URLへの直リンクか否か
|
|
|
|
*/
|
2019-06-13 06:30:51 +00:00
|
|
|
@Index()
|
2019-04-07 12:50:36 +00:00
|
|
|
@Column('boolean', {
|
|
|
|
default: false,
|
2021-12-09 14:58:30 +00:00
|
|
|
comment: 'Whether the DriveFile is direct link to remote server.',
|
2019-04-07 12:50:36 +00:00
|
|
|
})
|
2019-04-09 14:07:08 +00:00
|
|
|
public isLink: boolean;
|
2022-07-02 06:12:11 +00:00
|
|
|
|
|
|
|
@Column('jsonb', {
|
|
|
|
default: {},
|
|
|
|
nullable: true,
|
|
|
|
})
|
|
|
|
public requestHeaders: Record<string, string> | null;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
|
|
|
length: 128, nullable: true,
|
|
|
|
})
|
|
|
|
public requestIp: string | null;
|
2019-04-07 12:50:36 +00:00
|
|
|
}
|