spec(User): モデレーターは非公開ロールを確認できるように (MisskeyIO#384)

This commit is contained in:
まっちゃとーにゅ
2024-01-26 00:10:24 +09:00
committed by GitHub
parent 44b9dfd494
commit 0b6e22b8d9
7 changed files with 41 additions and 18 deletions

View File

@@ -343,9 +343,9 @@ export class UserEntityService implements OnModuleInit {
(profile.followersVisibility === 'followers') && (relation && relation.isFollowing) ? user.followersCount :
null;
const isModerator = isMe && opts.detail ? this.roleService.isModerator(user) : null;
const isAdmin = isMe && opts.detail ? this.roleService.isAdministrator(user) : null;
const policies = opts.detail ? await this.roleService.getUserPolicies(user.id) : null;
const isModerator = (isMe || iAmModerator) && opts.detail ? this.roleService.isModerator(user) : null;
const isAdmin = (isMe || iAmModerator) && opts.detail ? this.roleService.isAdministrator(user) : null;
const unreadAnnouncements = isMe && opts.detail ? await this.announcementService.getUnreadAnnouncements(user) : null;
const notificationsInfo = isMe && opts.detail ? await this.getNotificationsInfo(user.id) : null;
@@ -426,16 +426,20 @@ export class UserEntityService implements OnModuleInit {
userId: user.id,
}).then(result => result >= 1)
: false,
roles: this.roleService.getUserRoles(user.id).then(roles => roles.filter(role => role.isPublic).sort((a, b) => b.displayOrder - a.displayOrder).map(role => ({
id: role.id,
name: role.name,
color: role.color,
iconUrl: role.iconUrl,
description: role.description,
isModerator: role.isModerator,
isAdministrator: role.isAdministrator,
displayOrder: role.displayOrder,
}))),
roles: this.roleService.getUserRoles(user.id).then(roles => roles
.filter(role => role.isPublic || iAmModerator)
.sort((a, b) => b.displayOrder - a.displayOrder)
.map(role => ({
id: role.id,
name: role.name,
color: role.color,
iconUrl: role.iconUrl,
description: role.description,
isModerator: role.isModerator,
isAdministrator: role.isAdministrator,
displayOrder: role.displayOrder,
}))
),
memo: meId == null ? null : await this.userMemosRepository.findOneBy({
userId: meId,
targetUserId: user.id,
@@ -443,7 +447,7 @@ export class UserEntityService implements OnModuleInit {
moderationNote: iAmModerator ? (profile!.moderationNote ?? '') : undefined,
} : {}),
...(opts.detail && isMe ? {
...(opts.detail && (isMe || iAmModerator) ? {
avatarId: user.avatarId,
bannerId: user.bannerId,
isModerator: isModerator,
@@ -468,7 +472,7 @@ export class UserEntityService implements OnModuleInit {
where: { userId: user.id, isMentioned: true },
take: 1,
}).then(count => count > 0),
hasUnreadAnnouncement: unreadAnnouncements!.length > 0,
hasUnreadAnnouncement: (unreadAnnouncements?.length ?? 0) > 0,
unreadAnnouncements,
hasUnreadAntenna: this.getHasUnreadAntenna(user.id),
hasUnreadChannel: false, // 後方互換性のため

View File

@@ -7,9 +7,9 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkSpacer :contentMax="narrow ? 800 : 1100">
<div ref="rootEl" class="ftskorzw" :class="{ wide: !narrow }" style="container-type: inline-size;">
<div class="main _gaps">
<!-- TODO -->
<!-- <div class="punished" v-if="user.isSuspended"><i class="ti ti-alert-triangle" style="margin-right: 8px;"></i> {{ i18n.ts.userSuspended }}</div> -->
<!-- <div class="punished" v-if="user.isSilenced"><i class="ti ti-alert-triangle" style="margin-right: 8px;"></i> {{ i18n.ts.userSilenced }}</div> -->
<div v-if="user.isSuspended" class="punished"><i class="ti ti-alert-triangle" style="margin-right: 8px;"></i> {{ i18n.ts.userSuspended }}</div>
<div v-if="user.isLimited" class="punished"><i class="ti ti-alert-triangle" style="margin-right: 8px;"></i> {{ i18n.ts.userLimited }}</div>
<div v-if="user.isSilenced" class="punished"><i class="ti ti-alert-triangle" style="margin-right: 8px;"></i> {{ i18n.ts.userSilenced }}</div>
<div class="profile _gaps">
<MkAccountMoved v-if="user.movedTo" :movedTo="user.movedTo"/>
@@ -312,6 +312,10 @@ onUnmounted(() => {
> .punished {
font-size: 0.8em;
padding: 16px;
background: var(--infoWarnBg);
color: var(--infoWarnFg);
border-radius: var(--radius);
overflow: clip;
}
> .profile {

View File

@@ -13,6 +13,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<span :class="$style.userMInfoMetaSub"><span class="acct _monospace">@{{ acct(user) }}</span></span>
<span :class="$style.userMInfoMetaState">
<span v-if="suspended" :class="$style.suspended">Suspended</span>
<span v-if="limited" :class="$style.limited">Limited</span>
<span v-if="silenced" :class="$style.silenced">Silenced</span>
<span v-if="moderator" :class="$style.moderator">Moderator</span>
</span>
@@ -53,6 +54,7 @@ const props = defineProps<{
const moderator = computed(() => props.user.isModerator ?? false);
const silenced = computed(() => props.user.isSilenced ?? false);
const limited = computed(() => props.user.isLimited ?? false);
const suspended = computed(() => props.user.isSuspended ?? false);
</script>
@@ -103,6 +105,7 @@ const suspended = computed(() => props.user.isSuspended ?? false);
}
> .suspended,
> .limited,
> .silenced,
> .moderator {
display: inline-block;
@@ -117,6 +120,11 @@ const suspended = computed(() => props.user.isSuspended ?? false);
border-color: var(--error);
}
> .limited {
color: var(--error);
border-color: var(--error);
}
> .silenced {
color: var(--warn);
border-color: var(--warn);