summaryrefslogtreecommitdiff
path: root/packages/backend/src/server
diff options
context:
space:
mode:
authorSayamame-beans <61457993+Sayamame-beans@users.noreply.github.com>2024-07-14 20:24:29 +0900
committerGitHub <noreply@github.com>2024-07-14 20:24:29 +0900
commit4b9c60ad21704e7e75df830205cec2db7afc2baa (patch)
treefe76b30cf730a851b10118038903858ddb915349 /packages/backend/src/server
parentenhance(backend): configにsignToActivityPubGetの指定が無い場合true... (diff)
downloadsharkey-4b9c60ad21704e7e75df830205cec2db7afc2baa.tar.gz
sharkey-4b9c60ad21704e7e75df830205cec2db7afc2baa.tar.bz2
sharkey-4b9c60ad21704e7e75df830205cec2db7afc2baa.zip
fix(backend): ユーザーのリアクション一覧でミュート/ブロックが機能していなかった問題を修正 (#14100)
* fix: mute/block was not considered on users/reactions * docs(changelog): update changelog * chore: Apply suggestion from code review Co-authored-by: zyoshoka <107108195+zyoshoka@users.noreply.github.com> --------- Co-authored-by: zyoshoka <107108195+zyoshoka@users.noreply.github.com>
Diffstat (limited to 'packages/backend/src/server')
-rw-r--r--packages/backend/src/server/api/endpoints/users/reactions.ts19
1 files changed, 17 insertions, 2 deletions
diff --git a/packages/backend/src/server/api/endpoints/users/reactions.ts b/packages/backend/src/server/api/endpoints/users/reactions.ts
index aca883a052..7805ae3288 100644
--- a/packages/backend/src/server/api/endpoints/users/reactions.ts
+++ b/packages/backend/src/server/api/endpoints/users/reactions.ts
@@ -12,6 +12,7 @@ import { DI } from '@/di-symbols.js';
import { CacheService } from '@/core/CacheService.js';
import { UserEntityService } from '@/core/entities/UserEntityService.js';
import { RoleService } from '@/core/RoleService.js';
+import { isUserRelated } from '@/misc/is-user-related.js';
import { ApiError } from '../../error.js';
export const meta = {
@@ -74,6 +75,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
private roleService: RoleService,
) {
super(meta, paramDef, async (ps, me) => {
+ const userIdsWhoBlockingMe = me ? await this.cacheService.userBlockedCache.fetch(me.id) : new Set<string>();
const iAmModerator = me ? await this.roleService.isModerator(me) : false; // Moderators can see reactions of all users
if (!iAmModerator) {
const user = await this.cacheService.findUserById(ps.userId);
@@ -85,8 +87,15 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
if ((me == null || me.id !== ps.userId) && !profile.publicReactions) {
throw new ApiError(meta.errors.reactionsNotPublic);
}
+
+ // early return if me is blocked by requesting user
+ if (userIdsWhoBlockingMe.has(ps.userId)) {
+ return [];
+ }
}
+ const userIdsWhoMeMuting = me ? await this.cacheService.userMutingsCache.fetch(me.id) : new Set<string>();
+
const query = this.queryService.makePaginationQuery(this.noteReactionsRepository.createQueryBuilder('reaction'),
ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
.andWhere('reaction.userId = :userId', { userId: ps.userId })
@@ -94,9 +103,15 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
this.queryService.generateVisibilityQuery(query, me);
- const reactions = await query
+ const reactions = (await query
.limit(ps.limit)
- .getMany();
+ .getMany()).filter(reaction => {
+ if (reaction.note?.userId === ps.userId) return true; // we can see reactions to note of requesting user
+ if (me && isUserRelated(reaction.note, userIdsWhoBlockingMe)) return false;
+ if (me && isUserRelated(reaction.note, userIdsWhoMeMuting)) return false;
+
+ return true;
+ });
return await this.noteReactionEntityService.packMany(reactions, me, { withNote: true });
});