merge: Fix note hiding when renote and target have different visibility settings (resolves #803) (!741)
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/741 Closes #803 Approved-by: dakkar <dakkar@thenautilus.net> Approved-by: Marie <github@yuugi.dev>
This commit is contained in:
commit
7e3f519a5b
|
@ -16,6 +16,7 @@ import { bindThis } from '@/decorators.js';
|
||||||
import { DebounceLoader } from '@/misc/loader.js';
|
import { DebounceLoader } from '@/misc/loader.js';
|
||||||
import { IdService } from '@/core/IdService.js';
|
import { IdService } from '@/core/IdService.js';
|
||||||
import { ReactionsBufferingService } from '@/core/ReactionsBufferingService.js';
|
import { ReactionsBufferingService } from '@/core/ReactionsBufferingService.js';
|
||||||
|
import { isPackedPureRenote } from '@/misc/is-renote.js';
|
||||||
import type { OnModuleInit } from '@nestjs/common';
|
import type { OnModuleInit } from '@nestjs/common';
|
||||||
import type { CacheService } from '../CacheService.js';
|
import type { CacheService } from '../CacheService.js';
|
||||||
import type { CustomEmojiService } from '../CustomEmojiService.js';
|
import type { CustomEmojiService } from '../CustomEmojiService.js';
|
||||||
|
@ -122,29 +123,26 @@ export class NoteEntityService implements OnModuleInit {
|
||||||
} else if (packedNote.renote && (meId === packedNote.renote.userId)) {
|
} else if (packedNote.renote && (meId === packedNote.renote.userId)) {
|
||||||
hide = false;
|
hide = false;
|
||||||
} else {
|
} else {
|
||||||
if (packedNote.renote) {
|
// フォロワーかどうか
|
||||||
const isFollowing = await this.followingsRepository.exists({
|
const isFollowing = await this.followingsRepository.exists({
|
||||||
where: {
|
where: {
|
||||||
followeeId: packedNote.renote.userId,
|
followeeId: packedNote.userId,
|
||||||
followerId: meId,
|
followerId: meId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
hide = !isFollowing;
|
hide = !isFollowing;
|
||||||
} else {
|
|
||||||
// フォロワーかどうか
|
|
||||||
const isFollowing = await this.followingsRepository.exists({
|
|
||||||
where: {
|
|
||||||
followeeId: packedNote.userId,
|
|
||||||
followerId: meId,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
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 && isPackedPureRenote(packedNote)) {
|
||||||
|
hide = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!hide && meId && packedNote.userId !== meId) {
|
if (!hide && meId && packedNote.userId !== meId) {
|
||||||
const isBlocked = (await this.cacheService.userBlockedCache.fetch(meId)).has(packedNote.userId);
|
const isBlocked = (await this.cacheService.userBlockedCache.fetch(meId)).has(packedNote.userId);
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,14 @@ type PackedQuote =
|
||||||
fileIds: NonNullable<Packed<'Note'>['fileIds']>
|
fileIds: NonNullable<Packed<'Note'>['fileIds']>
|
||||||
});
|
});
|
||||||
|
|
||||||
|
type PackedPureRenote = PackedRenote & {
|
||||||
|
text: NonNullable<Packed<'Note'>['text']>;
|
||||||
|
cw: NonNullable<Packed<'Note'>['cw']>;
|
||||||
|
replyId: NonNullable<Packed<'Note'>['replyId']>;
|
||||||
|
poll: NonNullable<Packed<'Note'>['poll']>;
|
||||||
|
fileIds: NonNullable<Packed<'Note'>['fileIds']>;
|
||||||
|
}
|
||||||
|
|
||||||
export function isRenotePacked(note: Packed<'Note'>): note is PackedRenote {
|
export function isRenotePacked(note: Packed<'Note'>): note is PackedRenote {
|
||||||
return note.renoteId != null;
|
return note.renoteId != null;
|
||||||
}
|
}
|
||||||
|
@ -80,3 +88,7 @@ export function isQuotePacked(note: PackedRenote): note is PackedQuote {
|
||||||
note.poll != null ||
|
note.poll != null ||
|
||||||
(note.fileIds != null && note.fileIds.length > 0);
|
(note.fileIds != null && note.fileIds.length > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isPackedPureRenote(note: Packed<'Note'>): note is PackedPureRenote {
|
||||||
|
return isRenotePacked(note) && !isQuotePacked(note);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue