mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-25 00:49:17 +09:00
wip
This commit is contained in:
parent
06cfe618bb
commit
3dd3c69303
@ -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 (note.reply) {
|
if (ps.withRenotes === false) return false;
|
||||||
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;
|
||||||
|
@ -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 (note.renote) {
|
if (ps.withRenotes === false) return false;
|
||||||
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;
|
||||||
|
Loading…
Reference in New Issue
Block a user