fix note hiding when renote and target have different visibility settings

This commit is contained in:
Hazelnoot 2024-11-08 09:58:15 -05:00
parent 2fb2e52312
commit faf1b3559a
1 changed files with 17 additions and 19 deletions

View File

@ -16,6 +16,7 @@ import { bindThis } from '@/decorators.js';
import { DebounceLoader } from '@/misc/loader.js';
import { IdService } from '@/core/IdService.js';
import { ReactionsBufferingService } from '@/core/ReactionsBufferingService.js';
import { isPureRenotePacked } from '@/misc/is-renote.js';
import type { OnModuleInit } from '@nestjs/common';
import type { CacheService } from '../CacheService.js';
import type { CustomEmojiService } from '../CustomEmojiService.js';
@ -121,16 +122,6 @@ export class NoteEntityService implements OnModuleInit {
hide = false;
} else if (packedNote.renote && (meId === packedNote.renote.userId)) {
hide = false;
} else {
if (packedNote.renote) {
const isFollowing = await this.followingsRepository.exists({
where: {
followeeId: packedNote.renote.userId,
followerId: meId,
},
});
hide = !isFollowing;
} else {
// フォロワーかどうか
const isFollowing = await this.followingsRepository.exists({
@ -143,6 +134,13 @@ export class NoteEntityService implements OnModuleInit {
hide = !isFollowing;
}
}
// If this is a pure renote (boost), then we should *also* check the boosted note's visibility.
// Otherwise we can have empty notes on the timeline, which is not good.
// Notes are packed in depth-first order, so we can safely grab the "isHidden" property to avoid duplicated checks.
// This is pulled out to ensure that we check both the renote *and* the boosted note.
if (packedNote.renote?.isHidden && isPureRenotePacked(packedNote)) {
hide = true;
}
if (!hide && meId && packedNote.userId !== meId) {