From d535ec21a27529709a9b11751c829527ef1c49b4 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 2 May 2023 09:36:40 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=E3=83=81=E3=83=A3=E3=83=B3=E3=83=8D?= =?UTF-8?q?=E3=83=AB=E3=81=AB=E8=89=B2=E3=82=92=E8=A8=AD=E5=AE=9A=E3=81=A7?= =?UTF-8?q?=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + .../migration/1682985520254-channelColor.js | 11 +++++++++ .../src/core/entities/ChannelEntityService.ts | 1 + .../src/core/entities/NoteEntityService.ts | 1 + .../backend/src/models/entities/Channel.ts | 6 +++++ .../backend/src/models/json-schema/channel.ts | 4 ++++ .../server/api/endpoints/channels/create.ts | 2 ++ .../server/api/endpoints/channels/update.ts | 2 ++ .../frontend/src/components/MkColorInput.vue | 2 +- packages/frontend/src/components/MkNote.vue | 24 +++++++++++++++++++ .../frontend/src/pages/channel-editor.vue | 8 +++++++ 11 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 packages/backend/migration/1682985520254-channelColor.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 43882432d6..82f848121f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ (デスクトップ表示ではusernameの右側のボタンからも追加可能) - アカウントの引っ越し(フォロワー引き継ぎ)に対応 * 一度引っ越したアカウントは利用に制限がかかります +- チャンネルに色を設定できるようになりました。各ノートに設定した色のインジケーターが表示されます。 - ロールタイムラインをロールごとに表示するかどうかの選択できるようになりました。 * デフォルトがオフになるので、ロールタイムラインを表示する場合はオンにしてください。 - カスタム絵文字のライセンスを複数でセットできるようになりました。 diff --git a/packages/backend/migration/1682985520254-channelColor.js b/packages/backend/migration/1682985520254-channelColor.js new file mode 100644 index 0000000000..294b7372b2 --- /dev/null +++ b/packages/backend/migration/1682985520254-channelColor.js @@ -0,0 +1,11 @@ +export class ChannelColor1682985520254 { + name = 'ChannelColor1682985520254' + + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "channel" ADD "color" character varying(16) NOT NULL DEFAULT '#86b300'`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "channel" DROP COLUMN "color"`); + } +} diff --git a/packages/backend/src/core/entities/ChannelEntityService.ts b/packages/backend/src/core/entities/ChannelEntityService.ts index 987002606f..05eb836580 100644 --- a/packages/backend/src/core/entities/ChannelEntityService.ts +++ b/packages/backend/src/core/entities/ChannelEntityService.ts @@ -74,6 +74,7 @@ export class ChannelEntityService { userId: channel.userId, bannerUrl: banner ? this.driveFileEntityService.getPublicUrl(banner) : null, pinnedNoteIds: channel.pinnedNoteIds, + color: channel.color, usersCount: channel.usersCount, notesCount: channel.notesCount, diff --git a/packages/backend/src/core/entities/NoteEntityService.ts b/packages/backend/src/core/entities/NoteEntityService.ts index 26debd6adc..32269a4101 100644 --- a/packages/backend/src/core/entities/NoteEntityService.ts +++ b/packages/backend/src/core/entities/NoteEntityService.ts @@ -335,6 +335,7 @@ export class NoteEntityService implements OnModuleInit { channel: channel ? { id: channel.id, name: channel.name, + color: channel.color, } : undefined, mentions: note.mentions.length > 0 ? note.mentions : undefined, uri: note.uri ?? undefined, diff --git a/packages/backend/src/models/entities/Channel.ts b/packages/backend/src/models/entities/Channel.ts index 2d346fdf9d..ebbfc439ad 100644 --- a/packages/backend/src/models/entities/Channel.ts +++ b/packages/backend/src/models/entities/Channel.ts @@ -64,6 +64,12 @@ export class Channel { }) public pinnedNoteIds: string[]; + @Column('varchar', { + length: 16, + default: '#86b300', + }) + public color: string; + @Index() @Column('integer', { default: 0, diff --git a/packages/backend/src/models/json-schema/channel.ts b/packages/backend/src/models/json-schema/channel.ts index 745b39a6ba..cb42c782b1 100644 --- a/packages/backend/src/models/json-schema/channel.ts +++ b/packages/backend/src/models/json-schema/channel.ts @@ -59,5 +59,9 @@ export const packedChannelSchema = { format: 'id', }, }, + color: { + type: 'string', + optional: false, nullable: false, + }, }, } as const; diff --git a/packages/backend/src/server/api/endpoints/channels/create.ts b/packages/backend/src/server/api/endpoints/channels/create.ts index 6294b08fa0..69e2f2504c 100644 --- a/packages/backend/src/server/api/endpoints/channels/create.ts +++ b/packages/backend/src/server/api/endpoints/channels/create.ts @@ -43,6 +43,7 @@ export const paramDef = { name: { type: 'string', minLength: 1, maxLength: 128 }, description: { type: 'string', nullable: true, minLength: 1, maxLength: 2048 }, bannerId: { type: 'string', format: 'misskey:id', nullable: true }, + color: { type: 'string', minLength: 1, maxLength: 16 }, }, required: ['name'], } as const; @@ -80,6 +81,7 @@ export default class extends Endpoint { name: ps.name, description: ps.description ?? null, bannerId: banner ? banner.id : null, + ...(ps.color !== undefined ? { color: ps.color } : {}), } as Channel).then(x => this.channelsRepository.findOneByOrFail(x.identifiers[0])); return await this.channelEntityService.pack(channel, me); diff --git a/packages/backend/src/server/api/endpoints/channels/update.ts b/packages/backend/src/server/api/endpoints/channels/update.ts index 084b3f919e..a4e38d429d 100644 --- a/packages/backend/src/server/api/endpoints/channels/update.ts +++ b/packages/backend/src/server/api/endpoints/channels/update.ts @@ -53,6 +53,7 @@ export const paramDef = { type: 'string', format: 'misskey:id', }, }, + color: { type: 'string', minLength: 1, maxLength: 16 }, }, required: ['channelId'], } as const; @@ -104,6 +105,7 @@ export default class extends Endpoint { ...(ps.name !== undefined ? { name: ps.name } : {}), ...(ps.description !== undefined ? { description: ps.description } : {}), ...(ps.pinnedNoteIds !== undefined ? { pinnedNoteIds: ps.pinnedNoteIds } : {}), + ...(ps.color !== undefined ? { color: ps.color } : {}), ...(banner ? { bannerId: banner.id } : {}), }); diff --git a/packages/frontend/src/components/MkColorInput.vue b/packages/frontend/src/components/MkColorInput.vue index a96e1edf7a..2471aa958d 100644 --- a/packages/frontend/src/components/MkColorInput.vue +++ b/packages/frontend/src/components/MkColorInput.vue @@ -1,7 +1,7 @@