2023-07-27 05:31:52 +00:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2023-08-13 11:12:29 +00:00
|
|
|
import { Entity, Index, Column, PrimaryColumn, ManyToOne, JoinColumn } from 'typeorm';
|
2023-09-20 02:33:36 +00:00
|
|
|
import { id } from './util/id.js';
|
2023-08-16 08:51:28 +00:00
|
|
|
import { MiUser } from './User.js';
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2023-08-16 08:51:28 +00:00
|
|
|
@Entity('announcement')
|
|
|
|
export class MiAnnouncement {
|
2020-01-29 19:37:25 +00:00
|
|
|
@PrimaryColumn(id())
|
|
|
|
public id: string;
|
|
|
|
|
|
|
|
@Column('timestamp with time zone', {
|
|
|
|
comment: 'The updated date of the Announcement.',
|
2021-12-09 14:58:30 +00:00
|
|
|
nullable: true,
|
2020-01-29 19:37:25 +00:00
|
|
|
})
|
|
|
|
public updatedAt: Date | null;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
2021-12-09 14:58:30 +00:00
|
|
|
length: 8192, nullable: false,
|
2020-01-29 19:37:25 +00:00
|
|
|
})
|
|
|
|
public text: string;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
2021-12-09 14:58:30 +00:00
|
|
|
length: 256, nullable: false,
|
2020-01-29 19:37:25 +00:00
|
|
|
})
|
|
|
|
public title: string;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
2021-12-09 14:58:30 +00:00
|
|
|
length: 1024, nullable: true,
|
2020-01-29 19:37:25 +00:00
|
|
|
})
|
|
|
|
public imageUrl: string | null;
|
|
|
|
|
2023-08-13 11:12:29 +00:00
|
|
|
// info, warning, error, success
|
|
|
|
@Column('varchar', {
|
|
|
|
length: 256, nullable: false,
|
|
|
|
default: 'info',
|
|
|
|
})
|
|
|
|
public icon: string;
|
|
|
|
|
|
|
|
// normal ... お知らせページ掲載
|
|
|
|
// banner ... お知らせページ掲載 + バナー表示
|
|
|
|
// dialog ... お知らせページ掲載 + ダイアログ表示
|
|
|
|
@Column('varchar', {
|
|
|
|
length: 256, nullable: false,
|
|
|
|
default: 'normal',
|
|
|
|
})
|
|
|
|
public display: string;
|
|
|
|
|
|
|
|
@Column('boolean', {
|
|
|
|
default: false,
|
|
|
|
})
|
|
|
|
public needConfirmationToRead: boolean;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column('boolean', {
|
|
|
|
default: true,
|
|
|
|
})
|
|
|
|
public isActive: boolean;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column('boolean', {
|
|
|
|
default: false,
|
|
|
|
})
|
|
|
|
public forExistingUsers: boolean;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column({
|
|
|
|
...id(),
|
|
|
|
nullable: true,
|
|
|
|
})
|
2023-08-16 08:51:28 +00:00
|
|
|
public userId: MiUser['id'] | null;
|
2023-08-13 11:12:29 +00:00
|
|
|
|
2023-08-16 08:51:28 +00:00
|
|
|
@ManyToOne(type => MiUser, {
|
2023-08-13 11:12:29 +00:00
|
|
|
onDelete: 'CASCADE',
|
|
|
|
})
|
|
|
|
@JoinColumn()
|
2023-08-16 08:51:28 +00:00
|
|
|
public user: MiUser | null;
|
2023-08-13 11:12:29 +00:00
|
|
|
|
2023-08-16 08:51:28 +00:00
|
|
|
constructor(data: Partial<MiAnnouncement>) {
|
2020-01-29 19:37:25 +00:00
|
|
|
if (data == null) return;
|
|
|
|
|
|
|
|
for (const [k, v] of Object.entries(data)) {
|
|
|
|
(this as any)[k] = v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|