perf: early return users/notes and users/featured-notes if me is blocked by requesting user (#12663)

This commit is contained in:
anatawa12 2023-12-15 11:24:13 +09:00 committed by GitHub
parent 5cc3d3c873
commit bd4d8694dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 3 deletions

View file

@ -86,6 +86,14 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
if (ps.withReplies && ps.withFiles) throw new ApiError(meta.errors.bothWithRepliesAndWithFiles);
// early return if me is blocked by requesting user
if (me != null) {
const userIdsWhoBlockingMe = await this.cacheService.userBlockedCache.fetch(me.id);
if (userIdsWhoBlockingMe.has(ps.userId)) {
return [];
}
}
if (!serverSettings.enableFanoutTimeline) {
const timeline = await this.getFromDb({
untilId,