This commit is contained in:
syuilo 2023-10-01 20:25:51 +09:00
parent 06cfe618bb
commit 3dd3c69303
2 changed files with 28 additions and 28 deletions

View File

@ -14,6 +14,7 @@ import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
import { DI } from '@/di-symbols.js'; import { DI } from '@/di-symbols.js';
import { IdService } from '@/core/IdService.js'; import { IdService } from '@/core/IdService.js';
import { CacheService } from '@/core/CacheService.js'; import { CacheService } from '@/core/CacheService.js';
import { isUserRelated } from '@/misc/is-user-related.js';
export const meta = { export const meta = {
tags: ['notes'], tags: ['notes'],
@ -64,7 +65,13 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
private cacheService: CacheService, private cacheService: CacheService,
) { ) {
super(meta, paramDef, async (ps, me) => { super(meta, paramDef, async (ps, me) => {
const mutings = await this.cacheService.userMutingsCache.fetch(me.id); const [
userIdsWhoMeMuting,
userIdsWhoMeMutingRenotes,
] = await Promise.all([
this.cacheService.userMutingsCache.fetch(me.id),
this.cacheService.renoteMutingsCache.fetch(me.id),
]);
let timeline: MiNote[] = []; let timeline: MiNote[] = [];
@ -99,22 +106,17 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
// ミュート等考慮 // ミュート等考慮
timeline = timeline.filter(note => { timeline = timeline.filter(note => {
// TODO: インスタンスミュートの考慮 // TODO: インスタンスミュートの考慮
// TODO: リノートミュートの考慮
if (note.userId === me.id) { if (note.userId === me.id) {
return true; return true;
} }
if (note.renote) { if (isUserRelated(note, userIdsWhoMeMuting)) return false;
if (mutings.has(note.renote.userId)) return false; if (note.renoteId) {
if (note.text == null && note.fileIds.length === 0 && !note.hasPoll) {
if (isUserRelated(note, userIdsWhoMeMutingRenotes)) return false;
if (ps.withRenotes === false) return false;
} }
if (note.reply) {
if (mutings.has(note.reply.userId)) return false;
}
if (ps.withRenotes === false) {
if (note.renoteId && note.text == null && note.fileIds.length === 0 && !note.hasPoll) return false;
} }
return true; return true;

View File

@ -14,6 +14,7 @@ import ActiveUsersChart from '@/core/chart/charts/active-users.js';
import { DI } from '@/di-symbols.js'; import { DI } from '@/di-symbols.js';
import { CacheService } from '@/core/CacheService.js'; import { CacheService } from '@/core/CacheService.js';
import { IdService } from '@/core/IdService.js'; import { IdService } from '@/core/IdService.js';
import { isUserRelated } from '@/misc/is-user-related.js';
import { ApiError } from '../../error.js'; import { ApiError } from '../../error.js';
export const meta = { export const meta = {
@ -90,7 +91,13 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
throw new ApiError(meta.errors.noSuchList); throw new ApiError(meta.errors.noSuchList);
} }
const mutings = await this.cacheService.userMutingsCache.fetch(me.id); const [
userIdsWhoMeMuting,
userIdsWhoMeMutingRenotes,
] = await Promise.all([
this.cacheService.userMutingsCache.fetch(me.id),
this.cacheService.renoteMutingsCache.fetch(me.id),
]);
let timeline: MiNote[] = []; let timeline: MiNote[] = [];
@ -125,22 +132,13 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
// ミュート等考慮 // ミュート等考慮
timeline = timeline.filter(note => { timeline = timeline.filter(note => {
// TODO: インスタンスミュートの考慮 // TODO: インスタンスミュートの考慮
// TODO: リノートミュートの考慮
if (note.userId === me.id) { if (isUserRelated(note, userIdsWhoMeMuting)) return false;
return true; if (note.renoteId) {
if (note.text == null && note.fileIds.length === 0 && !note.hasPoll) {
if (isUserRelated(note, userIdsWhoMeMutingRenotes)) return false;
if (ps.withRenotes === false) return false;
} }
if (note.renote) {
if (mutings.has(note.renote.userId)) return false;
}
if (note.reply) {
if (mutings.has(note.reply.userId)) return false;
}
if (ps.withRenotes === false) {
if (note.renoteId && note.text == null && note.fileIds.length === 0 && !note.hasPoll) return false;
} }
return true; return true;