mute silenced notes in frontend
This commit is contained in:
parent
24e14c78fd
commit
64694be004
8 changed files with 39 additions and 3 deletions
4
locales/index.d.ts
vendored
4
locales/index.d.ts
vendored
|
|
@ -12092,6 +12092,10 @@ export interface Locale extends ILocale {
|
|||
* {name} said something in a muted thread
|
||||
*/
|
||||
"userSaysSomethingInMutedThread": ParameterizedString<"name">;
|
||||
/**
|
||||
* {name} has been silenced by {host} staff
|
||||
*/
|
||||
"silencedUserSaysSomething": ParameterizedString<"name" | "host">;
|
||||
/**
|
||||
* {name} is flagged: "{cw}"
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -409,6 +409,7 @@ export class WebhookTestService {
|
|||
isMutingNote: false,
|
||||
isFavorited: false,
|
||||
isRenoted: false,
|
||||
isSilenced: false,
|
||||
visibility: note.visibility,
|
||||
mentions: note.mentions,
|
||||
visibleUserIds: note.visibleUserIds,
|
||||
|
|
|
|||
|
|
@ -642,13 +642,26 @@ export class NoteEntityService implements OnModuleInit {
|
|||
.getExists() : false),
|
||||
]);
|
||||
|
||||
const packedUser = packedUsers?.get(note.userId) ?? this.userEntityService.pack(note.user ?? note.userId, me);
|
||||
const isSilenced = Promise.resolve(packedUser).then(async u => {
|
||||
if (!u.isSilenced && !u.instance?.isSilenced) return false;
|
||||
if (note.userId === meId) return false;
|
||||
|
||||
if (meId) {
|
||||
const followings = opts._hint_?.userFollowings ?? await this.cacheService.userFollowingsCache.fetch(meId);
|
||||
if (followings.has(note.userId)) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
const packed: Packed<'Note'> = await awaitAll({
|
||||
id: note.id,
|
||||
threadId,
|
||||
createdAt: this.idService.parse(note.id).date.toISOString(),
|
||||
updatedAt: note.updatedAt ? note.updatedAt.toISOString() : undefined,
|
||||
userId: note.userId,
|
||||
user: packedUsers?.get(note.userId) ?? this.userEntityService.pack(note.user ?? note.userId, me),
|
||||
user: packedUser,
|
||||
text: text,
|
||||
cw: note.cw,
|
||||
mandatoryCW: note.mandatoryCW,
|
||||
|
|
@ -689,6 +702,7 @@ export class NoteEntityService implements OnModuleInit {
|
|||
isMutingNote: mutedNotes.has(note.id),
|
||||
isFavorited,
|
||||
isRenoted,
|
||||
isSilenced,
|
||||
|
||||
...(meId && Object.keys(reactions).length > 0 ? {
|
||||
myReaction: this.populateMyReaction({
|
||||
|
|
|
|||
|
|
@ -193,6 +193,10 @@ export const packedNoteSchema = {
|
|||
type: 'boolean',
|
||||
optional: false, nullable: false,
|
||||
},
|
||||
isSilenced: {
|
||||
type: 'boolean',
|
||||
optional: false, nullable: false,
|
||||
},
|
||||
emojis: {
|
||||
type: 'object',
|
||||
optional: true, nullable: false,
|
||||
|
|
|
|||
|
|
@ -47,6 +47,16 @@ Displays a placeholder for a muted note.
|
|||
</template>
|
||||
</I18n>
|
||||
|
||||
<!-- Silenced users/instances -->
|
||||
<I18n v-if="mute.isSilenced" :src="i18n.ts.silencedUserSaysSomething" tag="small">
|
||||
<template #name>
|
||||
<MkUserName :user="note.user"/>
|
||||
</template>
|
||||
<template #host>
|
||||
{{ host }}
|
||||
</template>
|
||||
</I18n>
|
||||
|
||||
<!-- Word mutes -->
|
||||
<template v-if="mutedWords">
|
||||
<I18n v-if="prefer.s.showSoftWordMutedWord" :src="i18n.ts.userSaysSomethingAbout" tag="small">
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ export interface Mute {
|
|||
softMutedWords?: string[];
|
||||
sensitiveMuted?: boolean;
|
||||
|
||||
isSensitive?: boolean;
|
||||
isSilenced?: boolean;
|
||||
|
||||
threadMuted?: boolean;
|
||||
noteMuted?: boolean;
|
||||
|
|
@ -110,6 +110,7 @@ function getMutes(note: Misskey.entities.Note, withHardMute: boolean, overrides:
|
|||
const hardMuted = override.hardMuted ?? (!isMe && withHardMute && isHardMuted(note));
|
||||
const softMutedWords = override.softMutedWords ?? (isMe ? [] : isSoftMuted(note));
|
||||
const sensitiveMuted = override.sensitiveMuted ?? isSensitiveMuted(note);
|
||||
const isSilenced = override.isSilenced ?? note.isSilenced;
|
||||
const threadMuted = override.threadMuted ?? (!isMe && note.isMutingThread);
|
||||
const noteMuted = override.noteMuted ?? (!isMe && note.isMutingNote);
|
||||
const noteMandatoryCW = override.noteMandatoryCW !== undefined
|
||||
|
|
@ -126,7 +127,7 @@ function getMutes(note: Misskey.entities.Note, withHardMute: boolean, overrides:
|
|||
|
||||
const hasMute = hardMuted || softMutedWords.length > 0 || sensitiveMuted || threadMuted || noteMuted || !!noteMandatoryCW || !!userMandatoryCW || !!instanceMandatoryCW;
|
||||
|
||||
return { hasMute, hardMuted, softMutedWords, sensitiveMuted, threadMuted, noteMuted, noteMandatoryCW, userMandatoryCW, instanceMandatoryCW };
|
||||
return { hasMute, hardMuted, softMutedWords, sensitiveMuted, isSilenced, threadMuted, noteMuted, noteMandatoryCW, userMandatoryCW, instanceMandatoryCW };
|
||||
}
|
||||
|
||||
function isHardMuted(note: Misskey.entities.Note): boolean {
|
||||
|
|
|
|||
|
|
@ -4731,6 +4731,7 @@ export type components = {
|
|||
isMutingNote: boolean;
|
||||
isFavorited: boolean;
|
||||
isRenoted: boolean;
|
||||
isSilenced: boolean;
|
||||
emojis?: {
|
||||
[key: string]: string;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ muteNote: "Mute note"
|
|||
unmuteNote: "Unmute note"
|
||||
userSaysSomethingInMutedNote: "{name} said something in a muted post"
|
||||
userSaysSomethingInMutedThread: "{name} said something in a muted thread"
|
||||
silencedUserSaysSomething: "{name} has been silenced by {host} staff"
|
||||
userIsFlaggedAs: "{name} is flagged: \"{cw}\""
|
||||
noteIsFlaggedAs: "Note is flagged: \"{cw}\""
|
||||
instanceIsFlaggedAs: "{name} is flagged: \"{cw}\""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue