mirror of
https://activitypub.software/TransFem-org/Sharkey
synced 2024-11-23 22:45:11 +00:00
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
2 changed files with 29 additions and 19 deletions
|
@ -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';
|
||||||
|
@ -121,16 +122,6 @@ export class NoteEntityService implements OnModuleInit {
|
||||||
hide = false;
|
hide = false;
|
||||||
} else if (packedNote.renote && (meId === packedNote.renote.userId)) {
|
} else if (packedNote.renote && (meId === packedNote.renote.userId)) {
|
||||||
hide = false;
|
hide = false;
|
||||||
} else {
|
|
||||||
if (packedNote.renote) {
|
|
||||||
const isFollowing = await this.followingsRepository.exists({
|
|
||||||
where: {
|
|
||||||
followeeId: packedNote.renote.userId,
|
|
||||||
followerId: meId,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
hide = !isFollowing;
|
|
||||||
} else {
|
} else {
|
||||||
// フォロワーかどうか
|
// フォロワーかどうか
|
||||||
const isFollowing = await this.followingsRepository.exists({
|
const isFollowing = await this.followingsRepository.exists({
|
||||||
|
@ -143,6 +134,13 @@ export class NoteEntityService implements OnModuleInit {
|
||||||
hide = !isFollowing;
|
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) {
|
||||||
|
|
|
@ -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 a new issue