mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-26 04:00:18 +01:00
perf(server): disable some antenna features to improve performance
This commit is contained in:
parent
ff19640171
commit
9320c1699a
3 changed files with 19 additions and 19 deletions
|
@ -1,17 +1,26 @@
|
|||
import { Antenna } from '@/models/entities/antenna.js';
|
||||
import { Note } from '@/models/entities/note.js';
|
||||
import { User } from '@/models/entities/user.js';
|
||||
import { UserListJoinings, UserGroupJoinings } from '@/models/index.js';
|
||||
import { UserListJoinings, UserGroupJoinings, Blockings } from '@/models/index.js';
|
||||
import { getFullApAccount } from './convert-host.js';
|
||||
import * as Acct from '@/misc/acct.js';
|
||||
import { Packed } from './schema.js';
|
||||
import { Cache } from './cache.js';
|
||||
|
||||
const blockingCache = new Cache<User['id'][]>(1000 * 60 * 5);
|
||||
|
||||
// NOTE: フォローしているユーザーのノート、リストのユーザーのノート、グループのユーザーのノート指定はパフォーマンス上の理由で無効になっている
|
||||
|
||||
/**
|
||||
* noteUserFollowers / antennaUserFollowing はどちらか一方が指定されていればよい
|
||||
*/
|
||||
export async function checkHitAntenna(antenna: Antenna, note: (Note | Packed<'Note'>), noteUser: { username: string; host: string | null; }, noteUserFollowers?: User['id'][], antennaUserFollowing?: User['id'][]): Promise<boolean> {
|
||||
export async function checkHitAntenna(antenna: Antenna, note: (Note | Packed<'Note'>), noteUser: { id: User['id']; username: string; host: string | null; }, noteUserFollowers?: User['id'][], antennaUserFollowing?: User['id'][]): Promise<boolean> {
|
||||
if (note.visibility === 'specified') return false;
|
||||
|
||||
// アンテナ作成者がノート作成者にブロックされていたらスキップ
|
||||
const blockings = await blockingCache.fetch(noteUser.id, () => Blockings.find({ blockerId: noteUser.id }).then(res => res.map(x => x.blockeeId)));
|
||||
if (blockings.some(blocking => blocking === antenna.userId)) return false;
|
||||
|
||||
if (note.visibility === 'followers') {
|
||||
if (noteUserFollowers && !noteUserFollowers.includes(antenna.userId)) return false;
|
||||
if (antennaUserFollowing && !antennaUserFollowing.includes(note.userId)) return false;
|
||||
|
|
|
@ -275,22 +275,13 @@ export default async (user: { id: User['id']; username: User['username']; host:
|
|||
});
|
||||
|
||||
// Antenna
|
||||
// TODO: キャッシュしたい
|
||||
Followings.createQueryBuilder('following')
|
||||
.andWhere(`following.followeeId = :userId`, { userId: note.userId })
|
||||
.getMany()
|
||||
.then(async followings => {
|
||||
const blockings = await Blockings.find({ blockerId: user.id });
|
||||
const followers = followings.map(f => f.followerId);
|
||||
for (const antenna of (await getAntennas())) {
|
||||
if (blockings.some(blocking => blocking.blockeeId === antenna.userId)) continue; // この処理は checkHitAntenna 内でやるようにしてもいいかも
|
||||
checkHitAntenna(antenna, note, user, followers).then(hit => {
|
||||
checkHitAntenna(antenna, note, user).then(hit => {
|
||||
if (hit) {
|
||||
addNoteToAntenna(antenna, note, user);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Channel
|
||||
if (note.channelId) {
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
<MkSelect v-model="src" class="_formBlock">
|
||||
<template #label>{{ $ts.antennaSource }}</template>
|
||||
<option value="all">{{ $ts._antennaSources.all }}</option>
|
||||
<option value="home">{{ $ts._antennaSources.homeTimeline }}</option>
|
||||
<!--<option value="home">{{ $ts._antennaSources.homeTimeline }}</option>-->
|
||||
<option value="users">{{ $ts._antennaSources.users }}</option>
|
||||
<option value="list">{{ $ts._antennaSources.userList }}</option>
|
||||
<option value="group">{{ $ts._antennaSources.userGroup }}</option>
|
||||
<!--<option value="list">{{ $ts._antennaSources.userList }}</option>-->
|
||||
<!--<option value="group">{{ $ts._antennaSources.userGroup }}</option>-->
|
||||
</MkSelect>
|
||||
<MkSelect v-if="src === 'list'" v-model="userListId" class="_formBlock">
|
||||
<template #label>{{ $ts.userList }}</template>
|
||||
|
|
Loading…
Reference in a new issue