summaryrefslogtreecommitdiff
path: root/packages/backend/src/models/NoteSchedule.ts
blob: c9d031c2813a6db7be4bd4e70d7ba0ef1605ad96 (plain)
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
/*
 * SPDX-FileCopyrightText: syuilo and other misskey contributors
 * SPDX-License-Identifier: AGPL-3.0-only
 */

import { Entity, Index, Column, PrimaryColumn } from 'typeorm';
import { MiNote } from '@/models/Note.js';
import { id } from './util/id.js';
import { MiUser } from './User.js';
import { MiChannel } from './Channel.js';
import type { MiDriveFile } from './DriveFile.js';

type MinimumUser = {
	id: MiUser['id'];
	host: MiUser['host'];
	username: MiUser['username'];
	uri: MiUser['uri'];
};

export type MiScheduleNoteType = {
	visibility: 'public' | 'home' | 'followers' | 'specified';
	visibleUsers: MinimumUser[];
	channel?: MiChannel['id'];
	poll: {
		multiple: boolean;
		choices: string[];
		/** Date.toISOString() */
		expiresAt: string | null
	} | undefined;
	renote?: MiNote['id'];
	localOnly: boolean;
	cw?: string | null;
	reactionAcceptance: 'likeOnly' | 'likeOnlyForRemote' | 'nonSensitiveOnly' | 'nonSensitiveOnlyForLocalLikeOnlyForRemote' | null;
	files: MiDriveFile['id'][];
	text?: string | null;
	reply?: MiNote['id'];
	apMentions?: MinimumUser[] | null;
	apHashtags?: string[] | null;
	apEmojis?: string[] | null;
};

@Entity('note_schedule')
export class MiNoteSchedule {
	@PrimaryColumn(id())
	public id: string;

	@Column('jsonb')
	public note: MiScheduleNoteType;

	@Index()
	@Column('varchar', {
		length: 260,
	})
	public userId: MiUser['id'];

	@Column('timestamp with time zone')
	public scheduledAt: Date;
}