diff --git a/packages/backend/migration/1655793461890-thread-mute-notifications.js b/packages/backend/migration/1655793461890-thread-mute-notifications.js new file mode 100644 index 000000000..89f340d5f --- /dev/null +++ b/packages/backend/migration/1655793461890-thread-mute-notifications.js @@ -0,0 +1,13 @@ +export class threadMuteNotifications1655793461890 { + name = 'threadMuteNotifications1655793461890' + + async up(queryRunner) { + await queryRunner.query(`CREATE TYPE "public"."note_thread_muting_mutingnotificationtypes_enum" AS ENUM('mention', 'reply', 'renote', 'quote', 'reaction', 'pollVote', 'pollEnded')`); + await queryRunner.query(`ALTER TABLE "note_thread_muting" ADD "mutingNotificationTypes" "public"."note_thread_muting_mutingnotificationtypes_enum" array NOT NULL DEFAULT '{}'`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "note_thread_muting" DROP COLUMN "mutingNotificationTypes"`); + await queryRunner.query(`DROP TYPE "public"."note_thread_muting_mutingnotificationtypes_enum"`); + } +} diff --git a/packages/backend/src/models/entities/note-thread-muting.ts b/packages/backend/src/models/entities/note-thread-muting.ts index 0f2a29171..f604054b2 100644 --- a/packages/backend/src/models/entities/note-thread-muting.ts +++ b/packages/backend/src/models/entities/note-thread-muting.ts @@ -1,4 +1,5 @@ import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm'; +import { noteNotificationTypes } from 'foundkey-js'; import { id } from '../id.js'; import { User } from './user.js'; import { Note } from './note.js'; @@ -30,4 +31,11 @@ export class NoteThreadMuting { length: 256, }) public threadId: string; + + @Column('enum', { + enum: noteNotificationTypes, + array: true, + default: [], + }) + public mutingNotificationTypes: typeof notificationTypes[number][]; } diff --git a/packages/foundkey-js/src/consts.ts b/packages/foundkey-js/src/consts.ts index df73e829d..645bdf223 100644 --- a/packages/foundkey-js/src/consts.ts +++ b/packages/foundkey-js/src/consts.ts @@ -1,5 +1,7 @@ export const notificationTypes = ['follow', 'mention', 'reply', 'renote', 'quote', 'reaction', 'pollVote', 'pollEnded', 'receiveFollowRequest', 'followRequestAccepted', 'groupInvited', 'app'] as const; +export const noteNotificationTypes = ['mention', 'reply', 'renote', 'quote', 'reaction', 'pollVote', 'pollEnded'] as const; + export const mutedNoteReasons = ['word', 'manual', 'spam', 'other'] as const; export const ffVisibility = ['public', 'followers', 'private'] as const; diff --git a/packages/foundkey-js/src/index.ts b/packages/foundkey-js/src/index.ts index 61d34310b..5acac2748 100644 --- a/packages/foundkey-js/src/index.ts +++ b/packages/foundkey-js/src/index.ts @@ -10,6 +10,7 @@ export { export { permissions, notificationTypes, + noteNotificationTypes, mutedNoteReasons, ffVisibility, } from './consts.js';