summaryrefslogtreecommitdiff
path: root/packages/backend/src/core/NoteCreateService.ts
diff options
context:
space:
mode:
authorMarie <marie@kaifa.ch>2024-01-26 01:24:26 +0100
committerMarie <marie@kaifa.ch>2024-01-26 01:24:26 +0100
commit6c6ccdc1e04f02da1d58eb9e4b5ade185b164dba (patch)
tree57f8b5a843542ecbdb0b4c867acb0fe6313b95dd /packages/backend/src/core/NoteCreateService.ts
parentfix: reactions being shown on muted/blocked users (diff)
downloadsharkey-6c6ccdc1e04f02da1d58eb9e4b5ade185b164dba.tar.gz
sharkey-6c6ccdc1e04f02da1d58eb9e4b5ade185b164dba.tar.bz2
sharkey-6c6ccdc1e04f02da1d58eb9e4b5ade185b164dba.zip
fix: properly mute notifications when mentioned by muted users
Closes #339
Diffstat (limited to 'packages/backend/src/core/NoteCreateService.ts')
-rw-r--r--packages/backend/src/core/NoteCreateService.ts33
1 files changed, 30 insertions, 3 deletions
diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts
index f03316744d..419e58ec62 100644
--- a/packages/backend/src/core/NoteCreateService.ts
+++ b/packages/backend/src/core/NoteCreateService.ts
@@ -57,8 +57,10 @@ import { FeaturedService } from '@/core/FeaturedService.js';
import { FanoutTimelineService } from '@/core/FanoutTimelineService.js';
import { UtilityService } from '@/core/UtilityService.js';
import { UserBlockingService } from '@/core/UserBlockingService.js';
+import { CacheService } from '@/core/CacheService.js';
import { isReply } from '@/misc/is-reply.js';
import { trackPromise } from '@/misc/promise-tracker.js';
+import { isUserRelated } from '@/misc/is-user-related.js';
type NotificationType = 'reply' | 'renote' | 'quote' | 'mention';
@@ -217,6 +219,7 @@ export class NoteCreateService implements OnApplicationShutdown {
private instanceChart: InstanceChart,
private utilityService: UtilityService,
private userBlockingService: UserBlockingService,
+ private cacheService: CacheService,
) { }
@bindThis
@@ -796,7 +799,15 @@ export class NoteCreateService implements OnApplicationShutdown {
},
});
- if (!isThreadMuted) {
+ const [
+ userIdsWhoMeMuting,
+ ] = data.reply.userId ? await Promise.all([
+ this.cacheService.userMutingsCache.fetch(data.reply.userId),
+ ]) : [new Set<string>()];
+
+ const muted = isUserRelated(note, userIdsWhoMeMuting);
+
+ if (!isThreadMuted || !muted) {
nm.push(data.reply.userId, 'reply');
this.globalEventService.publishMainStream(data.reply.userId, 'reply', noteObj);
@@ -823,7 +834,15 @@ export class NoteCreateService implements OnApplicationShutdown {
},
});
- if (!isThreadMuted) {
+ const [
+ userIdsWhoMeMuting,
+ ] = data.renote.userId ? await Promise.all([
+ this.cacheService.userMutingsCache.fetch(data.renote.userId),
+ ]) : [new Set<string>()];
+
+ const muted = isUserRelated(note, userIdsWhoMeMuting);
+
+ if (!isThreadMuted || !muted) {
nm.push(data.renote.userId, type);
}
}
@@ -1042,7 +1061,15 @@ export class NoteCreateService implements OnApplicationShutdown {
},
});
- if (isThreadMuted) {
+ const [
+ userIdsWhoMeMuting,
+ ] = u.id ? await Promise.all([
+ this.cacheService.userMutingsCache.fetch(u.id),
+ ]) : [new Set<string>()];
+
+ const muted = isUserRelated(note, userIdsWhoMeMuting);
+
+ if (isThreadMuted || muted) {
continue;
}