Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance: ロール別お知らせに一致したロール名を表示するように #54

Merged
merged 3 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
- アバターデコレーションを登録したユーザーがアカウントを消去しても継続して使用ができるように
- アバターデコレーションをmisskeyUI上から登録できるように https://github.com/team-shahu/misskey/pull/12
- TL上のサーバー情報をアイコン表示に切り替えられるように https://github.com/team-shahu/misskey/pull/13 https://github.com/team-shahu/misskey/pull/24
- 特定のロールにのみお知らせを発行する機能 https://github.com/team-shahu/misskey/pull/18
- 特定のロールにのみお知らせを発行する機能 https://github.com/team-shahu/misskey/pull/18 https://github.com/team-shahu/misskey/pull/54
- リアクションした人一覧がブロック・ミュートを考慮するようにする設定 https://github.com/team-shahu/misskey/pull/23 https://github.com/team-shahu/misskey/pull/27
- 誰がリアクションをしたのかを非表示にできる機能 https://github.com/hideki0403/kakurega.app/commit/65d85bb4fe724dc0737f1ac7958bc13c96cc926d
- 誰がリアクションをしたのかを非表示にできる機能 https://github.com/team-shahu/misskey/pull/35 (https://github.com/team-shahu/misskey/commit/5b2923c8127336d7fd2ee39c76d16f8a30d1b9e1)
Expand Down
15 changes: 14 additions & 1 deletion packages/backend/src/core/entities/AnnouncementEntityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@

import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { AnnouncementsRepository, AnnouncementReadsRepository, MiAnnouncement, MiUser } from '@/models/_.js';
import type { AnnouncementsRepository, AnnouncementReadsRepository, AnnouncementRolesRepository, MiAnnouncement, MiUser } from '@/models/_.js';
import type { Packed } from '@/misc/json-schema.js';
import { bindThis } from '@/decorators.js';
import { IdService } from '@/core/IdService.js';
import { RoleEntityService } from './RoleEntityService.js';

@Injectable()
export class AnnouncementEntityService {
Expand All @@ -19,7 +20,11 @@ export class AnnouncementEntityService {
@Inject(DI.announcementReadsRepository)
private announcementReadsRepository: AnnouncementReadsRepository,

@Inject(DI.announcementRolesRepository)
private announcementRolesRepository: AnnouncementRolesRepository,

private idService: IdService,
private roleEntityService: RoleEntityService,
) {
}

Expand All @@ -43,6 +48,13 @@ export class AnnouncementEntityService {
.then((count: number) => count > 0);
}

// ロール名を取得
const roles = announcement.isRoleSpecified ? await this.announcementRolesRepository.findBy({ announcementId: announcement.id }) : [];
const roleNames = await Promise.all(roles.map(async role => {
const roleEntity = await this.roleEntityService.pack(role.roleId);
return roleEntity.name;
}));

return {
id: announcement.id,
createdAt: this.idService.parse(announcement.id).date.toISOString(),
Expand All @@ -57,6 +69,7 @@ export class AnnouncementEntityService {
needConfirmationToRead: announcement.needConfirmationToRead,
silence: announcement.silence,
isRead: announcement.isRead !== null ? announcement.isRead : undefined,
roleNames: roleNames,
};
}

Expand Down
8 changes: 8 additions & 0 deletions packages/backend/src/models/json-schema/announcement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ export const packedAnnouncementSchema = {
type: 'boolean',
optional: false, nullable: false,
},
roleNames: {
type: 'array',
items: {
type: 'string',
},
optional: false,
nullable: false,
},
isRead: {
type: 'boolean',
optional: true, nullable: false,
Expand Down
11 changes: 9 additions & 2 deletions packages/frontend/src/pages/announcements.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkPagination ref="paginationEl" :key="tab" v-slot="{items}" :pagination="tab === 'current' ? paginationCurrent : paginationPast" class="_gaps">
<section v-for="announcement in items" :key="announcement.id" class="_panel" :class="$style.announcement">
<div v-if="announcement.forYou" :class="$style.forYou"><i class="ti ti-pin"></i> {{ i18n.ts.forYou }}</div>
<div v-if="announcement.forYourRoles" :class="$style.forYou"><i class="ti ti-pin"></i> {{ i18n.ts.forYourRoles }}</div>
<div v-if="announcement.forYourRoles" :class="$style.forYou">
<i class="ti ti-pin"></i> {{ i18n.ts.forYourRoles }}: <span :class="$style.roleNames">{{ announcement.roleNames.join(', ') }}</span>
</div>
<div :class="$style.header">
<span v-if="$i && !announcement.silence && !announcement.isRead" style="margin-right: 0.5em;">🆕</span>
<span style="margin-right: 0.5em;">
Expand Down Expand Up @@ -129,7 +131,12 @@ definePageMetadata(() => ({
line-height: 24px;
font-size: 90%;
white-space: pre;
color: #d28a3f;
color: var(--MI_THEME-warn);
}

.roleNames {
font-weight: bold;
color: var(--MI_THEME-accent);
}

.header {
Expand Down
13 changes: 9 additions & 4 deletions packages/misskey-js/src/autogen/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4118,6 +4118,7 @@ export type components = {
silence: boolean;
forYou: boolean;
forYourRoles: boolean;
roleNames: string[];
isRead?: boolean;
};
App: {
Expand Down Expand Up @@ -16299,8 +16300,8 @@ export type operations = {
* @enum {string|null}
*/
type: 'follow' | 'unFollow' | 'wasFollow' | 'wasUnFollow' | 'blocked' | 'unBlocked' | 'wasBlocked' | 'wasUnBlocked';
fromUser: components['schemas']['UserDetailedNotMe'];
toUser: components['schemas']['UserDetailedNotMe'];
fromUser: Record<string, never>;
toUser: Record<string, never>;
/** Format: date-time */
timestamp: string;
})[];
Expand Down Expand Up @@ -16388,8 +16389,8 @@ export type operations = {
* @enum {string|null}
*/
type: 'sent' | 'received' | 'approved' | 'rejected' | 'wasApproved' | 'wasRejected' | 'wasBlocked' | 'wasUnBlocked';
fromUser: components['schemas']['UserDetailedNotMe'];
toUser: components['schemas']['UserDetailedNotMe'];
fromUser: Record<string, never>;
toUser: Record<string, never>;
/** Format: date-time */
timestamp: string;
})[];
Expand Down Expand Up @@ -22910,6 +22911,10 @@ export type operations = {
scheduleNote: {
scheduledAt?: number;
};
scheduledDelete?: ({
deleteAt?: number | null;
deleteAfter?: number | null;
}) | null;
};
};
};
Expand Down
Loading