diff --git a/packages/backend/migration/1747934911491-rename_followingVisibility.js b/packages/backend/migration/1747934911491-rename_followingVisibility.js new file mode 100644 index 0000000000..75f6db49ec --- /dev/null +++ b/packages/backend/migration/1747934911491-rename_followingVisibility.js @@ -0,0 +1,16 @@ +/* + * SPDX-FileCopyrightText: hazelnoot and other Sharkey contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +export class RenameFollowingVisibility1747934911491 { + name = 'RenameFollowingVisibility1747934911491' + + async up(queryRunner) { + await queryRunner.query(`ALTER TYPE "public"."user_profile_followingvisibility_enum" RENAME TO "user_profile_followingVisibility_enum"`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TYPE "public"."user_profile_followingVisibility_enum" RENAME TO "user_profile_followingvisibility_enum"`); + } +} diff --git a/packages/backend/migration/1747935197708-add_entity_comments.js b/packages/backend/migration/1747935197708-add_entity_comments.js new file mode 100644 index 0000000000..687c957425 --- /dev/null +++ b/packages/backend/migration/1747935197708-add_entity_comments.js @@ -0,0 +1,30 @@ +/* + * SPDX-FileCopyrightText: hazelnoot and other Sharkey contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +export class AddEntityComments1747935197708 { + name = 'AddEntityComments1747935197708' + + async up(queryRunner) { + await queryRunner.query(`COMMENT ON COLUMN "user"."backgroundId" IS 'The ID of background DriveFile.'`); + await queryRunner.query(`COMMENT ON COLUMN "user"."isSilenced" IS 'Whether the User is silenced.'`); + await queryRunner.query(`COMMENT ON COLUMN "user"."noindex" IS 'Whether the User''s notes dont get indexed.'`); + await queryRunner.query(`COMMENT ON COLUMN "user"."speakAsCat" IS 'Whether the User speaks in nya.'`); + await queryRunner.query(`COMMENT ON COLUMN "user_profile"."listenbrainz" IS 'The ListenBrainz username of the User.'`); + await queryRunner.query(`COMMENT ON COLUMN "note"."updatedAt" IS 'The update time of the Note.'`); + await queryRunner.query(`COMMENT ON COLUMN "meta"."trustedLinkUrlPatterns" IS 'An array of URL strings or regex that can be used to omit warnings about redirects to external sites. Separate them with spaces to specify AND, and enclose them with slashes to specify regular expressions. Each item is regarded as an OR.'`); + await queryRunner.query(`COMMENT ON COLUMN "note_edit"."oldDate" IS 'The old date from before the edit'`); + } + + async down(queryRunner) { + await queryRunner.query(`COMMENT ON COLUMN "note_edit"."oldDate" IS NULL`); + await queryRunner.query(`COMMENT ON COLUMN "meta"."trustedLinkUrlPatterns" IS NULL`); + await queryRunner.query(`COMMENT ON COLUMN "note"."updatedAt" IS 'The updated date of the Note.'`); + await queryRunner.query(`COMMENT ON COLUMN "user_profile"."listenbrainz" IS 'listenbrainz username to fetch currently playing.'`); + await queryRunner.query(`COMMENT ON COLUMN "user"."speakAsCat" IS 'Whether to speak as a cat if chosen.'`); + await queryRunner.query(`COMMENT ON COLUMN "user"."noindex" IS NULL`); + await queryRunner.query(`COMMENT ON COLUMN "user"."isSilenced" IS NULL`); + await queryRunner.query(`COMMENT ON COLUMN "user"."backgroundId" IS NULL`); + } +} diff --git a/packages/backend/migration/1747937504140-fix-system_webhook-updatedAt-default.js b/packages/backend/migration/1747937504140-fix-system_webhook-updatedAt-default.js new file mode 100644 index 0000000000..d30c6c4872 --- /dev/null +++ b/packages/backend/migration/1747937504140-fix-system_webhook-updatedAt-default.js @@ -0,0 +1,16 @@ +/* + * SPDX-FileCopyrightText: hazelnoot and other Sharkey contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +export class FixSystemWebhookUpdatedAtDefault1747937504140 { + name = 'FixSystemWebhookUpdatedAtDefault1747937504140' + + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "system_webhook" ALTER COLUMN "updatedAt" SET DEFAULT now()`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "system_webhook" ALTER COLUMN "updatedAt" SET DEFAULT CURRENT_TIMESTAMP`); + } +} diff --git a/packages/backend/migration/1747937670341-fix-abuse_report_notification_recipient-updatedAt-default.js b/packages/backend/migration/1747937670341-fix-abuse_report_notification_recipient-updatedAt-default.js new file mode 100644 index 0000000000..4364bbb56d --- /dev/null +++ b/packages/backend/migration/1747937670341-fix-abuse_report_notification_recipient-updatedAt-default.js @@ -0,0 +1,16 @@ +/* + * SPDX-FileCopyrightText: hazelnoot and other Sharkey contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +export class FixAbuseReportNotificationRecipientUpdatedAtDefault1747937670341 { + name = 'FixAbuseReportNotificationRecipientUpdatedAtDefault1747937670341' + + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "abuse_report_notification_recipient" ALTER COLUMN "updatedAt" SET DEFAULT now()`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "abuse_report_notification_recipient" ALTER COLUMN "updatedAt" SET DEFAULT CURRENT_TIMESTAMP`); + } +} diff --git a/packages/backend/migration/1747937796573-fix-flash-visibility-nullable.js b/packages/backend/migration/1747937796573-fix-flash-visibility-nullable.js new file mode 100644 index 0000000000..7076d05e19 --- /dev/null +++ b/packages/backend/migration/1747937796573-fix-flash-visibility-nullable.js @@ -0,0 +1,16 @@ +/* + * SPDX-FileCopyrightText: hazelnoot and other Sharkey contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +export class FixFlashVisibilityNullable1747937796573 { + name = 'FixFlashVisibilityNullable1747937796573' + + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "flash" ALTER COLUMN "visibility" SET NOT NULL`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "flash" ALTER COLUMN "visibility" DROP NOT NULL`); + } +} diff --git a/packages/backend/migration/1747938136399-fix-abuse_report_notification_recipient-defaults.js b/packages/backend/migration/1747938136399-fix-abuse_report_notification_recipient-defaults.js new file mode 100644 index 0000000000..6cf48bcbe9 --- /dev/null +++ b/packages/backend/migration/1747938136399-fix-abuse_report_notification_recipient-defaults.js @@ -0,0 +1,18 @@ +/* + * SPDX-FileCopyrightText: hazelnoot and other Sharkey contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +export class FixAbuseReportNotificationRecipientDefaults1747938136399 { + name = 'FixAbuseReportNotificationRecipientDefaults1747938136399' + + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "abuse_report_notification_recipient" ALTER COLUMN "userId" DROP DEFAULT`); + await queryRunner.query(`ALTER TABLE "abuse_report_notification_recipient" ALTER COLUMN "systemWebhookId" DROP DEFAULT`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "abuse_report_notification_recipient" ALTER COLUMN "systemWebhookId" SET DEFAULT NULL`); + await queryRunner.query(`ALTER TABLE "abuse_report_notification_recipient" ALTER COLUMN "userId" SET DEFAULT NULL`); + } +} diff --git a/packages/backend/migration/1747938263980-fix-meta-urlPreviewUserAgent-default.js b/packages/backend/migration/1747938263980-fix-meta-urlPreviewUserAgent-default.js new file mode 100644 index 0000000000..d04c1ac377 --- /dev/null +++ b/packages/backend/migration/1747938263980-fix-meta-urlPreviewUserAgent-default.js @@ -0,0 +1,16 @@ +/* + * SPDX-FileCopyrightText: hazelnoot and other Sharkey contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +export class FixMetaUrlPreviewUserAgentDefault1747938263980 { + name = 'FixMetaUrlPreviewUserAgentDefault1747938263980' + + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "meta" ALTER COLUMN "urlPreviewUserAgent" DROP DEFAULT`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "meta" ALTER COLUMN "urlPreviewUserAgent" SET DEFAULT NULL`); + } +} diff --git a/packages/backend/migration/1747938628395-add-missing-indexes.js b/packages/backend/migration/1747938628395-add-missing-indexes.js new file mode 100644 index 0000000000..745b39c855 --- /dev/null +++ b/packages/backend/migration/1747938628395-add-missing-indexes.js @@ -0,0 +1,22 @@ +/* + * SPDX-FileCopyrightText: hazelnoot and other Sharkey contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +export class AddMissingIndexes1747938628395 { + name = 'AddMissingIndexes1747938628395' + + async up(queryRunner) { + await queryRunner.query(`CREATE INDEX "IDX_58699f75b9cf904f5f007909cb" ON "user_profile" ("birthday") `); + await queryRunner.query(`CREATE INDEX "IDX_021015e6683570ae9f6b0c62be" ON "user_list_membership" ("userId") `); + await queryRunner.query(`CREATE INDEX "IDX_cddcaf418dc4d392ecfcca842a" ON "user_list_membership" ("userListId") `); + await queryRunner.query(`CREATE UNIQUE INDEX "IDX_e4f3094c43f2d665e6030b0337" ON "user_list_membership" ("userId", "userListId") `); + } + + async down(queryRunner) { + await queryRunner.query(`DROP INDEX "public"."IDX_e4f3094c43f2d665e6030b0337"`); + await queryRunner.query(`DROP INDEX "public"."IDX_cddcaf418dc4d392ecfcca842a"`); + await queryRunner.query(`DROP INDEX "public"."IDX_021015e6683570ae9f6b0c62be"`); + await queryRunner.query(`DROP INDEX "public"."IDX_58699f75b9cf904f5f007909cb"`); + } +} diff --git a/packages/backend/migration/1747944466178-alter-meta-defaultLike-not-null.js b/packages/backend/migration/1747944466178-alter-meta-defaultLike-not-null.js new file mode 100644 index 0000000000..b206a15ee2 --- /dev/null +++ b/packages/backend/migration/1747944466178-alter-meta-defaultLike-not-null.js @@ -0,0 +1,16 @@ +/* + * SPDX-FileCopyrightText: hazelnoot and other Sharkey contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +export class AlterMetaDefaultLikeNotNull1747944466178 { + name = 'AlterMetaDefaultLikeNotNull1747944466178' + + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "meta" ALTER COLUMN "defaultLike" SET NOT NULL`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "meta" ALTER COLUMN "defaultLike" DROP NOT NULL`); + } +} diff --git a/packages/backend/src/models/AbuseReportNotificationRecipient.ts b/packages/backend/src/models/AbuseReportNotificationRecipient.ts index fbff880afc..fd31354a80 100644 --- a/packages/backend/src/models/AbuseReportNotificationRecipient.ts +++ b/packages/backend/src/models/AbuseReportNotificationRecipient.ts @@ -22,7 +22,7 @@ export class MiAbuseReportNotificationRecipient { /** * 有効かどうか. */ - @Index() + @Index('IDX_abuse_report_notification_recipient_isActive') @Column('boolean', { default: true, }) @@ -47,7 +47,7 @@ export class MiAbuseReportNotificationRecipient { /** * 通知方法. */ - @Index() + @Index('IDX_abuse_report_notification_recipient_method') @Column('varchar', { length: 64, }) @@ -56,7 +56,7 @@ export class MiAbuseReportNotificationRecipient { /** * 通知先のユーザID. */ - @Index() + @Index('IDX_abuse_report_notification_recipient_userId') @Column({ ...id(), nullable: true, @@ -75,14 +75,16 @@ export class MiAbuseReportNotificationRecipient { /** * 通知先のユーザプロフィール. */ - @ManyToOne(type => MiUserProfile, {}) + @ManyToOne(type => MiUserProfile, { + onDelete: 'CASCADE', + }) @JoinColumn({ name: 'userId', referencedColumnName: 'userId', foreignKeyConstraintName: 'FK_abuse_report_notification_recipient_userId2' }) public userProfile: MiUserProfile | null; /** * 通知先のシステムWebhookId. */ - @Index() + @Index('IDX_abuse_report_notification_recipient_systemWebhookId') @Column({ ...id(), nullable: true, @@ -95,6 +97,8 @@ export class MiAbuseReportNotificationRecipient { @ManyToOne(type => MiSystemWebhook, { onDelete: 'CASCADE', }) - @JoinColumn() + @JoinColumn({ + foreignKeyConstraintName: 'FK_abuse_report_notification_recipient_systemWebhookId', + }) public systemWebhook: MiSystemWebhook | null; } diff --git a/packages/backend/src/models/Emoji.ts b/packages/backend/src/models/Emoji.ts index d62b6e9f6f..9f31455b83 100644 --- a/packages/backend/src/models/Emoji.ts +++ b/packages/backend/src/models/Emoji.ts @@ -29,6 +29,7 @@ export class MiEmoji { }) public host: string | null; + @Index('IDX_EMOJI_CATEGORY') @Column('varchar', { length: 128, nullable: true, }) @@ -77,6 +78,8 @@ export class MiEmoji { public isSensitive: boolean; // TODO: 定期ジョブで存在しなくなったロールIDを除去するようにする + // Synchronize: false is needed because TypeORM doesn't understand GIN indexes + @Index('IDX_EMOJI_ROLE_IDS', { synchronize: false }) @Column('varchar', { array: true, length: 128, default: '{}', }) diff --git a/packages/backend/src/models/LatestNote.ts b/packages/backend/src/models/LatestNote.ts index 064fcccc0a..37efb0d4b6 100644 --- a/packages/backend/src/models/LatestNote.ts +++ b/packages/backend/src/models/LatestNote.ts @@ -45,6 +45,7 @@ export class SkLatestNote { }) @JoinColumn({ name: 'user_id', + foreignKeyConstraintName: 'FK_20e346fffe4a2174585005d6d80', }) public user: MiUser | null; @@ -60,6 +61,7 @@ export class SkLatestNote { }) @JoinColumn({ name: 'note_id', + foreignKeyConstraintName: 'FK_47a38b1c13de6ce4e5090fb1acd', }) public note: MiNote | null; diff --git a/packages/backend/src/models/Meta.ts b/packages/backend/src/models/Meta.ts index 5292480142..b590015732 100644 --- a/packages/backend/src/models/Meta.ts +++ b/packages/backend/src/models/Meta.ts @@ -60,7 +60,7 @@ export class MiMeta { public maintainerEmail: string | null; @Column('boolean', { - default: false, + default: true, }) public disableRegistration: boolean; @@ -431,7 +431,7 @@ export class MiMeta { @Column('varchar', { length: 1024, default: 'https://activitypub.software/TransFem-org/Sharkey/', - nullable: false, + nullable: true, }) public repositoryUrl: string | null; @@ -618,8 +618,8 @@ export class MiMeta { }) public enableAchievements: boolean; - @Column('varchar', { - length: 2048, nullable: true, + @Column('text', { + nullable: true, }) public robotsTxt: string | null; @@ -649,7 +649,7 @@ export class MiMeta { public bannedEmailDomains: string[]; @Column('varchar', { - length: 1024, array: true, default: '{ "admin", "administrator", "root", "system", "maintainer", "host", "mod", "moderator", "owner", "superuser", "staff", "auth", "i", "me", "everyone", "all", "mention", "mentions", "example", "user", "users", "account", "accounts", "official", "help", "helps", "support", "supports", "info", "information", "informations", "announce", "announces", "announcement", "announcements", "notice", "notification", "notifications", "dev", "developer", "developers", "tech", "misskey" }', + length: 1024, array: true, default: '{admin,administrator,root,system,maintainer,host,mod,moderator,owner,superuser,staff,auth,i,me,everyone,all,mention,mentions,example,user,users,account,accounts,official,help,helps,support,supports,info,information,informations,announce,announces,announcement,announcements,notice,notification,notifications,dev,developer,developers,tech,misskey}', }) public preservedUsernames: string[]; @@ -664,22 +664,22 @@ export class MiMeta { public enableFanoutTimelineDbFallback: boolean; @Column('integer', { - default: 300, + default: 800, }) public perLocalUserUserTimelineCacheMax: number; @Column('integer', { - default: 100, + default: 800, }) public perRemoteUserUserTimelineCacheMax: number; @Column('integer', { - default: 300, + default: 800, }) public perUserHomeTimelineCacheMax: number; @Column('integer', { - default: 300, + default: 800, }) public perUserListTimelineCacheMax: number; @@ -695,9 +695,9 @@ export class MiMeta { @Column('varchar', { length: 500, - nullable: true, + default: '❤️', }) - public defaultLike: string | null; + public defaultLike: string; @Column('varchar', { length: 256, array: true, default: '{}', @@ -720,7 +720,7 @@ export class MiMeta { public urlPreviewMaximumContentLength: number; @Column('boolean', { - default: true, + default: false, }) public urlPreviewRequireContentLength: boolean; diff --git a/packages/backend/src/models/Note.ts b/packages/backend/src/models/Note.ts index 6b5ccf9e83..ee2098216d 100644 --- a/packages/backend/src/models/Note.ts +++ b/packages/backend/src/models/Note.ts @@ -10,7 +10,7 @@ import { MiUser } from './User.js'; import { MiChannel } from './Channel.js'; import type { MiDriveFile } from './DriveFile.js'; -@Index(['userId', 'id']) +@Index('IDX_724b311e6f883751f261ebe378', ['userId', 'id']) @Entity('note') export class MiNote { @PrimaryColumn(id()) diff --git a/packages/backend/src/models/User.ts b/packages/backend/src/models/User.ts index 760ef52d2b..46f8e84a94 100644 --- a/packages/backend/src/models/User.ts +++ b/packages/backend/src/models/User.ts @@ -129,7 +129,9 @@ export class MiUser { @OneToOne(() => MiDriveFile, { onDelete: 'SET NULL', }) - @JoinColumn() + @JoinColumn({ + foreignKeyConstraintName: 'FK_q5lm0tbgejtfskzg0rc4wd7t1n', + }) public background: MiDriveFile | null; // avatarId が null になったとしてもこれが null でない可能性があるため、このフィールドを使うときは avatarId の non-null チェックをすること @@ -345,7 +347,7 @@ export class MiUser { */ @Column('boolean', { name: 'enable_rss', - default: true, + default: false, }) public enableRss: boolean; diff --git a/packages/backend/src/models/UserListMembership.ts b/packages/backend/src/models/UserListMembership.ts index af659d071d..99ec8bdc26 100644 --- a/packages/backend/src/models/UserListMembership.ts +++ b/packages/backend/src/models/UserListMembership.ts @@ -24,7 +24,9 @@ export class MiUserListMembership { @ManyToOne(type => MiUser, { onDelete: 'CASCADE', }) - @JoinColumn() + @JoinColumn({ + foreignKeyConstraintName: 'FK_d844bfc6f3f523a05189076efaa', + }) public user: MiUser | null; @Index() @@ -37,7 +39,9 @@ export class MiUserListMembership { @ManyToOne(type => MiUserList, { onDelete: 'CASCADE', }) - @JoinColumn() + @JoinColumn({ + foreignKeyConstraintName: 'FK_605472305f26818cc93d1baaa74', + }) public userList: MiUserList | null; // タイムラインにその人のリプライまで含めるかどうか diff --git a/packages/backend/src/models/UserPending.ts b/packages/backend/src/models/UserPending.ts index 961ae344f1..972c862a1a 100644 --- a/packages/backend/src/models/UserPending.ts +++ b/packages/backend/src/models/UserPending.ts @@ -34,6 +34,7 @@ export class MiUserPending { @Column('varchar', { length: 1000, + nullable: true, }) public reason: string; } diff --git a/packages/backend/src/models/UserProfile.ts b/packages/backend/src/models/UserProfile.ts index cda55451d0..29c453dd71 100644 --- a/packages/backend/src/models/UserProfile.ts +++ b/packages/backend/src/models/UserProfile.ts @@ -110,12 +110,14 @@ export class MiUserProfile { @Column('enum', { enum: followingVisibilities, + enumName: 'user_profile_followingVisibility_enum', default: 'public', }) public followingVisibility: typeof followingVisibilities[number]; @Column('enum', { enum: followersVisibilities, + enumName: 'user_profile_followersVisibility_enum', default: 'public', }) public followersVisibility: typeof followersVisibilities[number]; diff --git a/packages/backend/src/server/api/endpoints/admin/meta.ts b/packages/backend/src/server/api/endpoints/admin/meta.ts index 13022f43a0..fe8ca012b2 100644 --- a/packages/backend/src/server/api/endpoints/admin/meta.ts +++ b/packages/backend/src/server/api/endpoints/admin/meta.ts @@ -481,6 +481,10 @@ export const meta = { type: 'string', optional: false, nullable: true, }, + defaultLike: { + type: 'string', + optional: false, nullable: false, + }, description: { type: 'string', optional: false, nullable: true, diff --git a/packages/backend/src/server/api/endpoints/admin/update-meta.ts b/packages/backend/src/server/api/endpoints/admin/update-meta.ts index 090681c134..7c3d485a0f 100644 --- a/packages/backend/src/server/api/endpoints/admin/update-meta.ts +++ b/packages/backend/src/server/api/endpoints/admin/update-meta.ts @@ -69,7 +69,7 @@ export const paramDef = { description: { type: 'string', nullable: true }, defaultLightTheme: { type: 'string', nullable: true }, defaultDarkTheme: { type: 'string', nullable: true }, - defaultLike: { type: 'string', nullable: true }, + defaultLike: { type: 'string' }, cacheRemoteFiles: { type: 'boolean' }, cacheRemoteSensitiveFiles: { type: 'boolean' }, emailRequiredForSignup: { type: 'boolean' }, diff --git a/packages/misskey-js/src/autogen/types.ts b/packages/misskey-js/src/autogen/types.ts index dee803a9e6..55302960dc 100644 --- a/packages/misskey-js/src/autogen/types.ts +++ b/packages/misskey-js/src/autogen/types.ts @@ -9259,6 +9259,7 @@ export type operations = { libreTranslateKey: string | null; defaultDarkTheme: string | null; defaultLightTheme: string | null; + defaultLike: string; description: string | null; disableRegistration: boolean; impressumUrl: string | null; @@ -12137,7 +12138,7 @@ export type operations = { description?: string | null; defaultLightTheme?: string | null; defaultDarkTheme?: string | null; - defaultLike?: string | null; + defaultLike?: string; cacheRemoteFiles?: boolean; cacheRemoteSensitiveFiles?: boolean; emailRequiredForSignup?: boolean;