2023-07-27 07:31:52 +02:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2021-04-24 15:38:24 +02:00
|
|
|
import { Entity, Index, JoinColumn, Column, PrimaryColumn, ManyToOne } from 'typeorm';
|
2023-09-20 04:33:36 +02:00
|
|
|
import { id } from './util/id.js';
|
2023-08-16 10:51:28 +02:00
|
|
|
import { MiUser } from './User.js';
|
|
|
|
import type { MiDriveFile } from './DriveFile.js';
|
2021-04-24 15:38:24 +02:00
|
|
|
|
2023-08-16 10:51:28 +02:00
|
|
|
@Entity('gallery_post')
|
|
|
|
export class MiGalleryPost {
|
2021-04-24 15:38:24 +02:00
|
|
|
@PrimaryColumn(id())
|
|
|
|
public id: string;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column('timestamp with time zone', {
|
2021-12-09 15:58:30 +01:00
|
|
|
comment: 'The updated date of the GalleryPost.',
|
2021-04-24 15:38:24 +02:00
|
|
|
})
|
|
|
|
public updatedAt: Date;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
|
|
|
length: 256,
|
|
|
|
})
|
|
|
|
public title: string;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
2021-12-09 15:58:30 +01:00
|
|
|
length: 2048, nullable: true,
|
2021-04-24 15:38:24 +02:00
|
|
|
})
|
|
|
|
public description: string | null;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column({
|
|
|
|
...id(),
|
2021-12-09 15:58:30 +01:00
|
|
|
comment: 'The ID of author.',
|
2021-04-24 15:38:24 +02:00
|
|
|
})
|
2023-08-16 10:51:28 +02:00
|
|
|
public userId: MiUser['id'];
|
2021-04-24 15:38:24 +02:00
|
|
|
|
2023-08-16 10:51:28 +02:00
|
|
|
@ManyToOne(type => MiUser, {
|
2021-12-09 15:58:30 +01:00
|
|
|
onDelete: 'CASCADE',
|
2021-04-24 15:38:24 +02:00
|
|
|
})
|
|
|
|
@JoinColumn()
|
2023-08-16 10:51:28 +02:00
|
|
|
public user: MiUser | null;
|
2021-04-24 15:38:24 +02:00
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column({
|
|
|
|
...id(),
|
2021-12-09 15:58:30 +01:00
|
|
|
array: true, default: '{}',
|
2021-04-24 15:38:24 +02:00
|
|
|
})
|
2023-08-16 10:51:28 +02:00
|
|
|
public fileIds: MiDriveFile['id'][];
|
2021-04-24 15:38:24 +02:00
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column('boolean', {
|
|
|
|
default: false,
|
2021-12-09 15:58:30 +01:00
|
|
|
comment: 'Whether the post is sensitive.',
|
2021-04-24 15:38:24 +02:00
|
|
|
})
|
|
|
|
public isSensitive: boolean;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column('integer', {
|
2021-12-09 15:58:30 +01:00
|
|
|
default: 0,
|
2021-04-24 15:38:24 +02:00
|
|
|
})
|
|
|
|
public likedCount: number;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column('varchar', {
|
2021-12-09 15:58:30 +01:00
|
|
|
length: 128, array: true, default: '{}',
|
2021-04-24 15:38:24 +02:00
|
|
|
})
|
|
|
|
public tags: string[];
|
|
|
|
|
2023-08-16 10:51:28 +02:00
|
|
|
constructor(data: Partial<MiGalleryPost>) {
|
2021-04-24 15:38:24 +02:00
|
|
|
if (data == null) return;
|
|
|
|
|
|
|
|
for (const [k, v] of Object.entries(data)) {
|
|
|
|
(this as any)[k] = v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|