mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-27 02:03:09 +02:00
fix: Hide reactions of all remote users / feat: moderators can see reactions of all users (#13128)
* fix: Hide reactions of all remote users https://github.com/misskey-dev/misskey/issues/12964 * feat: Moderators can see reactions of all users https://github.com/misskey-dev/misskey/issues/13127 * modify CHANGELOG.md * fix iAmModerator
This commit is contained in:
parent
ada2c69c7d
commit
b0a38c0cae
4 changed files with 26 additions and 5 deletions
|
@ -21,6 +21,9 @@
|
||||||
- Feat: [mCaptcha](https://github.com/mCaptcha/mCaptcha)のサポートを追加
|
- Feat: [mCaptcha](https://github.com/mCaptcha/mCaptcha)のサポートを追加
|
||||||
- Fix: リストライムラインの「リノートを表示」が正しく機能しない問題を修正
|
- Fix: リストライムラインの「リノートを表示」が正しく機能しない問題を修正
|
||||||
- Feat: Add support for TrueMail
|
- Feat: Add support for TrueMail
|
||||||
|
- Fix: リモートユーザーのリアクション一覧がすべて見えてしまうのを修正
|
||||||
|
* すべてのリモートユーザーのリアクション一覧を見えないようにします
|
||||||
|
- Enhance: モデレーターはすべてのユーザーのリアクション一覧を見られるように
|
||||||
|
|
||||||
### Client
|
### Client
|
||||||
- Feat: 新しいゲームを追加
|
- Feat: 新しいゲームを追加
|
||||||
|
|
|
@ -409,7 +409,7 @@ export class UserEntityService implements OnModuleInit {
|
||||||
}),
|
}),
|
||||||
pinnedPageId: profile!.pinnedPageId,
|
pinnedPageId: profile!.pinnedPageId,
|
||||||
pinnedPage: profile!.pinnedPageId ? this.pageEntityService.pack(profile!.pinnedPageId, me) : null,
|
pinnedPage: profile!.pinnedPageId ? this.pageEntityService.pack(profile!.pinnedPageId, me) : null,
|
||||||
publicReactions: profile!.publicReactions,
|
publicReactions: this.isLocalUser(user) ? profile!.publicReactions : false, // https://github.com/misskey-dev/misskey/issues/12964
|
||||||
followersVisibility: profile!.followersVisibility,
|
followersVisibility: profile!.followersVisibility,
|
||||||
followingVisibility: profile!.followingVisibility,
|
followingVisibility: profile!.followingVisibility,
|
||||||
twoFactorEnabled: profile!.twoFactorEnabled,
|
twoFactorEnabled: profile!.twoFactorEnabled,
|
||||||
|
|
|
@ -9,6 +9,9 @@ import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import { QueryService } from '@/core/QueryService.js';
|
import { QueryService } from '@/core/QueryService.js';
|
||||||
import { NoteReactionEntityService } from '@/core/entities/NoteReactionEntityService.js';
|
import { NoteReactionEntityService } from '@/core/entities/NoteReactionEntityService.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
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 { ApiError } from '../../error.js';
|
import { ApiError } from '../../error.js';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
|
@ -34,6 +37,11 @@ export const meta = {
|
||||||
code: 'REACTIONS_NOT_PUBLIC',
|
code: 'REACTIONS_NOT_PUBLIC',
|
||||||
id: '673a7dd2-6924-1093-e0c0-e68456ceae5c',
|
id: '673a7dd2-6924-1093-e0c0-e68456ceae5c',
|
||||||
},
|
},
|
||||||
|
isRemoteUser: {
|
||||||
|
message: 'Currently unavailable to display reactions of remote users. See https://github.com/misskey-dev/misskey/issues/12964',
|
||||||
|
code: 'IS_REMOTE_USER',
|
||||||
|
id: '6b95fa98-8cf9-2350-e284-f0ffdb54a805',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
@ -59,14 +67,24 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
@Inject(DI.noteReactionsRepository)
|
@Inject(DI.noteReactionsRepository)
|
||||||
private noteReactionsRepository: NoteReactionsRepository,
|
private noteReactionsRepository: NoteReactionsRepository,
|
||||||
|
|
||||||
|
private cacheService: CacheService,
|
||||||
|
private userEntityService: UserEntityService,
|
||||||
private noteReactionEntityService: NoteReactionEntityService,
|
private noteReactionEntityService: NoteReactionEntityService,
|
||||||
private queryService: QueryService,
|
private queryService: QueryService,
|
||||||
|
private roleService: RoleService,
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps, me) => {
|
super(meta, paramDef, async (ps, me) => {
|
||||||
const profile = await this.userProfilesRepository.findOneByOrFail({ userId: ps.userId });
|
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);
|
||||||
|
if (this.userEntityService.isRemoteUser(user)) {
|
||||||
|
throw new ApiError(meta.errors.isRemoteUser);
|
||||||
|
}
|
||||||
|
|
||||||
if ((me == null || me.id !== ps.userId) && !profile.publicReactions) {
|
const profile = await this.userProfilesRepository.findOneByOrFail({ userId: ps.userId });
|
||||||
throw new ApiError(meta.errors.reactionsNotPublic);
|
if ((me == null || me.id !== ps.userId) && !profile.publicReactions) {
|
||||||
|
throw new ApiError(meta.errors.reactionsNotPublic);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const query = this.queryService.makePaginationQuery(this.noteReactionsRepository.createQueryBuilder('reaction'),
|
const query = this.queryService.makePaginationQuery(this.noteReactionsRepository.createQueryBuilder('reaction'),
|
||||||
|
|
|
@ -96,7 +96,7 @@ const headerTabs = computed(() => user.value ? [{
|
||||||
key: 'achievements',
|
key: 'achievements',
|
||||||
title: i18n.ts.achievements,
|
title: i18n.ts.achievements,
|
||||||
icon: 'ti ti-medal',
|
icon: 'ti ti-medal',
|
||||||
}] : []), ...($i && ($i.id === user.value.id)) || user.value.publicReactions ? [{
|
}] : []), ...($i && ($i.id === user.value.id || $i.isAdmin || $i.isModerator)) || user.value.publicReactions ? [{
|
||||||
key: 'reactions',
|
key: 'reactions',
|
||||||
title: i18n.ts.reaction,
|
title: i18n.ts.reaction,
|
||||||
icon: 'ti ti-mood-happy',
|
icon: 'ti ti-mood-happy',
|
||||||
|
|
Loading…
Reference in a new issue