Block improvements

It will now hide posts if a blocked user is mentioned, or if it's a reblog of a reply to a blocked user.
This commit is contained in:
jaina heartles 2024-12-05 21:55:11 -05:00
parent 08e3706df7
commit d111fe935b
4 changed files with 34 additions and 2 deletions

View file

@ -42,6 +42,7 @@ export default class Connection {
public followingChannels: Set<string> = new Set();
public userIdsWhoMeMuting: Set<string> = new Set();
public userIdsWhoBlockingMe: Set<string> = new Set();
public userIdsWhoMeBlocking: Set<string> = new Set();
public userIdsWhoMeMutingRenotes: Set<string> = new Set();
public userMutedInstances: Set<string> = new Set();
private fetchIntervalId: NodeJS.Timeout | null = null;
@ -72,12 +73,13 @@ export default class Connection {
@bindThis
public async fetch() {
if (this.user == null) return;
const [userProfile, following, followingChannels, userIdsWhoMeMuting, userIdsWhoBlockingMe, userIdsWhoMeMutingRenotes] = await Promise.all([
const [userProfile, following, followingChannels, userIdsWhoMeMuting, userIdsWhoBlockingMe, userIdsWhoMeBlocking, userIdsWhoMeMutingRenotes] = await Promise.all([
this.cacheService.userProfileCache.fetch(this.user.id),
this.cacheService.userFollowingsCache.fetch(this.user.id),
this.channelFollowingService.userFollowingChannelsCache.fetch(this.user.id),
this.cacheService.userMutingsCache.fetch(this.user.id),
this.cacheService.userBlockedCache.fetch(this.user.id),
this.cacheService.userBlockingCache.fetch(this.user.id),
this.cacheService.renoteMutingsCache.fetch(this.user.id),
]);
this.userProfile = userProfile;
@ -85,6 +87,7 @@ export default class Connection {
this.followingChannels = followingChannels;
this.userIdsWhoMeMuting = userIdsWhoMeMuting;
this.userIdsWhoBlockingMe = userIdsWhoBlockingMe;
this.userIdsWhoMeBlocking = userIdsWhoMeBlocking;
this.userIdsWhoMeMutingRenotes = userIdsWhoMeMutingRenotes;
this.userMutedInstances = new Set(userProfile.mutedInstances);
}
@ -253,6 +256,9 @@ export default class Connection {
if (this.userIdsWhoBlockingMe.has(noteUserId)) {
return;
}
if (this.userIdsWhoMeBlocking.has(noteUserId)) {
return;
}
}
}

View file

@ -47,6 +47,10 @@ export default abstract class Channel {
return this.connection.userIdsWhoBlockingMe;
}
protected get userIdsWhoMeBlocking() {
return this.connection.userIdsWhoMeBlocking;
}
protected get userMutedInstances() {
return this.connection.userMutedInstances;
}
@ -70,6 +74,7 @@ export default abstract class Channel {
if (isUserRelated(note, this.userIdsWhoMeMuting)) return true;
// 流れてきたNoteがブロックされているユーザーが関わる
if (isUserRelated(note, this.userIdsWhoBlockingMe)) return true;
if (isUserRelated(note, this.userIdsWhoMeBlocking)) return true;
// 流れてきたNoteがリートをミュートしてるユーザが行ったもの
if (isRenotePacked(note) && !isQuotePacked(note) && this.userIdsWhoMeMutingRenotes.has(note.user.id)) return true;