summaryrefslogtreecommitdiff
path: root/packages/backend/src
diff options
context:
space:
mode:
authorzyoshoka <107108195+zyoshoka@users.noreply.github.com>2024-07-25 16:32:07 +0900
committerGitHub <noreply@github.com>2024-07-25 16:32:07 +0900
commitfc71bcc98e14f9c3c13ba74ade9245d64bd4b633 (patch)
tree7d86ea64e1ec2878f25c09c2ce3d289e41c02df0 /packages/backend/src
parentfix(frontend): 初期化時とroute変更時でkeyの決定方法が違うの... (diff)
downloadsharkey-fc71bcc98e14f9c3c13ba74ade9245d64bd4b633.tar.gz
sharkey-fc71bcc98e14f9c3c13ba74ade9245d64bd4b633.tar.bz2
sharkey-fc71bcc98e14f9c3c13ba74ade9245d64bd4b633.zip
fix(backend): avoid notifying to remote users on local (#13774)
* fix(backend): avoid notifying to remote users on local * Update CHANGELOG.md * refactor: check before calling method --------- Co-authored-by: かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
Diffstat (limited to 'packages/backend/src')
-rw-r--r--packages/backend/src/core/RoleService.ts5
-rw-r--r--packages/backend/src/core/UserFollowingService.ts6
-rw-r--r--packages/backend/src/queue/processors/EndedPollNotificationProcessorService.ts11
3 files changed, 15 insertions, 7 deletions
diff --git a/packages/backend/src/core/RoleService.ts b/packages/backend/src/core/RoleService.ts
index 94026fd503..7966774673 100644
--- a/packages/backend/src/core/RoleService.ts
+++ b/packages/backend/src/core/RoleService.ts
@@ -505,14 +505,15 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit {
this.globalEventService.publishInternalEvent('userRoleAssigned', created);
- if (role.isPublic) {
+ const user = await this.usersRepository.findOneByOrFail({ id: userId });
+
+ if (role.isPublic && user.host === null) {
this.notificationService.createNotification(userId, 'roleAssigned', {
roleId: roleId,
});
}
if (moderator) {
- const user = await this.usersRepository.findOneByOrFail({ id: userId });
this.moderationLogService.log(moderator, 'assignRole', {
roleId: roleId,
roleName: role.name,
diff --git a/packages/backend/src/core/UserFollowingService.ts b/packages/backend/src/core/UserFollowingService.ts
index 267a6a3f1b..6aab8fde70 100644
--- a/packages/backend/src/core/UserFollowingService.ts
+++ b/packages/backend/src/core/UserFollowingService.ts
@@ -279,8 +279,10 @@ export class UserFollowingService implements OnModuleInit {
});
// 通知を作成
- this.notificationService.createNotification(follower.id, 'followRequestAccepted', {
- }, followee.id);
+ if (follower.host === null) {
+ this.notificationService.createNotification(follower.id, 'followRequestAccepted', {
+ }, followee.id);
+ }
}
if (alreadyFollowed) return;
diff --git a/packages/backend/src/queue/processors/EndedPollNotificationProcessorService.ts b/packages/backend/src/queue/processors/EndedPollNotificationProcessorService.ts
index 29c1f27bb1..34180e5f2b 100644
--- a/packages/backend/src/queue/processors/EndedPollNotificationProcessorService.ts
+++ b/packages/backend/src/queue/processors/EndedPollNotificationProcessorService.ts
@@ -7,6 +7,7 @@ import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { PollVotesRepository, NotesRepository } from '@/models/_.js';
import type Logger from '@/logger.js';
+import { CacheService } from '@/core/CacheService.js';
import { NotificationService } from '@/core/NotificationService.js';
import { bindThis } from '@/decorators.js';
import { QueueLoggerService } from '../QueueLoggerService.js';
@@ -24,6 +25,7 @@ export class EndedPollNotificationProcessorService {
@Inject(DI.pollVotesRepository)
private pollVotesRepository: PollVotesRepository,
+ private cacheService: CacheService,
private notificationService: NotificationService,
private queueLoggerService: QueueLoggerService,
) {
@@ -47,9 +49,12 @@ export class EndedPollNotificationProcessorService {
const userIds = [...new Set([note.userId, ...votes.map(v => v.userId)])];
for (const userId of userIds) {
- this.notificationService.createNotification(userId, 'pollEnded', {
- noteId: note.id,
- });
+ const profile = await this.cacheService.userProfileCache.fetch(userId);
+ if (profile.userHost === null) {
+ this.notificationService.createNotification(userId, 'pollEnded', {
+ noteId: note.id,
+ });
+ }
}
}
}