feat: 노트 게시를 예약할 수 있음 (yojo-art/cherrypick#483, [Type4ny-Project/Type4ny@271c872c](271c872c97))
This commit is contained in:
parent
92ffd2a5fc
commit
2528508cff
41 changed files with 1455 additions and 6 deletions
60
packages/backend/src/models/NoteSchedule.ts
Normal file
60
packages/backend/src/models/NoteSchedule.ts
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* 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={
|
||||
/** Date.toISOString() */
|
||||
createdAt: string;
|
||||
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;
|
||||
}
|
||||
|
|
@ -43,6 +43,7 @@ import {
|
|||
MiNote,
|
||||
MiNoteFavorite,
|
||||
MiNoteReaction,
|
||||
MiNoteSchedule,
|
||||
MiNoteThreadMuting,
|
||||
MiNoteUnread,
|
||||
MiPage,
|
||||
|
|
@ -509,6 +510,12 @@ const $reversiGamesRepository: Provider = {
|
|||
inject: [DI.db],
|
||||
};
|
||||
|
||||
const $noteScheduleRepository: Provider = {
|
||||
provide: DI.noteScheduleRepository,
|
||||
useFactory: (db: DataSource) => db.getRepository(MiNoteSchedule).extend(miRepository as MiRepository<MiNoteSchedule>),
|
||||
inject: [DI.db],
|
||||
};
|
||||
|
||||
@Module({
|
||||
imports: [],
|
||||
providers: [
|
||||
|
|
@ -583,6 +590,7 @@ const $reversiGamesRepository: Provider = {
|
|||
$noteEditRepository,
|
||||
$bubbleGameRecordsRepository,
|
||||
$reversiGamesRepository,
|
||||
$noteScheduleRepository,
|
||||
],
|
||||
exports: [
|
||||
$usersRepository,
|
||||
|
|
@ -656,6 +664,7 @@ const $reversiGamesRepository: Provider = {
|
|||
$noteEditRepository,
|
||||
$bubbleGameRecordsRepository,
|
||||
$reversiGamesRepository,
|
||||
$noteScheduleRepository,
|
||||
],
|
||||
})
|
||||
export class RepositoryModule {
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ import { MiUserListFavorite } from '@/models/UserListFavorite.js';
|
|||
import { NoteEdit } from '@/models/NoteEdit.js';
|
||||
import { MiBubbleGameRecord } from '@/models/BubbleGameRecord.js';
|
||||
import { MiReversiGame } from '@/models/ReversiGame.js';
|
||||
import { MiNoteSchedule } from '@/models/NoteSchedule.js';
|
||||
import type { QueryDeepPartialEntity } from 'typeorm/query-builder/QueryPartialEntity.js';
|
||||
|
||||
export interface MiRepository<T extends ObjectLiteral> {
|
||||
|
|
@ -160,6 +161,7 @@ export {
|
|||
MiNote,
|
||||
MiNoteFavorite,
|
||||
MiNoteReaction,
|
||||
MiNoteSchedule,
|
||||
MiNoteThreadMuting,
|
||||
MiNoteUnread,
|
||||
MiPage,
|
||||
|
|
@ -271,3 +273,4 @@ export type UserMemoRepository = Repository<MiUserMemo> & MiRepository<MiUserMem
|
|||
export type BubbleGameRecordsRepository = Repository<MiBubbleGameRecord> & MiRepository<MiBubbleGameRecord>;
|
||||
export type ReversiGamesRepository = Repository<MiReversiGame> & MiRepository<MiReversiGame>;
|
||||
export type NoteEditRepository = Repository<NoteEdit> & MiRepository<NoteEdit>;
|
||||
export type NoteScheduleRepository = Repository<MiNoteSchedule>;
|
||||
|
|
|
|||
|
|
@ -296,6 +296,10 @@ export const packedRolePoliciesSchema = {
|
|||
type: 'boolean',
|
||||
optional: false, nullable: false,
|
||||
},
|
||||
scheduleNoteMax: {
|
||||
type: 'integer',
|
||||
optional: false, nullable: false,
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue