forked from misskey-dev/misskey
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathDriveFile.ts
204 lines (172 loc) ยท 4.25 KB
/
DriveFile.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
import { id } from './util/id.js';
import { MiUser } from './User.js';
import { MiDriveFolder } from './DriveFolder.js';
@Entity('drive_file')
@Index(['userId', 'folderId', 'id'])
export class MiDriveFile {
@PrimaryColumn(id())
public id: string;
@Index()
@Column('timestamp with time zone', {
comment: 'The created date of the DriveFile.',
default: () => 'CURRENT_TIMESTAMP',
})
public createdAt: Date;
@Index()
@Column({
...id(),
nullable: true,
comment: 'The owner ID.',
})
public userId: MiUser['id'] | null;
@ManyToOne(type => MiUser, {
onDelete: 'SET NULL',
})
@JoinColumn()
public user: MiUser | null;
@Index()
@Column('varchar', {
length: 128, nullable: true,
comment: 'The host of owner. It will be null if the user in local.',
})
public userHost: string | null;
@Index()
@Column('varchar', {
length: 32,
comment: 'The MD5 hash of the DriveFile.',
})
public md5: string;
@Column('varchar', {
length: 256,
comment: 'The file name of the DriveFile.',
})
public name: string;
@Index()
@Column('varchar', {
length: 128,
comment: 'The content type (MIME) of the DriveFile.',
})
public type: string;
@Column('integer', {
comment: 'The file size (bytes) of the DriveFile.',
})
public size: number;
@Column('varchar', {
length: 512, nullable: true,
comment: 'The comment of the DriveFile.',
})
public comment: string | null;
@Column('varchar', {
length: 128, nullable: true,
comment: 'The BlurHash string.',
})
public blurhash: string | null;
@Column('jsonb', {
default: {},
comment: 'The any properties of the DriveFile. For example, it includes image width/height.',
})
public properties: { width?: number; height?: number; orientation?: number; avgColor?: string };
@Column('boolean')
public storedInternal: boolean;
@Column('varchar', {
length: 512,
comment: 'The URL of the DriveFile.',
})
public url: string;
@Column('varchar', {
length: 512, nullable: true,
comment: 'The URL of the thumbnail of the DriveFile.',
})
public thumbnailUrl: string | null;
@Column('varchar', {
length: 512, nullable: true,
comment: 'The URL of the webpublic of the DriveFile.',
})
public webpublicUrl: string | null;
@Column('varchar', {
length: 128, nullable: true,
})
public webpublicType: string | null;
@Index({ unique: true })
@Column('varchar', {
length: 256, nullable: true,
})
public accessKey: string | null;
@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,
comment: 'The URI of the DriveFile. it will be null when the DriveFile is local.',
})
public uri: string | null;
@Column('varchar', {
length: 512, nullable: true,
})
public src: string | null;
@Index()
@Column({
...id(),
nullable: true,
comment: 'The parent folder ID. If null, it means the DriveFile is located in root.',
})
public folderId: MiDriveFolder['id'] | null;
@ManyToOne(type => MiDriveFolder, {
onDelete: 'SET NULL',
})
@JoinColumn()
public folder: MiDriveFolder | null;
@Index()
@Column('boolean', {
default: false,
comment: 'Whether the DriveFile is NSFW.',
})
public isSensitive: boolean;
@Index()
@Column('boolean', {
default: false,
})
public isSensitiveByModerator: boolean;
@Index()
@Column('boolean', {
default: false,
comment: 'Whether the DriveFile is NSFW. (predict)',
})
public maybeSensitive: boolean;
@Index()
@Column('boolean', {
default: false,
})
public maybePorn: boolean;
/**
* ๅค้จใฎ(ไฟก้ ผใใใฆใใชใ)URLใธใฎ็ดใชใณใฏใๅฆใ
*/
@Index()
@Column('boolean', {
default: false,
comment: 'Whether the DriveFile is direct link to remote server.',
})
public isLink: boolean;
@Column('jsonb', {
default: {},
nullable: true,
})
public requestHeaders: Record<string, string> | null;
@Column('varchar', {
length: 128, nullable: true,
})
public requestIp: string | null;
}