mirror of
https://activitypub.software/TransFem-org/Sharkey.git
synced 2025-09-18 21:38:07 +00:00
fix note mutings not applying to websocket
This commit is contained in:
parent
bd22ae0d80
commit
d0bd12b410
2 changed files with 14 additions and 3 deletions
|
@ -46,6 +46,7 @@ export default class Connection {
|
|||
public userIdsWhoMeMutingRenotes: Set<string> = new Set();
|
||||
public userMutedInstances: Set<string> = new Set();
|
||||
public userMutedThreads: Set<string> = new Set();
|
||||
public userMutedNotes: Set<string> = new Set();
|
||||
public myRecentReactions: Map<string, string> = new Map();
|
||||
public myRecentRenotes: Set<string> = new Set();
|
||||
public myRecentFavorites: Set<string> = new Set();
|
||||
|
@ -84,7 +85,7 @@ export default class Connection {
|
|||
@bindThis
|
||||
public async fetch() {
|
||||
if (this.user == null) return;
|
||||
const [userProfile, following, followingChannels, userIdsWhoMeMuting, userIdsWhoBlockingMe, userIdsWhoMeMutingRenotes, threadMutings, myRecentReactions, myRecentFavorites, myRecentRenotes] = await Promise.all([
|
||||
const [userProfile, following, followingChannels, userIdsWhoMeMuting, userIdsWhoBlockingMe, userIdsWhoMeMutingRenotes, threadMutings, noteMutings, myRecentReactions, myRecentFavorites, myRecentRenotes] = await Promise.all([
|
||||
this.cacheService.userProfileCache.fetch(this.user.id),
|
||||
this.cacheService.userFollowingsCache.fetch(this.user.id),
|
||||
this.channelFollowingService.userFollowingChannelsCache.fetch(this.user.id),
|
||||
|
@ -92,6 +93,7 @@ export default class Connection {
|
|||
this.cacheService.userBlockedCache.fetch(this.user.id),
|
||||
this.cacheService.renoteMutingsCache.fetch(this.user.id),
|
||||
this.cacheService.threadMutingsCache.fetch(this.user.id),
|
||||
this.cacheService.noteMutingsCache.fetch(this.user.id),
|
||||
this.noteReactionsRepository.find({
|
||||
where: { userId: this.user.id },
|
||||
select: { noteId: true, reaction: true },
|
||||
|
@ -120,6 +122,7 @@ export default class Connection {
|
|||
this.userIdsWhoMeMutingRenotes = userIdsWhoMeMutingRenotes;
|
||||
this.userMutedInstances = new Set(userProfile.mutedInstances);
|
||||
this.userMutedThreads = threadMutings;
|
||||
this.userMutedNotes = noteMutings;
|
||||
this.myRecentReactions = new Map(myRecentReactions.map(r => [r.noteId, r.reaction]));
|
||||
this.myRecentFavorites = new Set(myRecentFavorites.map(f => f.noteId ));
|
||||
this.myRecentRenotes = new Set(myRecentRenotes.map(r => r.renoteId ));
|
||||
|
|
|
@ -78,6 +78,13 @@ export default abstract class Channel {
|
|||
return this.connection.userMutedThreads;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use cacheService.noteMutingsCache to avoid stale data
|
||||
*/
|
||||
protected get userMutedNotes() {
|
||||
return this.connection.userMutedNotes;
|
||||
}
|
||||
|
||||
protected get followingChannels() {
|
||||
return this.connection.followingChannels;
|
||||
}
|
||||
|
@ -134,6 +141,9 @@ export default abstract class Channel {
|
|||
// Muted thread
|
||||
if (this.userMutedThreads.has(note.threadId)) return true;
|
||||
|
||||
// Muted note
|
||||
if (this.userMutedNotes.has(note.id)) return true;
|
||||
|
||||
// If it's a boost (pure renote) then we need to check the target as well
|
||||
if (isPackedPureRenote(note) && note.renote && this.isNoteMutedOrBlocked(note.renote)) return true;
|
||||
|
||||
|
@ -144,8 +154,6 @@ export default abstract class Channel {
|
|||
if (!this.following.has(note.userId)) return true;
|
||||
}
|
||||
|
||||
// TODO muted threads
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue