feat(backend): support isSensitive in channel endpoints

This commit is contained in:
anatawa12 2023-07-31 15:33:57 +09:00
parent aacde76f43
commit 11593a76b0
No known key found for this signature in database
GPG Key ID: 9CA909848B8E4EA6
4 changed files with 9 additions and 0 deletions

View File

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

View File

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

View File

@ -44,6 +44,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;
@ -81,6 +82,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

@ -55,6 +55,7 @@ export const paramDef = {
},
},
color: { type: 'string', minLength: 1, maxLength: 16 },
isSensitive: { type: 'boolean', nullable: true },
},
required: ['channelId'],
} as const;
@ -109,6 +110,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);