b752dc72e5
* WIp (backend) * Remove unused * 下書きbackend 続き * fix(backedn): visibilityが下書きに反映されない * Update packages/backend/src/postgres.ts Co-authored-by: かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> * Fix : import order * fix(backend) : createでcwが効かない * FIX FOREGIN KEY * wip: frontend(既存の下書きを挿入) まだ:チャンネル表示、下書きの作成、削除 * WIP: ノート選択ダイアログ 投稿時に下書きを削除 * Promiseに変更 * 連合なし、チャンネルも表示 * Hashtagの値抜け漏れ * hasthagを0文字でも作成可能に * 下書きの保存機構 * chore(misskey-js): build types * localOnly抜け漏れ * チャンネル情報の書き換え * enhance(frontend): ヘッダ部の表示改善 * fix(frontend): ファイル添付できない * fix: no file * fix(frontend): 投票が反映されない * ハッシュタグの展開(コメントアウト外し忘れ) * fix: visibleUserIdsが反映されない * enhance: APIの型を整備 * refactor: 型が整備できたのでasを削除 * Add userhost * fix * enhance: paginationを使う * fix * fix: 自分のアカウントでの投稿でしか下書きを利用できないように 完全に塞ぐことはできないが一応 * 🎨 * APIのエラーIDを追加 * enhance: スタイル調整 * remove unused code * 🎨 * fix: ロールポリシーの型 * ロールの編集画面 * ダイアログの挙動改善 * 下書き機能が利用できない場合は表示しないように * refactor * fix: ダブルクリックが効かない問題を修正 * add comments * fix * fix: 保存時のエラーの種別にかかわらずmodalを閉じないように * fix()backend: NoteDraftのreply, renoteの型が間違ってたので修正 (migtrationはあってた) * fix: 投稿フォームを空白にして通常リノートできるやつは下書きとしては弾くように * fix(backend): テキストが0文字でも下書きは保存できるように * Fix(backend): replyIdの型定義がミスっているのを修正 * chore(misskey-js): update types * Add CHANGELOG * lint * 常にサーバー下書きに保存し、上限を超えた場合のみ尋ねるように * NoteDraftServiceにcreate, updateの処理を移譲 * Fix typeerror * remove tooltip * Remove Mkbutton:short and use iconOnly * 不要なコメントの削除 * Remove Short Completely * wip * escキーまわりの挙動を改善 * 下書き選択時に下書き可能数と現在の量が分かるように * cleanUp * wip * wi * wip * Update MkPostForm.vue --------- Co-authored-by: かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
258 lines
5.7 KiB
TypeScript
258 lines
5.7 KiB
TypeScript
/*
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
import { Entity, Index, JoinColumn, Column, PrimaryColumn, ManyToOne } from 'typeorm';
|
|
import { noteVisibilities, noteReactionAcceptances } from '@/types.js';
|
|
import { id } from './util/id.js';
|
|
import { MiUser } from './User.js';
|
|
import { MiChannel } from './Channel.js';
|
|
import type { MiDriveFile } from './DriveFile.js';
|
|
|
|
// Note: When you create a new index for existing column of this table,
|
|
// it might be better to index concurrently under isConcurrentIndexMigrationEnabled flag
|
|
// by editing generated migration file since this table is very large,
|
|
// and it will make a long lock to create index in most cases.
|
|
// Please note that `CREATE INDEX CONCURRENTLY` is not supported in transaction,
|
|
// so you need to set `transaction = false` in migration if isConcurrentIndexMigrationEnabled() is true.
|
|
// Please refer 1745378064470-composite-note-index.js for example.
|
|
// You should not use `@Index({ concurrent: true })` decorator because database initialization for test will fail
|
|
// because it will always run CREATE INDEX in transaction based on decorators.
|
|
// Not appending `{ concurrent: true }` to `@Index` will not cause any problem in production,
|
|
@Index(['userId', 'id'])
|
|
@Entity('note')
|
|
export class MiNote {
|
|
@PrimaryColumn(id())
|
|
public id: string;
|
|
|
|
@Index()
|
|
@Column({
|
|
...id(),
|
|
nullable: true,
|
|
comment: 'The ID of reply target.',
|
|
})
|
|
public replyId: MiNote['id'] | null;
|
|
|
|
@ManyToOne(type => MiNote, {
|
|
onDelete: 'CASCADE',
|
|
})
|
|
@JoinColumn()
|
|
public reply: MiNote | null;
|
|
|
|
@Index()
|
|
@Column({
|
|
...id(),
|
|
nullable: true,
|
|
comment: 'The ID of renote target.',
|
|
})
|
|
public renoteId: MiNote['id'] | null;
|
|
|
|
@ManyToOne(type => MiNote, {
|
|
onDelete: 'CASCADE',
|
|
})
|
|
@JoinColumn()
|
|
public renote: MiNote | null;
|
|
|
|
@Index()
|
|
@Column('varchar', {
|
|
length: 256, nullable: true,
|
|
})
|
|
public threadId: string | null;
|
|
|
|
// TODO: varcharにしたい
|
|
@Column('text', {
|
|
nullable: true,
|
|
})
|
|
public text: string | null;
|
|
|
|
@Column('varchar', {
|
|
length: 256, nullable: true,
|
|
})
|
|
public name: string | null;
|
|
|
|
@Column('varchar', {
|
|
length: 512, nullable: true,
|
|
})
|
|
public cw: string | null;
|
|
|
|
@Column({
|
|
...id(),
|
|
comment: 'The ID of author.',
|
|
})
|
|
public userId: MiUser['id'];
|
|
|
|
@ManyToOne(type => MiUser, {
|
|
onDelete: 'CASCADE',
|
|
})
|
|
@JoinColumn()
|
|
public user: MiUser | null;
|
|
|
|
@Column('boolean', {
|
|
default: false,
|
|
})
|
|
public localOnly: boolean;
|
|
|
|
@Column('varchar', {
|
|
length: 64, nullable: true,
|
|
})
|
|
public reactionAcceptance: typeof noteReactionAcceptances[number];
|
|
|
|
@Column('smallint', {
|
|
default: 0,
|
|
})
|
|
public renoteCount: number;
|
|
|
|
@Column('smallint', {
|
|
default: 0,
|
|
})
|
|
public repliesCount: number;
|
|
|
|
@Column('smallint', {
|
|
default: 0,
|
|
})
|
|
public clippedCount: number;
|
|
|
|
@Column('jsonb', {
|
|
default: {},
|
|
})
|
|
public reactions: Record<string, number>;
|
|
|
|
/**
|
|
* public ... 公開
|
|
* home ... ホームタイムライン(ユーザーページのタイムライン含む)のみに流す
|
|
* followers ... フォロワーのみ
|
|
* specified ... visibleUserIds で指定したユーザーのみ
|
|
*/
|
|
@Column('enum', { enum: noteVisibilities })
|
|
public visibility: typeof noteVisibilities[number];
|
|
|
|
@Index({ unique: true })
|
|
@Column('varchar', {
|
|
length: 512, nullable: true,
|
|
comment: 'The URI of a note. it will be null when the note is local.',
|
|
})
|
|
public uri: string | null;
|
|
|
|
@Column('varchar', {
|
|
length: 512, nullable: true,
|
|
comment: 'The human readable url of a note. it will be null when the note is local.',
|
|
})
|
|
public url: string | null;
|
|
|
|
@Index('IDX_NOTE_FILE_IDS', { synchronize: false })
|
|
@Column({
|
|
...id(),
|
|
array: true, default: '{}',
|
|
})
|
|
public fileIds: MiDriveFile['id'][];
|
|
|
|
@Column('varchar', {
|
|
length: 256, array: true, default: '{}',
|
|
})
|
|
public attachedFileTypes: string[];
|
|
|
|
@Index('IDX_NOTE_VISIBLE_USER_IDS', { synchronize: false })
|
|
@Column({
|
|
...id(),
|
|
array: true, default: '{}',
|
|
})
|
|
public visibleUserIds: MiUser['id'][];
|
|
|
|
@Index('IDX_NOTE_MENTIONS', { synchronize: false })
|
|
@Column({
|
|
...id(),
|
|
array: true, default: '{}',
|
|
})
|
|
public mentions: MiUser['id'][];
|
|
|
|
@Column('text', {
|
|
default: '[]',
|
|
})
|
|
public mentionedRemoteUsers: string;
|
|
|
|
@Column('varchar', {
|
|
length: 1024, array: true, default: '{}',
|
|
})
|
|
public reactionAndUserPairCache: string[];
|
|
|
|
@Column('varchar', {
|
|
length: 128, array: true, default: '{}',
|
|
})
|
|
public emojis: string[];
|
|
|
|
@Index('IDX_NOTE_TAGS', { synchronize: false })
|
|
@Column('varchar', {
|
|
length: 128, array: true, default: '{}',
|
|
})
|
|
public tags: string[];
|
|
|
|
@Column('boolean', {
|
|
default: false,
|
|
})
|
|
public hasPoll: boolean;
|
|
|
|
@Index()
|
|
@Column({
|
|
...id(),
|
|
nullable: true,
|
|
comment: 'The ID of source channel.',
|
|
})
|
|
public channelId: MiChannel['id'] | null;
|
|
|
|
@ManyToOne(type => MiChannel, {
|
|
onDelete: 'CASCADE',
|
|
})
|
|
@JoinColumn()
|
|
public channel: MiChannel | null;
|
|
|
|
//#region Denormalized fields
|
|
@Index()
|
|
@Column('varchar', {
|
|
length: 128, nullable: true,
|
|
comment: '[Denormalized]',
|
|
})
|
|
public userHost: string | null;
|
|
|
|
@Column({
|
|
...id(),
|
|
nullable: true,
|
|
comment: '[Denormalized]',
|
|
})
|
|
public replyUserId: MiUser['id'] | null;
|
|
|
|
@Column('varchar', {
|
|
length: 128, nullable: true,
|
|
comment: '[Denormalized]',
|
|
})
|
|
public replyUserHost: string | null;
|
|
|
|
@Column({
|
|
...id(),
|
|
nullable: true,
|
|
comment: '[Denormalized]',
|
|
})
|
|
public renoteUserId: MiUser['id'] | null;
|
|
|
|
@Column('varchar', {
|
|
length: 128, nullable: true,
|
|
comment: '[Denormalized]',
|
|
})
|
|
public renoteUserHost: string | null;
|
|
|
|
constructor(data: Partial<MiNote>) {
|
|
if (data == null) return;
|
|
|
|
for (const [k, v] of Object.entries(data)) {
|
|
(this as any)[k] = v;
|
|
}
|
|
}
|
|
}
|
|
|
|
export type IMentionedRemoteUsers = {
|
|
uri: string;
|
|
url?: string;
|
|
username: string;
|
|
host: string;
|
|
}[];
|