fix(filter): relation check
This commit is contained in:
parent
ba95b99abc
commit
92f7f90a5c
@ -132,15 +132,19 @@ export class AntennaService implements OnApplicationShutdown {
|
|||||||
private async filter(me: MiUser | null, note: (MiNote | Packed<'Note'>)): Promise<boolean> {
|
private async filter(me: MiUser | null, note: (MiNote | Packed<'Note'>)): Promise<boolean> {
|
||||||
const [
|
const [
|
||||||
userIdsWhoMeMuting,
|
userIdsWhoMeMuting,
|
||||||
|
userIdsWhoMeBlocking,
|
||||||
userIdsWhoBlockingMe,
|
userIdsWhoBlockingMe,
|
||||||
] = me ? await Promise.all([
|
] = me ? await Promise.all([
|
||||||
this.cacheService.userMutingsCache.fetch(me.id),
|
this.cacheService.userMutingsCache.fetch(me.id),
|
||||||
|
this.cacheService.userBlockingCache.fetch(me.id),
|
||||||
this.cacheService.userBlockedCache.fetch(me.id),
|
this.cacheService.userBlockedCache.fetch(me.id),
|
||||||
]) : [new Set<string>(), new Set<string>()];
|
]) : [new Set<string>(), new Set<string>(), new Set<string>()];
|
||||||
if (me && isUserRelated(note, userIdsWhoBlockingMe)) return false;
|
if (me && isUserRelated(note, userIdsWhoBlockingMe)) return false;
|
||||||
|
if (me && isUserRelated(note, userIdsWhoMeBlocking)) return false;
|
||||||
if (me && isUserRelated(note, userIdsWhoMeMuting)) return false;
|
if (me && isUserRelated(note, userIdsWhoMeMuting)) return false;
|
||||||
if (['followers', 'specified'].includes(note.visibility)) {
|
if (['followers', 'specified'].includes(note.visibility)) {
|
||||||
if (!me) return false;
|
if (me == null) return false;
|
||||||
|
if (me.id === note.userId) return true;
|
||||||
if (note.visibility === 'followers') {
|
if (note.visibility === 'followers') {
|
||||||
const relationship = await this.userEntityService.getRelation(me.id, note.userId);
|
const relationship = await this.userEntityService.getRelation(me.id, note.userId);
|
||||||
if (relationship.isFollowing) return true;
|
if (relationship.isFollowing) return true;
|
||||||
@ -153,7 +157,7 @@ export class AntennaService implements OnApplicationShutdown {
|
|||||||
@bindThis
|
@bindThis
|
||||||
public async checkHitAntenna(antenna: MiAntenna, note: (MiNote | Packed<'Note'>), noteUser: { id: MiUser['id']; username: string; host: string | null; isBot: boolean; }): Promise<boolean> {
|
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);
|
const result = await this.filter(antenna.user, note);
|
||||||
if (!result && antenna.userId !== note.userId) return false;
|
if (!result) return false;
|
||||||
|
|
||||||
if (antenna.excludeBots && noteUser.isBot) return false;
|
if (antenna.excludeBots && noteUser.isBot) return false;
|
||||||
|
|
||||||
|
@ -280,6 +280,7 @@ export class SearchService {
|
|||||||
if (me && isUserRelated(note, userIdsWhoMeMuting)) return false;
|
if (me && isUserRelated(note, userIdsWhoMeMuting)) return false;
|
||||||
if (['followers', 'specified'].includes(note.visibility)) {
|
if (['followers', 'specified'].includes(note.visibility)) {
|
||||||
if (me == null) return false;
|
if (me == null) return false;
|
||||||
|
if (me.id === note.userId) return true;
|
||||||
if (note.visibility === 'followers') {
|
if (note.visibility === 'followers') {
|
||||||
const relationship = await this.userEntityService.getRelation(me.id, note.userId);
|
const relationship = await this.userEntityService.getRelation(me.id, note.userId);
|
||||||
if (relationship.isFollowing) return true;
|
if (relationship.isFollowing) return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user