fix(AntennaService): filter is not working
This commit is contained in:
parent
d4a1ed43f8
commit
c3dfbf1e33
@ -11,9 +11,11 @@ import type { MiUser } from '@/models/User.js';
|
|||||||
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
||||||
import * as Acct from '@/misc/acct.js';
|
import * as Acct from '@/misc/acct.js';
|
||||||
import type { Packed } from '@/misc/json-schema.js';
|
import type { Packed } from '@/misc/json-schema.js';
|
||||||
|
import { isUserRelated } from '@/misc/is-user-related.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import type { AntennasRepository, FollowingsRepository, UserListMembershipsRepository } from '@/models/_.js';
|
import type { AntennasRepository, FollowingsRepository, UserListMembershipsRepository } from '@/models/_.js';
|
||||||
import { UtilityService } from '@/core/UtilityService.js';
|
import { UtilityService } from '@/core/UtilityService.js';
|
||||||
|
import { CacheService } from '@/core/CacheService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import type { GlobalEvents } from '@/core/GlobalEventService.js';
|
import type { GlobalEvents } from '@/core/GlobalEventService.js';
|
||||||
import { FanoutTimelineService } from '@/core/FanoutTimelineService.js';
|
import { FanoutTimelineService } from '@/core/FanoutTimelineService.js';
|
||||||
@ -42,6 +44,7 @@ export class AntennaService implements OnApplicationShutdown {
|
|||||||
@Inject(DI.userListMembershipsRepository)
|
@Inject(DI.userListMembershipsRepository)
|
||||||
private userListMembershipsRepository: UserListMembershipsRepository,
|
private userListMembershipsRepository: UserListMembershipsRepository,
|
||||||
|
|
||||||
|
private cacheService: CacheService,
|
||||||
private userEntityService: UserEntityService,
|
private userEntityService: UserEntityService,
|
||||||
private utilityService: UtilityService,
|
private utilityService: UtilityService,
|
||||||
private globalEventService: GlobalEventService,
|
private globalEventService: GlobalEventService,
|
||||||
@ -126,14 +129,31 @@ export class AntennaService implements OnApplicationShutdown {
|
|||||||
// NOTE: フォローしているユーザーのノート、リストのユーザーのノート、グループのユーザーのノート指定はパフォーマンス上の理由で無効になっている
|
// NOTE: フォローしているユーザーのノート、リストのユーザーのノート、グループのユーザーのノート指定はパフォーマンス上の理由で無効になっている
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async checkHitAntenna(antenna: MiAntenna, note: (MiNote | Packed<'Note'>), noteUser: { id: MiUser['id']; username: string; host: string | null; isBot: boolean; }): Promise<boolean> {
|
private async filter(me: MiUser | null, note: (MiNote | Packed<'Note'>)): Promise<boolean> {
|
||||||
/* if (note.visibility === 'specified') return false;
|
const [
|
||||||
if (note.visibility === 'followers') {
|
userIdsWhoMeMuting,
|
||||||
if (antenna.userId === note.userId) return true;
|
userIdsWhoBlockingMe,
|
||||||
|
] = me ? await Promise.all([
|
||||||
|
this.cacheService.userMutingsCache.fetch(me.id),
|
||||||
|
this.cacheService.userBlockedCache.fetch(me.id),
|
||||||
|
]) : [new Set<string>(), new Set<string>()];
|
||||||
|
if (me && isUserRelated(note, userIdsWhoBlockingMe)) return false;
|
||||||
|
if (me && isUserRelated(note, userIdsWhoMeMuting)) return false;
|
||||||
|
if (['followers', 'specified'].includes(note.visibility)) {
|
||||||
|
if (!me) return false;
|
||||||
|
if (note.visibility === 'followers') {
|
||||||
|
const relationship = await this.userEntityService.getRelation(me.id, note.userId);
|
||||||
|
if (relationship.isFollowing) return true;
|
||||||
|
}
|
||||||
|
if (!note.visibleUserIds?.includes(me.id) && !note.mentions?.includes(me.id)) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
const relationship = await this.userEntityService.getRelation(antenna.userId, noteUser.id);
|
@bindThis
|
||||||
if (!relationship.isFollowing) return false;
|
public async checkHitAntenna(antenna: MiAntenna, note: (MiNote | Packed<'Note'>), noteUser: { id: MiUser['id']; username: string; host: string | null; isBot: boolean; }): Promise<boolean> {
|
||||||
} */
|
const result = await this.filter(antenna.user, note);
|
||||||
|
if (!result) return false;
|
||||||
|
|
||||||
if (antenna.excludeBots && noteUser.isBot) return false;
|
if (antenna.excludeBots && noteUser.isBot) return false;
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ import { QueryService } from '@/core/QueryService.js';
|
|||||||
import { IdService } from '@/core/IdService.js';
|
import { IdService } from '@/core/IdService.js';
|
||||||
import { UserEntityService } from './entities/UserEntityService.js';
|
import { UserEntityService } from './entities/UserEntityService.js';
|
||||||
import type { Index, MeiliSearch } from 'meilisearch';
|
import type { Index, MeiliSearch } from 'meilisearch';
|
||||||
import { nonMaxSuppressionV3Impl } from '@tensorflow/tfjs-core/dist/backends/non_max_suppression_impl.js';
|
// import { nonMaxSuppressionV3Impl } from '@tensorflow/tfjs-core/dist/backends/non_max_suppression_impl.js';
|
||||||
|
|
||||||
type K = string;
|
type K = string;
|
||||||
type V = string | number | boolean;
|
type V = string | number | boolean;
|
||||||
|
Loading…
Reference in New Issue
Block a user