2023-07-27 08:31:52 +03:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2019-04-29 03:11:57 +03:00
|
|
|
import { Entity, Index, JoinColumn, Column, PrimaryColumn, ManyToOne } from 'typeorm';
|
2022-02-27 04:07:39 +02:00
|
|
|
import { id } from '../id.js';
|
2022-09-17 21:27:08 +03:00
|
|
|
import { User } from './User.js';
|
|
|
|
import { DriveFile } from './DriveFile.js';
|
2019-04-29 03:11:57 +03:00
|
|
|
|
|
|
|
@Entity()
|
|
|
|
@Index(['userId', 'name'], { unique: true })
|
|
|
|
export class Page {
|
|
|
|
@PrimaryColumn(id())
|
|
|
|
public id: string;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column('timestamp with time zone', {
|
2021-12-09 16:58:30 +02:00
|
|
|
comment: 'The created date of the Page.',
|
2019-04-29 03:11:57 +03:00
|
|
|
})
|
|
|
|
public createdAt: Date;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column('timestamp with time zone', {
|
2021-12-09 16:58:30 +02:00
|
|
|
comment: 'The updated date of the Page.',
|
2019-04-29 03:11:57 +03:00
|
|
|
})
|
|
|
|
public updatedAt: Date;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
|
|
|
length: 256,
|
|
|
|
})
|
|
|
|
public title: string;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column('varchar', {
|
|
|
|
length: 256,
|
|
|
|
})
|
|
|
|
public name: string;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
2021-12-09 16:58:30 +02:00
|
|
|
length: 256, nullable: true,
|
2019-04-29 03:11:57 +03:00
|
|
|
})
|
|
|
|
public summary: string | null;
|
|
|
|
|
|
|
|
@Column('boolean')
|
|
|
|
public alignCenter: boolean;
|
|
|
|
|
2019-07-07 00:56:13 +03:00
|
|
|
@Column('boolean', {
|
2021-12-09 16:58:30 +02:00
|
|
|
default: false,
|
2019-07-07 00:56:13 +03:00
|
|
|
})
|
|
|
|
public hideTitleWhenPinned: boolean;
|
|
|
|
|
2019-04-29 03:11:57 +03:00
|
|
|
@Column('varchar', {
|
|
|
|
length: 32,
|
|
|
|
})
|
|
|
|
public font: string;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column({
|
|
|
|
...id(),
|
2021-12-09 16:58:30 +02:00
|
|
|
comment: 'The ID of author.',
|
2019-04-29 03:11:57 +03:00
|
|
|
})
|
|
|
|
public userId: User['id'];
|
|
|
|
|
|
|
|
@ManyToOne(type => User, {
|
2021-12-09 16:58:30 +02:00
|
|
|
onDelete: 'CASCADE',
|
2019-04-29 03:11:57 +03:00
|
|
|
})
|
|
|
|
@JoinColumn()
|
|
|
|
public user: User | null;
|
|
|
|
|
|
|
|
@Column({
|
|
|
|
...id(),
|
|
|
|
nullable: true,
|
|
|
|
})
|
|
|
|
public eyeCatchingImageId: DriveFile['id'] | null;
|
|
|
|
|
|
|
|
@ManyToOne(type => DriveFile, {
|
2021-12-09 16:58:30 +02:00
|
|
|
onDelete: 'CASCADE',
|
2019-04-29 03:11:57 +03:00
|
|
|
})
|
|
|
|
@JoinColumn()
|
|
|
|
public eyeCatchingImage: DriveFile | null;
|
|
|
|
|
|
|
|
@Column('jsonb', {
|
2021-12-09 16:58:30 +02:00
|
|
|
default: [],
|
2019-04-29 03:11:57 +03:00
|
|
|
})
|
|
|
|
public content: Record<string, any>[];
|
|
|
|
|
|
|
|
@Column('jsonb', {
|
2021-12-09 16:58:30 +02:00
|
|
|
default: [],
|
2019-04-29 03:11:57 +03:00
|
|
|
})
|
|
|
|
public variables: Record<string, any>[];
|
|
|
|
|
2020-04-12 21:23:23 +03:00
|
|
|
@Column('varchar', {
|
|
|
|
length: 16384,
|
2021-12-09 16:58:30 +02:00
|
|
|
default: '',
|
2020-04-12 21:23:23 +03:00
|
|
|
})
|
|
|
|
public script: string;
|
|
|
|
|
2019-04-29 03:11:57 +03:00
|
|
|
/**
|
|
|
|
* public ... 公開
|
|
|
|
* followers ... フォロワーのみ
|
|
|
|
* specified ... visibleUserIds で指定したユーザーのみ
|
|
|
|
*/
|
|
|
|
@Column('enum', { enum: ['public', 'followers', 'specified'] })
|
|
|
|
public visibility: 'public' | 'followers' | 'specified';
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column({
|
|
|
|
...id(),
|
2021-12-09 16:58:30 +02:00
|
|
|
array: true, default: '{}',
|
2019-04-29 03:11:57 +03:00
|
|
|
})
|
|
|
|
public visibleUserIds: User['id'][];
|
|
|
|
|
2019-05-17 13:56:47 +03:00
|
|
|
@Column('integer', {
|
2021-12-09 16:58:30 +02:00
|
|
|
default: 0,
|
2019-05-17 13:56:47 +03:00
|
|
|
})
|
|
|
|
public likedCount: number;
|
|
|
|
|
2019-04-29 03:11:57 +03:00
|
|
|
constructor(data: Partial<Page>) {
|
|
|
|
if (data == null) return;
|
|
|
|
|
|
|
|
for (const [k, v] of Object.entries(data)) {
|
|
|
|
(this as any)[k] = v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|