feat: sensitive channel (#11438)

* feat(backend): add isSensitive to Channel

* feat(backend): support isSensitive in channel endpoints

* feat(frontend/channel-editor): support isSensitive in create/edit channel page

* feat(frontend/channel): show sensitive indicator for sensitive channels

* docs(changelog): add チャンネルをセンシティブ指定できるようになりました

* chore: license header for each file

* chore: add isSensitive of channel to Note object
This commit is contained in:
anatawa12
2023-08-05 13:58:31 +09:00
committed by GitHub
parent 79966d33b5
commit c5b8766a18
12 changed files with 73 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
/*
* SPDX-FileCopyrightText: syuilo and other misskey contributors
* SPDX-License-Identifier: AGPL-3.0-only
*/
export class SensitiveChannel1690782653311 {
name = 'SensitiveChannel1690782653311'
async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "channel"
ADD "isSensitive" boolean NOT NULL DEFAULT false`);
}
async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "channel" DROP COLUMN "isSensitive"`);
}
}

View File

@@ -92,6 +92,7 @@ export class ChannelEntityService {
isArchived: channel.isArchived,
usersCount: channel.usersCount,
notesCount: channel.notesCount,
isSensitive: channel.isSensitive,
...(me ? {
isFollowing,

View File

@@ -333,6 +333,7 @@ export class NoteEntityService implements OnModuleInit {
id: channel.id,
name: channel.name,
color: channel.color,
isSensitive: channel.isSensitive,
} : undefined,
mentions: note.mentions.length > 0 ? note.mentions : undefined,
uri: note.uri ?? undefined,

View File

@@ -94,4 +94,9 @@ export class Channel {
comment: 'The count of users.',
})
public usersCount: number;
@Column('boolean', {
default: false,
})
public isSensitive: boolean;
}

View File

@@ -72,5 +72,9 @@ export const packedChannelSchema = {
type: 'string',
optional: false, nullable: false,
},
isSensitive: {
type: 'boolean',
optional: false, nullable: false,
},
},
} as const;

View File

@@ -139,6 +139,10 @@ export const packedNoteSchema = {
type: 'string',
optional: false, nullable: true,
},
isSensitive: {
type: 'boolean',
optional: true, nullable: false,
}
},
},
},

View File

@@ -49,6 +49,7 @@ export const paramDef = {
description: { type: 'string', nullable: true, minLength: 1, maxLength: 2048 },
bannerId: { type: 'string', format: 'misskey:id', nullable: true },
color: { type: 'string', minLength: 1, maxLength: 16 },
isSensitive: { type: 'boolean', nullable: true },
},
required: ['name'],
} as const;
@@ -86,6 +87,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
name: ps.name,
description: ps.description ?? null,
bannerId: banner ? banner.id : null,
isSensitive: ps.isSensitive ?? false,
...(ps.color !== undefined ? { color: ps.color } : {}),
} as Channel).then(x => this.channelsRepository.findOneByOrFail(x.identifiers[0]));

View File

@@ -60,6 +60,7 @@ export const paramDef = {
},
},
color: { type: 'string', minLength: 1, maxLength: 16 },
isSensitive: { type: 'boolean', nullable: true },
},
required: ['channelId'],
} as const;
@@ -114,6 +115,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
...(ps.color !== undefined ? { color: ps.color } : {}),
...(typeof ps.isArchived === 'boolean' ? { isArchived: ps.isArchived } : {}),
...(banner ? { bannerId: banner.id } : {}),
...(typeof ps.isSensitive === 'boolean' ? { isSensitive: ps.isSensitive } : {}),
});
return await this.channelEntityService.pack(channel.id, me);