fix(backend/notes/mentions): @mentionされていないノートがあなた宛てに載ってしまう問題を修正 (MisskeyIO#388)

通常のspecified投稿の場合、visibleUserIdsはmentionsに含まれるので、このクエリーでvisibleUserIdsを参照する必要はない
This commit is contained in:
まっちゃとーにゅ 2024-01-27 01:02:36 +09:00 committed by GitHub
parent 39334aa026
commit 1e093f3dac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 8 deletions

View File

@ -3,7 +3,6 @@
* SPDX-License-Identifier: AGPL-3.0-only * SPDX-License-Identifier: AGPL-3.0-only
*/ */
import { Brackets } from 'typeorm';
import { Inject, Injectable } from '@nestjs/common'; import { Inject, Injectable } from '@nestjs/common';
import type { NotesRepository, FollowingsRepository } from '@/models/_.js'; import type { NotesRepository, FollowingsRepository } from '@/models/_.js';
import { Endpoint } from '@/server/api/endpoint-base.js'; import { Endpoint } from '@/server/api/endpoint-base.js';
@ -60,13 +59,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
.where('following.followerId = :followerId', { followerId: me.id }); .where('following.followerId = :followerId', { followerId: me.id });
const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'), ps.sinceId, ps.untilId) const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'), ps.sinceId, ps.untilId)
.andWhere(new Brackets(qb => { .andWhere(':meIdAsList <@ note.mentions') // このmeIdAsListパラメータはqueryServiceのgenerateVisibilityQueryでセットされる
qb // このmeIdAsListパラメータはqueryServiceのgenerateVisibilityQueryでセットされる .orderBy('CONCAT(note.id)', 'DESC') // Avoid scanning primary key index
.where(':meIdAsList <@ note.mentions')
.orWhere(':meIdAsList <@ note.visibleUserIds');
}))
// Avoid scanning primary key index
.orderBy('CONCAT(note.id)', 'DESC')
.innerJoinAndSelect('note.user', 'user') .innerJoinAndSelect('note.user', 'user')
.leftJoinAndSelect('note.reply', 'reply') .leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote') .leftJoinAndSelect('note.renote', 'renote')