parent
b5a1fdd4c7
commit
cf43dd6ec5
32 changed files with 485 additions and 12 deletions
48
src/models/entities/muted-note.ts
Normal file
48
src/models/entities/muted-note.ts
Normal file
|
@ -0,0 +1,48 @@
|
|||
import { Entity, Index, JoinColumn, Column, ManyToOne, PrimaryColumn } from 'typeorm';
|
||||
import { Note } from './note';
|
||||
import { User } from './user';
|
||||
import { id } from '../id';
|
||||
import { mutedNoteReasons } from '../../types';
|
||||
|
||||
@Entity()
|
||||
@Index(['noteId', 'userId'], { unique: true })
|
||||
export class MutedNote {
|
||||
@PrimaryColumn(id())
|
||||
public id: string;
|
||||
|
||||
@Index()
|
||||
@Column({
|
||||
...id(),
|
||||
comment: 'The note ID.'
|
||||
})
|
||||
public noteId: Note['id'];
|
||||
|
||||
@ManyToOne(type => Note, {
|
||||
onDelete: 'CASCADE'
|
||||
})
|
||||
@JoinColumn()
|
||||
public note: Note | null;
|
||||
|
||||
@Index()
|
||||
@Column({
|
||||
...id(),
|
||||
comment: 'The user ID.'
|
||||
})
|
||||
public userId: User['id'];
|
||||
|
||||
@ManyToOne(type => User, {
|
||||
onDelete: 'CASCADE'
|
||||
})
|
||||
@JoinColumn()
|
||||
public user: User | null;
|
||||
|
||||
/**
|
||||
* ミュートされた理由。
|
||||
*/
|
||||
@Index()
|
||||
@Column('enum', {
|
||||
enum: mutedNoteReasons,
|
||||
comment: 'The reason of the MutedNote.'
|
||||
})
|
||||
public reason: typeof mutedNoteReasons[number];
|
||||
}
|
|
@ -147,6 +147,17 @@ export class UserProfile {
|
|||
})
|
||||
public integrations: Record<string, any>;
|
||||
|
||||
@Index()
|
||||
@Column('boolean', {
|
||||
default: false,
|
||||
})
|
||||
public enableWordMute: boolean;
|
||||
|
||||
@Column('jsonb', {
|
||||
default: []
|
||||
})
|
||||
public mutedWords: string[][];
|
||||
|
||||
//#region Denormalized fields
|
||||
@Index()
|
||||
@Column('varchar', {
|
||||
|
|
|
@ -53,6 +53,7 @@ import { PromoNote } from './entities/promo-note';
|
|||
import { PromoRead } from './entities/promo-read';
|
||||
import { EmojiRepository } from './repositories/emoji';
|
||||
import { RelayRepository } from './repositories/relay';
|
||||
import { MutedNote } from './entities/muted-note';
|
||||
|
||||
export const Announcements = getRepository(Announcement);
|
||||
export const AnnouncementReads = getRepository(AnnouncementRead);
|
||||
|
@ -108,3 +109,4 @@ export const AntennaNotes = getRepository(AntennaNote);
|
|||
export const PromoNotes = getRepository(PromoNote);
|
||||
export const PromoReads = getRepository(PromoRead);
|
||||
export const Relays = getCustomRepository(RelayRepository);
|
||||
export const MutedNotes = getRepository(MutedNote);
|
||||
|
|
|
@ -239,6 +239,7 @@ export class UserRepository extends Repository<User> {
|
|||
hasUnreadNotification: this.getHasUnreadNotification(user.id),
|
||||
hasPendingReceivedFollowRequest: this.getHasPendingReceivedFollowRequest(user.id),
|
||||
integrations: profile!.integrations,
|
||||
mutedWords: profile!.mutedWords,
|
||||
} : {}),
|
||||
|
||||
...(opts.includeSecrets ? {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue