Merge branch 'develop' of https://firefish.dev/firefish/firefish into refactor/types

This commit is contained in:
Lhcfl 2024-04-12 00:23:21 +08:00
commit 8e28f0e97c
71 changed files with 808 additions and 588 deletions

View File

@ -27,3 +27,6 @@
By submitting this issue, you agree to follow our [Contribution Guidelines](https://firefish.dev/firefish/firefish/-/blob/develop/CONTRIBUTING.md)
- [ ] I agree to follow this project's Contribution Guidelines
- [ ] I have searched the issue tracker for similar issues, and this is not a duplicate.
**Can you fix this bug?** (optional)
- [ ] Yes. I will fix this bug and open a merge request if the change is agreed upon.

View File

@ -15,3 +15,6 @@
By submitting this issue, you agree to follow our [Contribution Guidelines](https://firefish.dev/firefish/firefish/-/blob/develop/CONTRIBUTING.md)
- [ ] I agree to follow this project's Contribution Guidelines
- [ ] I have searched the issue tracker for similar requests, and this is not a duplicate.
**Can you implement this feature?** (optional)
- [ ] Yes. I will implement this feature and open a merge request if the change is agreed upon.

View File

@ -4,6 +4,7 @@
**Contribution Guidelines**
By submitting this merge request, you agree to follow our [Contribution Guidelines](https://firefish.dev/firefish/firefish/-/blob/develop/CONTRIBUTING.md)
- [ ] This change is reviewed in an issue / This is a minor bug fix
- [ ] I agree to follow this project's Contribution Guidelines
- [ ] I have made sure to test this pull request
- [ ] I have made sure to run `pnpm run format` before submitting this pull request
@ -12,4 +13,4 @@ If this merge request makes changes to the Firefish API, please update `docs/api
- [ ] I updated the document / This merge request doesn't include API changes
<!-- Uncomment if your merge request has multiple authors -->
<!-- Co-authored-by: Name <email@email.com> -->
<!-- Co-authored-by: Name <email@example.com> -->

View File

@ -1,6 +1,7 @@
Unless specified otherwise, the entirety of this repository is subject to the following:
Copyright © 2014-2023 syuilo and contributors
Copyright © 2022-2023 Kainoa Kanter and contributors
Copyright © 2024 Firefish contributors
And is distributed under The GNU Affero General Public License Version 3, you should have received a copy of the license file as LICENSE.
@ -13,6 +14,7 @@ These specific configuration directories:
and their contents are
Copyright © 2022-2023 Kainoa Kanter and contributors
Copyright © 2024 Firefish contributors
And are distributed under The Apache License, Version 2.0, you should have received a copy of the license file as LICENSE in each specified directory.

View File

@ -876,7 +876,7 @@ fromDrive: Des del Disc
uploadFromUrl: Puja des d'una adreça URL
uploadFromUrlDescription: Adreça URL del fitxer que vols pujar
uploadFromUrlRequested: Pujada demanada
noMoreHistory: No hi ha res més a l'historial
noMoreHistory: No hi ha més historial
tos: Condicions d'ús
start: Comença
startMessaging: Comença una conversa
@ -2293,5 +2293,5 @@ markLocalFilesNsfwByDefaultDescription: Independentment d'aquest ajust, els usua
afectats.
autocorrectNoteLanguage: Mostra un avís si l'idioma de la publicació no coincideix
amb el resultat de l'idioma detectat automàticament
noteEditHistory: Historial d'edició de la publicació
noteEditHistory: Historial d'edicions
media: Multimèdia

View File

@ -2272,3 +2272,4 @@ markLocalFilesNsfwByDefault: Tandai semua berkas lokal baru sensitif secara bawa
markLocalFilesNsfwByDefaultDescription: Terlepas dari pengaturan ini, pengguna dapat
menghapus sendiri tanda NSFW. Berkas yang ada tidak berpengaruh.
noteEditHistory: Riwayat penyuntingan kiriman
media: Media

View File

@ -2060,3 +2060,4 @@ showNoAltTextWarning: 当您尝试发布没有描述的帖子附件时显示警
autocorrectNoteLanguage: 当帖子语言不符合自动检测的结果的时候显示警告
incorrectLanguageWarning: "看上去您帖子使用的语言是{detected},但您选择的语言是{current}。\n要改为以{detected}发帖吗?"
noteEditHistory: "帖子编辑历史"
media: 媒体

View File

@ -5,6 +5,7 @@ import {
JoinColumn,
Column,
ManyToOne,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { id } from "../id.js";
@ -24,34 +25,16 @@ export class AbuseUserReport {
@Column(id())
public targetUserId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public targetUser: User | null;
@Index()
@Column(id())
public reporterId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public reporter: User | null;
@Column({
...id(),
nullable: true,
})
public assigneeId: User["id"] | null;
@ManyToOne((type) => User, {
onDelete: "SET NULL",
})
@JoinColumn()
public assignee: User | null;
@Index()
@Column("boolean", {
default: false,
@ -85,4 +68,25 @@ export class AbuseUserReport {
})
public reporterHost: string | null;
//#endregion
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public targetUser: Relation<User>;
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public reporter: Relation<User>;
@ManyToOne(() => User, {
onDelete: "SET NULL",
nullable: true,
})
@JoinColumn()
public assignee: Relation<User | null>;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
Column,
ManyToOne,
JoinColumn,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { App } from "./app.js";
@ -48,24 +49,12 @@ export class AccessToken {
@Column(id())
public userId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
@Column({
...id(),
nullable: true,
})
public appId: App["id"] | null;
@ManyToOne((type) => App, {
onDelete: "CASCADE",
})
@JoinColumn()
public app: App | null;
@Column("varchar", {
length: 128,
nullable: true,
@ -95,4 +84,18 @@ export class AccessToken {
default: false,
})
public fetched: boolean;
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: Relation<User>;
@ManyToOne(() => App, {
onDelete: "CASCADE",
})
@JoinColumn()
public app: Relation<App>;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
JoinColumn,
Column,
ManyToOne,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { Announcement } from "./announcement.js";
@ -25,19 +26,21 @@ export class AnnouncementRead {
@Column(id())
public userId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
@Index()
@Column(id())
public announcementId: Announcement["id"];
@ManyToOne((type) => Announcement, {
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public announcement: Announcement | null;
public user: Relation<User>;
@ManyToOne(() => Announcement, {
onDelete: "CASCADE",
})
@JoinColumn()
public announcement: Relation<Announcement>;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
JoinColumn,
Column,
ManyToOne,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { id } from "../id.js";
@ -28,12 +29,6 @@ export class Antenna {
})
public userId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
@Column("varchar", {
length: 128,
comment: "The name of the Antenna.",
@ -51,24 +46,12 @@ export class Antenna {
})
public userListId: UserList["id"] | null;
@ManyToOne((type) => UserList, {
onDelete: "CASCADE",
})
@JoinColumn()
public userList: UserList | null;
@Column({
...id(),
nullable: true,
})
public userGroupJoiningId: UserGroupJoining["id"] | null;
@ManyToOne((type) => UserGroupJoining, {
onDelete: "CASCADE",
})
@JoinColumn()
public userGroupJoining: UserGroupJoining | null;
@Column("varchar", {
length: 1024,
array: true,
@ -112,4 +95,27 @@ export class Antenna {
@Column("boolean")
public notify: boolean;
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
nullable: true,
})
@JoinColumn()
public user: Relation<User | null>;
@ManyToOne(() => UserList, {
onDelete: "CASCADE",
nullable: true,
})
@JoinColumn()
public userList: Relation<UserList | null>;
@ManyToOne(() => UserGroupJoining, {
onDelete: "CASCADE",
nullable: true,
})
@JoinColumn()
public userGroupJoining: Relation<UserGroupJoining | null>;
//#endregion
}

View File

@ -1,4 +1,11 @@
import { Entity, PrimaryColumn, Column, Index, ManyToOne } from "typeorm";
import {
Entity,
PrimaryColumn,
Column,
Index,
ManyToOne,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { id } from "../id.js";
@ -21,12 +28,6 @@ export class App {
})
public userId: User["id"] | null;
@ManyToOne((type) => User, {
onDelete: "SET NULL",
nullable: true,
})
public user: User | null;
@Index()
@Column("varchar", {
length: 64,
@ -59,4 +60,12 @@ export class App {
comment: "The callbackUrl of the App.",
})
public callbackUrl: string | null;
//#region Relations
@ManyToOne(() => User, {
onDelete: "SET NULL",
nullable: true,
})
public user: Relation<User | null>;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
Column,
ManyToOne,
Index,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { id } from "../id.js";
@ -18,12 +19,6 @@ export class AttestationChallenge {
@PrimaryColumn(id())
public userId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
@Index()
@Column("varchar", {
length: 64,
@ -43,6 +38,14 @@ export class AttestationChallenge {
})
public registrationChallenge: boolean;
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: Relation<User>;
//#endregion
constructor(data: Partial<AttestationChallenge>) {
if (data == null) return;

View File

@ -5,6 +5,7 @@ import {
Column,
ManyToOne,
JoinColumn,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { App } from "./app.js";
@ -32,19 +33,20 @@ export class AuthSession {
})
public userId: User["id"] | null;
@ManyToOne((type) => User, {
onDelete: "CASCADE",
nullable: true,
})
@JoinColumn()
public user: User | null;
@Column(id())
public appId: App["id"];
@ManyToOne((type) => App, {
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public app: App | null;
public user: Relation<User>;
@ManyToOne(() => App, {
onDelete: "CASCADE",
})
@JoinColumn()
public app: App;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
JoinColumn,
Column,
ManyToOne,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { id } from "../id.js";
@ -28,12 +29,6 @@ export class Blocking {
})
public blockeeId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public blockee: User | null;
@Index()
@Column({
...id(),
@ -41,9 +36,17 @@ export class Blocking {
})
public blockerId: User["id"];
@ManyToOne((type) => User, {
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public blocker: User | null;
public blockee: Relation<User>;
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public blocker: Relation<User>;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
JoinColumn,
Column,
ManyToOne,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { id } from "../id.js";
@ -29,12 +30,6 @@ export class ChannelFollowing {
})
public followeeId: Channel["id"];
@ManyToOne((type) => Channel, {
onDelete: "CASCADE",
})
@JoinColumn()
public followee: Channel | null;
@Index()
@Column({
...id(),
@ -42,9 +37,17 @@ export class ChannelFollowing {
})
public followerId: User["id"];
@ManyToOne((type) => User, {
//#region Relations
@ManyToOne(() => Channel, {
onDelete: "CASCADE",
})
@JoinColumn()
public follower: User | null;
public followee: Relation<Channel>;
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public follower: Relation<User>;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
JoinColumn,
Column,
ManyToOne,
type Relation,
} from "typeorm";
import { Note } from "./note.js";
import { Channel } from "./channel.js";
@ -25,18 +26,20 @@ export class ChannelNotePining {
@Column(id())
public channelId: Channel["id"];
@ManyToOne((type) => Channel, {
onDelete: "CASCADE",
})
@JoinColumn()
public channel: Channel | null;
@Column(id())
public noteId: Note["id"];
@ManyToOne((type) => Note, {
//#region Relations
@ManyToOne(() => Channel, {
onDelete: "CASCADE",
})
@JoinColumn()
public note: Note | null;
public channel: Relation<Channel>;
@ManyToOne(() => Note, {
onDelete: "CASCADE",
})
@JoinColumn()
public note: Relation<Note>;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
JoinColumn,
Column,
ManyToOne,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { id } from "../id.js";
@ -35,12 +36,6 @@ export class Channel {
})
public userId: User["id"] | null;
@ManyToOne((type) => User, {
onDelete: "SET NULL",
})
@JoinColumn()
public user: User | null;
@Column("varchar", {
length: 128,
comment: "The name of the Channel.",
@ -61,12 +56,6 @@ export class Channel {
})
public bannerId: DriveFile["id"] | null;
@ManyToOne((type) => DriveFile, {
onDelete: "SET NULL",
})
@JoinColumn()
public banner: DriveFile | null;
@Index()
@Column("integer", {
default: 0,
@ -80,4 +69,18 @@ export class Channel {
comment: "The count of users.",
})
public usersCount: number;
//#region Relations
@ManyToOne(() => User, {
onDelete: "SET NULL",
})
@JoinColumn()
public user: Relation<User>;
@ManyToOne(() => DriveFile, {
onDelete: "SET NULL",
})
@JoinColumn()
public banner: Relation<DriveFile>;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
Column,
ManyToOne,
PrimaryColumn,
type Relation,
} from "typeorm";
import { Note } from "./note.js";
import { Clip } from "./clip.js";
@ -23,12 +24,6 @@ export class ClipNote {
})
public noteId: Note["id"];
@ManyToOne((type) => Note, {
onDelete: "CASCADE",
})
@JoinColumn()
public note: Note | null;
@Index()
@Column({
...id(),
@ -36,9 +31,17 @@ export class ClipNote {
})
public clipId: Clip["id"];
@ManyToOne((type) => Clip, {
//#region Relations
@ManyToOne(() => Note, {
onDelete: "CASCADE",
})
@JoinColumn()
public clip: Clip | null;
public note: Relation<Note>;
@ManyToOne(() => Clip, {
onDelete: "CASCADE",
})
@JoinColumn()
public clip: Relation<Clip>;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
JoinColumn,
Column,
ManyToOne,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { id } from "../id.js";
@ -26,12 +27,6 @@ export class Clip {
})
public userId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
@Column("varchar", {
length: 128,
comment: "The name of the Clip.",
@ -49,4 +44,12 @@ export class Clip {
comment: "The description of the Clip.",
})
public description: string | null;
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: Relation<User>;
//#endregion
}

View File

@ -214,12 +214,14 @@ export class DriveFile {
@ManyToOne(() => User, {
onDelete: "SET NULL",
nullable: true,
})
@JoinColumn()
public user: User | null;
@ManyToOne(() => DriveFolder, {
onDelete: "SET NULL",
nullable: true,
})
@JoinColumn()
public folder: DriveFolder | null;

View File

@ -5,6 +5,7 @@ import {
PrimaryColumn,
Index,
Column,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { id } from "../id.js";
@ -34,12 +35,6 @@ export class DriveFolder {
})
public userId: User["id"] | null;
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
@Index()
@Column({
...id(),
@ -49,9 +44,19 @@ export class DriveFolder {
})
public parentId: DriveFolder["id"] | null;
@ManyToOne((type) => DriveFolder, {
onDelete: "SET NULL",
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
nullable: true,
})
@JoinColumn()
public parent: DriveFolder | null;
public user: Relation<User | null>;
@ManyToOne(() => DriveFolder, {
onDelete: "SET NULL",
nullable: true,
})
@JoinColumn()
public parent: Relation<DriveFolder | null>;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
JoinColumn,
Column,
ManyToOne,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { id } from "../id.js";
@ -27,12 +28,6 @@ export class FollowRequest {
})
public followeeId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public followee: User | null;
@Index()
@Column({
...id(),
@ -40,12 +35,6 @@ export class FollowRequest {
})
public followerId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public follower: User | null;
@Column("varchar", {
length: 128,
nullable: true,
@ -96,4 +85,18 @@ export class FollowRequest {
})
public followeeSharedInbox: string | null;
//#endregion
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public followee: Relation<User>;
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public follower: Relation<User>;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
JoinColumn,
Column,
ManyToOne,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { id } from "../id.js";
@ -28,12 +29,6 @@ export class Following {
})
public followeeId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public followee: User | null;
@Index()
@Column({
...id(),
@ -41,12 +36,6 @@ export class Following {
})
public followerId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public follower: User | null;
//#region Denormalized fields
@Index()
@Column("varchar", {
@ -92,4 +81,18 @@ export class Following {
})
public followeeSharedInbox: string | null;
//#endregion
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public followee: Relation<User>;
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public follower: Relation<User>;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
JoinColumn,
Column,
ManyToOne,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { id } from "../id.js";
@ -23,18 +24,20 @@ export class GalleryLike {
@Column(id())
public userId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
@Column(id())
public postId: GalleryPost["id"];
@ManyToOne((type) => GalleryPost, {
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public post: GalleryPost | null;
public user: Relation<User>;
@ManyToOne(() => GalleryPost, {
onDelete: "CASCADE",
})
@JoinColumn()
public post: Relation<GalleryPost>;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
Column,
PrimaryColumn,
ManyToOne,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { id } from "../id.js";
@ -45,12 +46,6 @@ export class GalleryPost {
})
public userId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
@Index()
@Column({
...id(),
@ -80,6 +75,14 @@ export class GalleryPost {
})
public tags: string[];
//#region Relations
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: Relation<User>;
//#endregion
constructor(data: Partial<GalleryPost>) {
if (data == null) return;

View File

@ -5,6 +5,7 @@ import {
JoinColumn,
Column,
ManyToOne,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { DriveFile } from "./drive-file.js";
@ -29,12 +30,6 @@ export class MessagingMessage {
})
public userId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
@Index()
@Column({
...id(),
@ -43,12 +38,6 @@ export class MessagingMessage {
})
public recipientId: User["id"] | null;
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public recipient: User | null;
@Index()
@Column({
...id(),
@ -57,12 +46,6 @@ export class MessagingMessage {
})
public groupId: UserGroup["id"] | null;
@ManyToOne((type) => UserGroup, {
onDelete: "CASCADE",
})
@JoinColumn()
public group: UserGroup | null;
@Column("varchar", {
length: 4096,
nullable: true,
@ -93,9 +76,31 @@ export class MessagingMessage {
})
public fileId: DriveFile["id"] | null;
@ManyToOne((type) => DriveFile, {
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public file: DriveFile | null;
public user: Relation<User>;
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public recipient: Relation<User>;
@ManyToOne(() => UserGroup, {
onDelete: "CASCADE",
nullable: true,
})
@JoinColumn()
public group: Relation<UserGroup | null>;
@ManyToOne(() => DriveFile, {
onDelete: "CASCADE", // TODO: change this to SET NULL
nullable: true,
})
@JoinColumn()
public file: Relation<DriveFile | null>;
//#endregion
}

View File

@ -1,4 +1,11 @@
import { Entity, Column, PrimaryColumn, ManyToOne, JoinColumn } from "typeorm";
import {
Entity,
Column,
PrimaryColumn,
ManyToOne,
JoinColumn,
type Relation,
} from "typeorm";
import { id } from "../id.js";
import { User } from "./user.js";
import type { Clip } from "./clip.js";
@ -218,12 +225,6 @@ export class Meta {
})
public proxyAccountId: User["id"] | null;
@ManyToOne((type) => User, {
onDelete: "SET NULL",
})
@JoinColumn()
public proxyAccount: User | null;
@Column("boolean", {
default: false,
})
@ -500,4 +501,13 @@ export class Meta {
nullable: true,
})
public donationLink: string | null;
//#region Relations
@ManyToOne(() => User, {
onDelete: "SET NULL",
nullable: true,
})
@JoinColumn()
public proxyAccount: Relation<User | null>;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
JoinColumn,
Column,
ManyToOne,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { id } from "../id.js";
@ -23,12 +24,6 @@ export class ModerationLog {
@Column(id())
public userId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
@Column("varchar", {
length: 128,
})
@ -36,4 +31,12 @@ export class ModerationLog {
@Column("jsonb")
public info: Record<string, any>;
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: Relation<User>;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
Column,
ManyToOne,
PrimaryColumn,
type Relation,
} from "typeorm";
import { Note } from "./note.js";
import { User } from "./user.js";
@ -24,12 +25,6 @@ export class MutedNote {
})
public noteId: Note["id"];
@ManyToOne((type) => Note, {
onDelete: "CASCADE",
})
@JoinColumn()
public note: Note | null;
@Index()
@Column({
...id(),
@ -37,12 +32,6 @@ export class MutedNote {
})
public userId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
/**
*
*/
@ -52,4 +41,18 @@ export class MutedNote {
comment: "The reason of the MutedNote.",
})
public reason: (typeof mutedNoteReasons)[number];
//#region Relations
@ManyToOne(() => Note, {
onDelete: "CASCADE",
})
@JoinColumn()
public note: Relation<Note>;
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: Relation<User>;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
JoinColumn,
Column,
ManyToOne,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { id } from "../id.js";
@ -34,12 +35,6 @@ export class Muting {
})
public muteeId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public mutee: User | null;
@Index()
@Column({
...id(),
@ -47,9 +42,17 @@ export class Muting {
})
public muterId: User["id"];
@ManyToOne((type) => User, {
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public muter: User | null;
public mutee: Relation<User>;
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public muter: Relation<User>;
//#endregion
}

View File

@ -8,7 +8,7 @@ import {
} from "typeorm";
import { Note } from "./note.js";
import { id } from "../id.js";
import { DriveFile } from "./drive-file.js";
import type { DriveFile } from "./drive-file.js";
@Entity()
export class NoteEdit {
@ -22,12 +22,6 @@ export class NoteEdit {
})
public noteId: Note["id"];
@ManyToOne((type) => Note, {
onDelete: "CASCADE",
})
@JoinColumn()
public note: Note | null;
@Column("text", {
nullable: true,
})
@ -57,4 +51,12 @@ export class NoteEdit {
default: "{}",
})
public emojis: string[];
//#region Relations
@ManyToOne(() => Note, {
onDelete: "CASCADE",
})
@JoinColumn()
public note: Note;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
JoinColumn,
Column,
ManyToOne,
type Relation,
} from "typeorm";
import { Note } from "./note.js";
import { User } from "./user.js";
@ -25,18 +26,20 @@ export class NoteFavorite {
@Column(id())
public userId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
@Column(id())
public noteId: Note["id"];
@ManyToOne((type) => Note, {
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public note: Note | null;
public user: Relation<User>;
@ManyToOne(() => Note, {
onDelete: "CASCADE",
})
@JoinColumn()
public note: Relation<Note>;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
JoinColumn,
Column,
ManyToOne,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { Note } from "./note.js";
@ -26,26 +27,28 @@ export class NoteReaction {
@Column(id())
public userId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user?: User | null;
@Index()
@Column(id())
public noteId: Note["id"];
@ManyToOne((type) => Note, {
onDelete: "CASCADE",
})
@JoinColumn()
public note?: Note | null;
// TODO: 対象noteのuserIdを非正規化したい(「受け取ったリアクション一覧」のようなものを(JOIN無しで)実装したいため)
@Column("varchar", {
length: 260,
})
public reaction: string;
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: Relation<User>;
@ManyToOne(() => Note, {
onDelete: "CASCADE",
})
@JoinColumn()
public note: Relation<Note>;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
JoinColumn,
Column,
ManyToOne,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { id } from "../id.js";
@ -24,15 +25,17 @@ export class NoteThreadMuting {
})
public userId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
@Index()
@Column("varchar", {
length: 256,
})
public threadId: string;
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: Relation<User>;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
JoinColumn,
Column,
ManyToOne,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { Note } from "./note.js";
@ -21,22 +22,10 @@ export class NoteUnread {
@Column(id())
public userId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
@Index()
@Column(id())
public noteId: Note["id"];
@ManyToOne((type) => Note, {
onDelete: "CASCADE",
})
@JoinColumn()
public note: Note | null;
/**
*
*/
@ -67,4 +56,18 @@ export class NoteUnread {
})
public noteChannelId: Channel["id"] | null;
//#endregion
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: Relation<User>;
@ManyToOne(() => Note, {
onDelete: "CASCADE",
})
@JoinColumn()
public note: Relation<Note>;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
JoinColumn,
Column,
ManyToOne,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { Note } from "./note.js";
@ -29,12 +30,6 @@ export class NoteWatching {
})
public userId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
@Index()
@Column({
...id(),
@ -42,12 +37,6 @@ export class NoteWatching {
})
public noteId: Note["id"];
@ManyToOne((type) => Note, {
onDelete: "CASCADE",
})
@JoinColumn()
public note: Note | null;
//#region Denormalized fields
@Index()
@Column({
@ -56,4 +45,18 @@ export class NoteWatching {
})
public noteUserId: Note["userId"];
//#endregion
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: Relation<User>;
@ManyToOne(() => Note, {
onDelete: "CASCADE",
})
@JoinColumn()
public note: Relation<Note>;
//#endregion
}

View File

@ -206,55 +206,6 @@ export class Note {
})
public channelId: Channel["id"] | null;
//#region Relations
@OneToMany(
() => NoteFile,
(noteFile: NoteFile) => noteFile.note,
)
public noteFiles: Relation<NoteFile[]>;
@ManyToMany(
() => DriveFile,
(file: DriveFile) => file.notes,
)
@JoinTable({
name: "note_file",
joinColumn: {
name: "noteId",
referencedColumnName: "id",
},
inverseJoinColumn: {
name: "fileId",
referencedColumnName: "id",
},
})
public files: Relation<DriveFile[]>;
@ManyToOne(() => Note, {
onDelete: "CASCADE",
})
@JoinColumn()
public reply: Note | null;
@ManyToOne(() => Note, {
onDelete: "CASCADE",
})
@JoinColumn()
public renote: Note | null;
@ManyToOne(() => Channel, {
onDelete: "CASCADE",
})
@JoinColumn()
public channel: Channel | null;
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
//#endregion Relations
//#region Denormalized fields
@Index()
@Column("varchar", {
@ -299,6 +250,59 @@ export class Note {
public updatedAt: Date | null;
//#endregion
//#region Relations
@OneToMany(
() => NoteFile,
(noteFile: NoteFile) => noteFile.note,
)
public noteFiles: Relation<NoteFile[]>;
@ManyToMany(
() => DriveFile,
(file: DriveFile) => file.notes,
)
@JoinTable({
name: "note_file",
joinColumn: {
name: "noteId",
referencedColumnName: "id",
},
inverseJoinColumn: {
name: "fileId",
referencedColumnName: "id",
},
})
public files: Relation<DriveFile[]>;
@ManyToOne(() => Note, {
onDelete: "CASCADE",
nullable: true,
})
@JoinColumn()
public reply: Relation<Note | null>;
@ManyToOne(() => Note, {
onDelete: "CASCADE",
nullable: true,
})
@JoinColumn()
public renote: Relation<Note | null>;
@ManyToOne(() => Channel, {
onDelete: "CASCADE",
nullable: true,
})
@JoinColumn()
public channel: Relation<Channel | null>;
@ManyToOne(() => User, {
onDelete: "CASCADE",
nullable: true,
})
@JoinColumn()
public user: Relation<User | null>;
//#endregion Relations
constructor(data: Partial<Note>) {
if (data == null) return;

View File

@ -5,6 +5,7 @@ import {
ManyToOne,
Column,
PrimaryColumn,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { id } from "../id.js";
@ -35,12 +36,6 @@ export class Notification {
})
public notifieeId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public notifiee: User | null;
/**
* Notification sender (initiator)
*/
@ -52,12 +47,6 @@ export class Notification {
})
public notifierId: User["id"] | null;
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public notifier: User | null;
/**
* Notification types:
* follow - Follow request
@ -96,36 +85,18 @@ export class Notification {
})
public noteId: Note["id"] | null;
@ManyToOne((type) => Note, {
onDelete: "CASCADE",
})
@JoinColumn()
public note: Note | null;
@Column({
...id(),
nullable: true,
})
public followRequestId: FollowRequest["id"] | null;
@ManyToOne((type) => FollowRequest, {
onDelete: "CASCADE",
})
@JoinColumn()
public followRequest: FollowRequest | null;
@Column({
...id(),
nullable: true,
})
public userGroupInvitationId: UserGroupInvitation["id"] | null;
@ManyToOne((type) => UserGroupInvitation, {
onDelete: "CASCADE",
})
@JoinColumn()
public userGroupInvitation: UserGroupInvitation | null;
@Column("varchar", {
length: 128,
nullable: true,
@ -176,9 +147,46 @@ export class Notification {
})
public appAccessTokenId: AccessToken["id"] | null;
@ManyToOne((type) => AccessToken, {
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public appAccessToken: AccessToken | null;
public notifiee: Relation<User>;
@ManyToOne(() => User, {
onDelete: "CASCADE",
nullable: true,
})
@JoinColumn()
public notifier: Relation<User | null>;
@ManyToOne(() => Note, {
onDelete: "CASCADE",
nullable: true,
})
@JoinColumn()
public note: Relation<Note | null>;
@ManyToOne(() => FollowRequest, {
onDelete: "CASCADE",
nullable: true,
})
@JoinColumn()
public followRequest: Relation<FollowRequest | null>;
@ManyToOne(() => UserGroupInvitation, {
onDelete: "CASCADE",
nullable: true,
})
@JoinColumn()
public userGroupInvitation: Relation<UserGroupInvitation | null>;
@ManyToOne(() => AccessToken, {
onDelete: "CASCADE",
nullable: true,
})
@JoinColumn()
public appAccessToken: Relation<AccessToken | null>;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
JoinColumn,
Column,
ManyToOne,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { id } from "../id.js";
@ -23,18 +24,20 @@ export class PageLike {
@Column(id())
public userId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
@Column(id())
public pageId: Page["id"];
@ManyToOne((type) => Page, {
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public page: Page | null;
public user: Relation<User>;
@ManyToOne(() => Page, {
onDelete: "CASCADE",
})
@JoinColumn()
public page: Relation<Page>;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
Column,
PrimaryColumn,
ManyToOne,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { id } from "../id.js";
@ -68,24 +69,12 @@ export class Page {
})
public userId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
@Column({
...id(),
nullable: true,
})
public eyeCatchingImageId: DriveFile["id"] | null;
@ManyToOne((type) => DriveFile, {
onDelete: "CASCADE",
})
@JoinColumn()
public eyeCatchingImage: DriveFile | null;
@Column("jsonb", {
default: [],
})
@ -123,6 +112,20 @@ export class Page {
})
public likedCount: number;
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: Relation<User>;
@ManyToOne(() => DriveFile, {
onDelete: "CASCADE", // TODO: this should be SET NULL
})
@JoinColumn()
public eyeCatchingImage: Relation<DriveFile | null>;
//#endregion
constructor(data: Partial<Page>) {
if (data == null) return;

View File

@ -5,6 +5,7 @@ import {
Column,
ManyToOne,
JoinColumn,
type Relation,
} from "typeorm";
import { id } from "../id.js";
import { User } from "./user.js";
@ -29,9 +30,11 @@ export class PasswordResetRequest {
})
public userId: User["id"];
@ManyToOne((type) => User, {
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
public user: Relation<User>;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
JoinColumn,
Column,
ManyToOne,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { Note } from "./note.js";
@ -26,22 +27,24 @@ export class PollVote {
@Column(id())
public userId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
@Index()
@Column(id())
public noteId: Note["id"];
@ManyToOne((type) => Note, {
@Column("integer")
public choice: number;
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public note: Note | null;
public user: Relation<User>;
@Column("integer")
public choice: number;
@ManyToOne(() => Note, {
onDelete: "CASCADE",
})
@JoinColumn()
public note: Relation<Note>;
//#endregion
}

View File

@ -5,23 +5,18 @@ import {
JoinColumn,
Column,
OneToOne,
type Relation,
} from "typeorm";
import { id } from "../id.js";
import { Note } from "./note.js";
import type { User } from "./user.js";
import { noteVisibilities } from "../../types.js";
import { noteVisibilities } from "@/types.js";
@Entity()
export class Poll {
@PrimaryColumn(id())
public noteId: Note["id"];
@OneToOne((type) => Note, {
onDelete: "CASCADE",
})
@JoinColumn()
public note: Note | null;
@Column("timestamp without time zone", {
nullable: true,
})
@ -65,6 +60,14 @@ export class Poll {
public userHost: string | null;
//#endregion
//#region Relations
@OneToOne(() => Note, {
onDelete: "CASCADE",
})
@JoinColumn()
public note: Relation<Note>;
//#endregion
constructor(data: Partial<Poll>) {
if (data == null) return;

View File

@ -5,6 +5,7 @@ import {
JoinColumn,
Column,
OneToOne,
type Relation,
} from "typeorm";
import { Note } from "./note.js";
import type { User } from "./user.js";
@ -15,12 +16,6 @@ export class PromoNote {
@PrimaryColumn(id())
public noteId: Note["id"];
@OneToOne((type) => Note, {
onDelete: "CASCADE",
})
@JoinColumn()
public note: Note | null;
@Column("timestamp without time zone")
public expiresAt: Date;
@ -32,4 +27,12 @@ export class PromoNote {
})
public userId: User["id"];
//#endregion
//#region Relations
@OneToOne(() => Note, {
onDelete: "CASCADE",
})
@JoinColumn()
public note: Relation<Note>;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
JoinColumn,
Column,
ManyToOne,
type Relation,
} from "typeorm";
import { Note } from "./note.js";
import { User } from "./user.js";
@ -25,18 +26,20 @@ export class PromoRead {
@Column(id())
public userId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
@Column(id())
public noteId: Note["id"];
@ManyToOne((type) => Note, {
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public note: Note | null;
public user: Relation<User>;
@ManyToOne(() => Note, {
onDelete: "CASCADE",
})
@JoinColumn()
public note: Relation<Note>;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
JoinColumn,
Column,
ManyToOne,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { id } from "../id.js";
@ -32,12 +33,6 @@ export class RegistryItem {
})
public userId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
@Column("varchar", {
length: 1024,
comment: "The key of the RegistryItem.",
@ -66,4 +61,12 @@ export class RegistryItem {
nullable: true,
})
public domain: string | null;
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: Relation<User>;
//#endregion
}

View File

@ -2,12 +2,13 @@ import {
PrimaryColumn,
Entity,
Index,
JoinColumn,
// JoinColumn,
Column,
ManyToOne,
// ManyToOne,
// type Relation,
} from "typeorm";
import { id } from "../id.js";
import { User } from "./user.js";
import type { User } from "./user.js";
@Entity()
@Index(["muterId", "muteeId"], { unique: true })
@ -28,12 +29,6 @@ export class RenoteMuting {
})
public muteeId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public mutee: User | null;
@Index()
@Column({
...id(),
@ -41,9 +36,19 @@ export class RenoteMuting {
})
public muterId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public muter: User | null;
//#region Relations
/* FIXME: There is no such relation */
// @ManyToOne(() => User, {
// onDelete: "CASCADE",
// })
// @JoinColumn()
// public mutee: Relation<User>;
/* FIXME: There is no such relation */
// @ManyToOne(() => User, {
// onDelete: "CASCADE",
// })
// @JoinColumn()
// public muter: Relation<User>;
//#endregion
}

View File

@ -2,12 +2,13 @@ import {
PrimaryColumn,
Entity,
Index,
JoinColumn,
// JoinColumn,
Column,
ManyToOne,
// ManyToOne,
// type Relation,
} from "typeorm";
import { id } from "../id.js";
import { User } from "./user.js";
import type { User } from "./user.js";
@Entity()
@Index(["muterId", "muteeId"], { unique: true })
@ -28,12 +29,6 @@ export class ReplyMuting {
})
public muteeId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public mutee: User | null;
@Index()
@Column({
...id(),
@ -41,9 +36,19 @@ export class ReplyMuting {
})
public muterId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public muter: User | null;
//#region Relations
/* FIXME: There is no such relation */
// @ManyToOne(() => User, {
// onDelete: "CASCADE",
// })
// @JoinColumn()
// public mutee: Relation<User>;
/* FIXME: There is no such relation */
// @ManyToOne(() => User, {
// onDelete: "CASCADE",
// })
// @JoinColumn()
// public muter: Relation<User>;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
JoinColumn,
Column,
ManyToOne,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { id } from "../id.js";
@ -23,12 +24,6 @@ export class Signin {
@Column(id())
public userId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
@Column("varchar", {
length: 128,
})
@ -39,4 +34,12 @@ export class Signin {
@Column("boolean")
public success: boolean;
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: Relation<User>;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
JoinColumn,
Column,
ManyToOne,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { id } from "../id.js";
@ -21,12 +22,6 @@ export class SwSubscription {
@Column(id())
public userId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
@Column("varchar", {
length: 512,
})
@ -46,4 +41,12 @@ export class SwSubscription {
default: false,
})
public sendReadMessage: boolean;
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: Relation<User>;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
JoinColumn,
Column,
ManyToOne,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { UserGroup } from "./user-group.js";
@ -28,12 +29,6 @@ export class UserGroupInvitation {
})
public userId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
@Index()
@Column({
...id(),
@ -41,9 +36,17 @@ export class UserGroupInvitation {
})
public userGroupId: UserGroup["id"];
@ManyToOne((type) => UserGroup, {
//#region Relation
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public userGroup: UserGroup | null;
public user: Relation<User>;
@ManyToOne(() => UserGroup, {
onDelete: "CASCADE",
})
@JoinColumn()
public userGroup: Relation<UserGroup>;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
JoinColumn,
Column,
ManyToOne,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { UserGroup } from "./user-group.js";
@ -28,12 +29,6 @@ export class UserGroupJoining {
})
public userId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
@Index()
@Column({
...id(),
@ -41,9 +36,17 @@ export class UserGroupJoining {
})
public userGroupId: UserGroup["id"];
@ManyToOne((type) => UserGroup, {
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public userGroup: UserGroup | null;
public user: Relation<User>;
@ManyToOne(() => UserGroup, {
onDelete: "CASCADE",
})
@JoinColumn()
public userGroup: Relation<UserGroup>;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
Column,
PrimaryColumn,
ManyToOne,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { id } from "../id.js";
@ -32,17 +33,19 @@ export class UserGroup {
})
public userId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
@Column("boolean", {
default: false,
})
public isPrivate: boolean;
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: Relation<User>;
//#endregion
constructor(data: Partial<UserGroup>) {
if (data == null) return;

View File

@ -1,4 +1,11 @@
import { PrimaryColumn, Entity, JoinColumn, Column, OneToOne } from "typeorm";
import {
PrimaryColumn,
Entity,
JoinColumn,
Column,
OneToOne,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { id } from "../id.js";
@ -7,12 +14,6 @@ export class UserKeypair {
@PrimaryColumn(id())
public userId: User["id"];
@OneToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
@Column("varchar", {
length: 4096,
})
@ -23,6 +24,14 @@ export class UserKeypair {
})
public privateKey: string;
//#region Relations
@OneToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: Relation<User>;
//#endregion
constructor(data: Partial<UserKeypair>) {
if (data == null) return;

View File

@ -5,6 +5,7 @@ import {
JoinColumn,
Column,
ManyToOne,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { UserList } from "./user-list.js";
@ -28,12 +29,6 @@ export class UserListJoining {
})
public userId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
@Index()
@Column({
...id(),
@ -41,9 +36,17 @@ export class UserListJoining {
})
public userListId: UserList["id"];
@ManyToOne((type) => UserList, {
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public userList: UserList | null;
public user: Relation<User>;
@ManyToOne(() => UserList, {
onDelete: "CASCADE",
})
@JoinColumn()
public userList: Relation<UserList>;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
JoinColumn,
Column,
ManyToOne,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { id } from "../id.js";
@ -26,15 +27,17 @@ export class UserList {
})
public userId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
@Column("varchar", {
length: 128,
comment: "The name of the UserList.",
})
public name: string;
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: Relation<User>;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
JoinColumn,
Column,
ManyToOne,
type Relation,
} from "typeorm";
import { Note } from "./note.js";
import { User } from "./user.js";
@ -25,18 +26,20 @@ export class UserNotePining {
@Column(id())
public userId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
@Column(id())
public noteId: Note["id"];
@ManyToOne((type) => Note, {
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public note: Note | null;
public user: Relation<User>;
@ManyToOne(() => Note, {
onDelete: "CASCADE",
})
@JoinColumn()
public note: Relation<Note>;
//#endregion
}

View File

@ -5,6 +5,7 @@ import {
OneToOne,
JoinColumn,
PrimaryColumn,
type Relation,
} from "typeorm";
import { ffVisibility, notificationTypes } from "@/types.js";
import { id } from "../id.js";
@ -18,12 +19,6 @@ export class UserProfile {
@PrimaryColumn(id())
public userId: User["id"];
@OneToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
@Column("varchar", {
length: 128,
nullable: true,
@ -246,6 +241,14 @@ export class UserProfile {
public userHost: string | null;
//#endregion
//#region Relations
@OneToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: Relation<User>;
//#endregion
constructor(data: Partial<UserProfile>) {
if (data == null) return;

View File

@ -5,6 +5,7 @@ import {
JoinColumn,
Column,
OneToOne,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { id } from "../id.js";
@ -14,12 +15,6 @@ export class UserPublickey {
@PrimaryColumn(id())
public userId: User["id"];
@OneToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
@Index({ unique: true })
@Column("varchar", {
length: 512,
@ -31,6 +26,14 @@ export class UserPublickey {
})
public keyPem: string;
//#region Relations
@OneToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: Relation<User>;
//#endregion
constructor(data: Partial<UserPublickey>) {
if (data == null) return;

View File

@ -5,6 +5,7 @@ import {
Column,
ManyToOne,
Index,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { id } from "../id.js";
@ -20,12 +21,6 @@ export class UserSecurityKey {
@Column(id())
public userId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
@Index()
@Column("varchar", {
comment:
@ -45,6 +40,14 @@ export class UserSecurityKey {
})
public name: string;
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: Relation<User>;
//#endregion
constructor(data: Partial<UserSecurityKey>) {
if (data == null) return;

View File

@ -5,6 +5,7 @@ import {
OneToOne,
JoinColumn,
PrimaryColumn,
type Relation,
} from "typeorm";
import { id } from "../id.js";
import { DriveFile } from "./drive-file.js";
@ -106,12 +107,6 @@ export class User {
})
public avatarId: DriveFile["id"] | null;
@OneToOne((type) => DriveFile, {
onDelete: "SET NULL",
})
@JoinColumn()
public avatar: DriveFile | null;
@Column({
...id(),
nullable: true,
@ -119,12 +114,6 @@ export class User {
})
public bannerId: DriveFile["id"] | null;
@OneToOne((type) => DriveFile, {
onDelete: "SET NULL",
})
@JoinColumn()
public banner: DriveFile | null;
@Index()
@Column("varchar", {
length: 128,
@ -286,6 +275,22 @@ export class User {
})
public isIndexable: boolean;
//#region Relations
@OneToOne(() => DriveFile, {
onDelete: "SET NULL",
nullable: true,
})
@JoinColumn()
public avatar: Relation<DriveFile | null>;
@OneToOne(() => DriveFile, {
onDelete: "SET NULL",
nullable: true,
})
@JoinColumn()
public banner: Relation<DriveFile | null>;
//#endregion
constructor(data: Partial<User>) {
if (data == null) return;

View File

@ -5,6 +5,7 @@ import {
JoinColumn,
Column,
ManyToOne,
type Relation,
} from "typeorm";
import { User } from "./user.js";
import { id } from "../id.js";
@ -37,12 +38,6 @@ export class Webhook {
})
public userId: User["id"];
@ManyToOne((type) => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: User | null;
@Column("varchar", {
length: 128,
comment: "The name of the Antenna.",
@ -88,4 +83,12 @@ export class Webhook {
nullable: true,
})
public latestStatus: number | null;
//#region Relations
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
@JoinColumn()
public user: Relation<User>;
//#endregion
}

View File

@ -297,22 +297,14 @@
</template>
<script lang="ts" setup>
import {
computed,
defineAsyncComponent,
inject,
nextTick,
onMounted,
ref,
watch,
} from "vue";
import { computed, inject, nextTick, onMounted, ref, watch } from "vue";
import * as mfm from "mfm-js";
import autosize from "autosize";
import insertTextAtCursor from "insert-text-at-cursor";
import { length } from "stringz";
import { toASCII } from "punycode/";
import { acct } from "firefish-js";
import type { entities, languages, noteVisibilities } from "firefish-js";
import type { entities, languages } from "firefish-js";
import { throttle } from "throttle-debounce";
import XNoteSimple from "@/components/MkNoteSimple.vue";
import XNotePreview from "@/components/MkNotePreview.vue";
@ -347,6 +339,8 @@ import {
} from "@/scripts/language-utils";
import type { MenuItem } from "@/types/menu";
import icon from "@/scripts/icon";
import MkVisibilityPicker from "@/components/MkVisibilityPicker.vue";
import type { NoteVisibility } from "@/types/note";
const modal = inject("modal");
@ -358,7 +352,7 @@ const props = withDefaults(
mention?: entities.User;
specified?: entities.User;
initialText?: string;
initialVisibility?: typeof noteVisibilities;
initialVisibility?: NoteVisibility;
initialLanguage?: typeof languages;
initialFiles?: entities.DriveFile[];
initialLocalOnly?: boolean;
@ -412,10 +406,9 @@ const localOnly = ref<boolean>(
);
const visibility = ref(
props.initialVisibility ??
((defaultStore.state.rememberNoteVisibility
(defaultStore.state.rememberNoteVisibility
? defaultStore.state.visibility
: defaultStore.state
.defaultNoteVisibility) as (typeof noteVisibilities)[number]),
: defaultStore.state.defaultNoteVisibility),
);
const visibleUsers = ref([]);
@ -737,7 +730,7 @@ function setVisibility() {
}
os.popup(
defineAsyncComponent(() => import("@/components/MkVisibilityPicker.vue")),
MkVisibilityPicker,
{
currentVisibility: visibility.value,
currentLocalOnly: localOnly.value,

View File

@ -21,9 +21,10 @@
<script lang="ts" setup>
import { shallowRef } from "vue";
import type { entities, languages, noteVisibilities } from "firefish-js";
import type { entities, languages } from "firefish-js";
import MkModal from "@/components/MkModal.vue";
import MkPostForm from "@/components/MkPostForm.vue";
import type { NoteVisibility } from "@/types/note";
const props = defineProps<{
reply?: entities.Note;
@ -32,7 +33,7 @@ const props = defineProps<{
mention?: entities.User;
specified?: entities.User;
initialText?: string;
initialVisibility?: typeof noteVisibilities;
initialVisibility?: NoteVisibility;
initialLanguage?: typeof languages;
initialFiles?: entities.DriveFile[];
initialLocalOnly?: boolean;

View File

@ -142,16 +142,16 @@
<script lang="ts" setup>
import { nextTick, ref, shallowRef, watch } from "vue";
import type { noteVisibilities } from "firefish-js";
import MkModal from "@/components/MkModal.vue";
import { i18n } from "@/i18n";
import icon from "@/scripts/icon";
import type { NoteVisibility } from "@/types/note";
const modal = shallowRef<InstanceType<typeof MkModal>>();
const props = withDefaults(
defineProps<{
currentVisibility: (typeof noteVisibilities)[number];
currentVisibility: NoteVisibility;
currentLocalOnly: boolean;
src?: HTMLElement;
}>(),
@ -159,7 +159,7 @@ const props = withDefaults(
);
const emit = defineEmits<{
(ev: "changeVisibility", v: (typeof noteVisibilities)[number]): void;
(ev: "changeVisibility", v: NoteVisibility): void;
(ev: "changeLocalOnly", v: boolean): void;
(ev: "closed"): void;
}>();
@ -171,9 +171,7 @@ watch(localOnly, () => {
emit("changeLocalOnly", localOnly.value);
});
function choose(
visibility: (typeof noteVisibilities)[number] | "private",
): void {
function choose(visibility: NoteVisibility): void {
v.value = visibility;
emit("changeVisibility", visibility);
nextTick(() => {

View File

@ -34,7 +34,7 @@ import { computed, ref } from "vue";
// SPECIFICATION: https://misskey-hub.net/docs/features/share-form.html
import type { entities } from "firefish-js";
import { acct, noteVisibilities } from "firefish-js";
import { acct } from "firefish-js";
import MkButton from "@/components/MkButton.vue";
import XPostForm from "@/components/MkPostForm.vue";
import * as os from "@/os";
@ -42,6 +42,8 @@ import { mainRouter } from "@/router";
import { definePageMetadata } from "@/scripts/page-metadata";
import { i18n } from "@/i18n";
import icon from "@/scripts/icon";
import type { NoteVisibility } from "@/types/note";
import { noteVisibilitiesClient } from "@/scripts/consts";
const urlParams = new URLSearchParams(window.location.search);
const localOnlyQuery = urlParams.get("localOnly");
@ -54,8 +56,14 @@ const url = urlParams.get("url");
const initialText = ref(null as string | null);
const reply = ref(null as entities.Note | null);
const renote = ref(null as entities.Note | null);
function isVisibility(v: string | null): v is NoteVisibility {
if (v == null) return false;
return (noteVisibilitiesClient as readonly string[]).includes(v);
}
const visibility = ref(
noteVisibilities.includes(visibilityQuery) ? visibilityQuery : null,
isVisibility(visibilityQuery) ? visibilityQuery : undefined,
);
const localOnly = ref(
localOnlyQuery === "0" ? false : localOnlyQuery === "1" ? true : null,

View File

@ -0,0 +1,6 @@
import { noteVisibilities } from "firefish-js";
import type { NoteVisibility } from "@/types/note";
export const noteVisibilitiesClient = (
noteVisibilities as readonly NoteVisibility[]
).concat("private");

View File

@ -1,6 +1,7 @@
import { markRaw, ref } from "vue";
import { isSignedIn } from "./me";
import { Storage } from "./pizzax";
import type { NoteVisibility } from "@/types/note";
export const postFormActions = [];
export const userActions = [];
@ -75,7 +76,7 @@ export const defaultStore = markRaw(
},
defaultNoteVisibility: {
where: "account",
default: "public",
default: "public" as NoteVisibility,
},
defaultNoteLocalOnly: {
where: "account",
@ -123,12 +124,7 @@ export const defaultStore = markRaw(
},
visibility: {
where: "deviceAccount",
default: "public" as
| "public"
| "home"
| "followers"
| "specified"
| "private",
default: "public" as NoteVisibility,
},
localOnly: {
where: "deviceAccount",

View File

@ -0,0 +1,3 @@
import type { noteVisibilities } from "firefish-js";
export type NoteVisibility = (typeof noteVisibilities)[number] | "private";

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2021-2023 Kainoa Kanter, Firefish contributors, Syuilo, and misskey-js contributors
Copyright (c) 2021-2024 Firefish contributors, Kainoa Kanter, Syuilo, and misskey-js contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal