feat: Per-user renote mute (#10249)
* feat: per-user renote muting From FoundKey/c414f24a2c https://akkoma.dev/FoundKeyGang/FoundKey * Update ja-JP.yml * Delete renote-muting.ts * rename * fix ids * lint * fix * Update CHANGELOG.md * リノートをミュートしたユーザー一覧を見れるように * 🎨 * add test * fix test --------- Co-authored-by: Hélène <pleroma-dev@helene.moe>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { User, Note, Announcement, AnnouncementRead, App, NoteFavorite, NoteThreadMuting, NoteReaction, NoteUnread, Notification, Poll, PollVote, UserProfile, UserKeypair, UserPending, AttestationChallenge, UserSecurityKey, UserPublickey, UserList, UserListJoining, UserNotePining, UserIp, UsedUsername, Following, FollowRequest, Instance, Emoji, DriveFile, DriveFolder, Meta, Muting, Blocking, SwSubscription, Hashtag, AbuseUserReport, RegistrationTicket, AuthSession, AccessToken, Signin, Page, PageLike, GalleryPost, GalleryLike, ModerationLog, Clip, ClipNote, Antenna, AntennaNote, PromoNote, PromoRead, Relay, MutedNote, Channel, ChannelFollowing, ChannelNotePining, RegistryItem, Webhook, Ad, PasswordResetRequest, RetentionAggregation, FlashLike, Flash, Role, RoleAssignment } from './index.js';
|
||||
import { User, Note, Announcement, AnnouncementRead, App, NoteFavorite, NoteThreadMuting, NoteReaction, NoteUnread, Notification, Poll, PollVote, UserProfile, UserKeypair, UserPending, AttestationChallenge, UserSecurityKey, UserPublickey, UserList, UserListJoining, UserNotePining, UserIp, UsedUsername, Following, FollowRequest, Instance, Emoji, DriveFile, DriveFolder, Meta, Muting, RenoteMuting, Blocking, SwSubscription, Hashtag, AbuseUserReport, RegistrationTicket, AuthSession, AccessToken, Signin, Page, PageLike, GalleryPost, GalleryLike, ModerationLog, Clip, ClipNote, Antenna, AntennaNote, PromoNote, PromoRead, Relay, MutedNote, Channel, ChannelFollowing, ChannelNotePining, RegistryItem, Webhook, Ad, PasswordResetRequest, RetentionAggregation, FlashLike, Flash, Role, RoleAssignment } from './index.js';
|
||||
import type { DataSource } from 'typeorm';
|
||||
import type { Provider } from '@nestjs/common';
|
||||
|
||||
@@ -190,6 +190,12 @@ const $mutingsRepository: Provider = {
|
||||
inject: [DI.db],
|
||||
};
|
||||
|
||||
const $renoteMutingsRepository: Provider = {
|
||||
provide: DI.renoteMutingsRepository,
|
||||
useFactory: (db: DataSource) => db.getRepository(RenoteMuting),
|
||||
inject: [DI.db],
|
||||
};
|
||||
|
||||
const $blockingsRepository: Provider = {
|
||||
provide: DI.blockingsRepository,
|
||||
useFactory: (db: DataSource) => db.getRepository(Blocking),
|
||||
@@ -423,6 +429,7 @@ const $roleAssignmentsRepository: Provider = {
|
||||
$notificationsRepository,
|
||||
$metasRepository,
|
||||
$mutingsRepository,
|
||||
$renoteMutingsRepository,
|
||||
$blockingsRepository,
|
||||
$swSubscriptionsRepository,
|
||||
$hashtagsRepository,
|
||||
@@ -489,6 +496,7 @@ const $roleAssignmentsRepository: Provider = {
|
||||
$notificationsRepository,
|
||||
$metasRepository,
|
||||
$mutingsRepository,
|
||||
$renoteMutingsRepository,
|
||||
$blockingsRepository,
|
||||
$swSubscriptionsRepository,
|
||||
$hashtagsRepository,
|
||||
|
42
packages/backend/src/models/entities/RenoteMuting.ts
Normal file
42
packages/backend/src/models/entities/RenoteMuting.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
|
||||
import { id } from '../id.js';
|
||||
import { User } from './User.js';
|
||||
|
||||
@Entity()
|
||||
@Index(['muterId', 'muteeId'], { unique: true })
|
||||
export class RenoteMuting {
|
||||
@PrimaryColumn(id())
|
||||
public id: string;
|
||||
|
||||
@Index()
|
||||
@Column('timestamp with time zone', {
|
||||
comment: 'The created date of the Muting.',
|
||||
})
|
||||
public createdAt: Date;
|
||||
|
||||
@Index()
|
||||
@Column({
|
||||
...id(),
|
||||
comment: 'The mutee user ID.',
|
||||
})
|
||||
public muteeId: User['id'];
|
||||
|
||||
@ManyToOne(type => User, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn()
|
||||
public mutee: User | null;
|
||||
|
||||
@Index()
|
||||
@Column({
|
||||
...id(),
|
||||
comment: 'The muter user ID.',
|
||||
})
|
||||
public muterId: User['id'];
|
||||
|
||||
@ManyToOne(type => User, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn()
|
||||
public muter: User | null;
|
||||
}
|
@@ -26,6 +26,7 @@ import { Meta } from '@/models/entities/Meta.js';
|
||||
import { ModerationLog } from '@/models/entities/ModerationLog.js';
|
||||
import { MutedNote } from '@/models/entities/MutedNote.js';
|
||||
import { Muting } from '@/models/entities/Muting.js';
|
||||
import { RenoteMuting } from '@/models/entities/RenoteMuting.js';
|
||||
import { Note } from '@/models/entities/Note.js';
|
||||
import { NoteFavorite } from '@/models/entities/NoteFavorite.js';
|
||||
import { NoteReaction } from '@/models/entities/NoteReaction.js';
|
||||
@@ -93,6 +94,7 @@ export {
|
||||
ModerationLog,
|
||||
MutedNote,
|
||||
Muting,
|
||||
RenoteMuting,
|
||||
Note,
|
||||
NoteFavorite,
|
||||
NoteReaction,
|
||||
@@ -159,6 +161,7 @@ export type MetasRepository = Repository<Meta>;
|
||||
export type ModerationLogsRepository = Repository<ModerationLog>;
|
||||
export type MutedNotesRepository = Repository<MutedNote>;
|
||||
export type MutingsRepository = Repository<Muting>;
|
||||
export type RenoteMutingsRepository = Repository<RenoteMuting>;
|
||||
export type NotesRepository = Repository<Note>;
|
||||
export type NoteFavoritesRepository = Repository<NoteFavorite>;
|
||||
export type NoteReactionsRepository = Repository<NoteReaction>;
|
||||
|
26
packages/backend/src/models/schema/renote-muting.ts
Normal file
26
packages/backend/src/models/schema/renote-muting.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
export const packedRenoteMutingSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
id: {
|
||||
type: 'string',
|
||||
optional: false, nullable: false,
|
||||
format: 'id',
|
||||
example: 'xxxxxxxxxx',
|
||||
},
|
||||
createdAt: {
|
||||
type: 'string',
|
||||
optional: false, nullable: false,
|
||||
format: 'date-time',
|
||||
},
|
||||
muteeId: {
|
||||
type: 'string',
|
||||
optional: false, nullable: false,
|
||||
format: 'id',
|
||||
},
|
||||
mutee: {
|
||||
type: 'object',
|
||||
optional: false, nullable: false,
|
||||
ref: 'UserDetailed',
|
||||
},
|
||||
},
|
||||
} as const;
|
@@ -234,6 +234,10 @@ export const packedUserDetailedNotMeOnlySchema = {
|
||||
type: 'boolean',
|
||||
nullable: false, optional: true,
|
||||
},
|
||||
isRenoteMuted: {
|
||||
type: 'boolean',
|
||||
nullable: false, optional: true,
|
||||
},
|
||||
//#endregion
|
||||
},
|
||||
} as const;
|
||||
|
Reference in New Issue
Block a user