feat(guild): GET /channels/:id/members
List explicit channel members (userIds) for the split members sidebar. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -34,6 +34,13 @@ export class ChannelsController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Get(':id/members')
|
||||||
|
members(@Req() req: AuthedRequest, @Param('id') channelId: string) {
|
||||||
|
const userId = req.userId ?? '';
|
||||||
|
if (!userId) throw new UnauthorizedException('missing user');
|
||||||
|
return this.channelsService.channelMembers(channelId);
|
||||||
|
}
|
||||||
|
|
||||||
@Post(':id/join')
|
@Post(':id/join')
|
||||||
join(@Req() req: AuthedRequest, @Param('id') channelId: string) {
|
join(@Req() req: AuthedRequest, @Param('id') channelId: string) {
|
||||||
const userId = req.userId ?? '';
|
const userId = req.userId ?? '';
|
||||||
|
|||||||
@@ -56,6 +56,14 @@ export class ChannelsService {
|
|||||||
.map((c) => ({ ...c, isMember: memberChannelIds.has(c.id) }));
|
.map((c) => ({ ...c, isMember: memberChannelIds.has(c.id) }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async channelMembers(channelId: string): Promise<{ userId: string }[]> {
|
||||||
|
const rows = await this.memberRepo.find({
|
||||||
|
where: { channelId },
|
||||||
|
order: { createdAt: 'ASC' },
|
||||||
|
});
|
||||||
|
return rows.map((r) => ({ userId: r.userId }));
|
||||||
|
}
|
||||||
|
|
||||||
async joinChannel(channelId: string, userId: string) {
|
async joinChannel(channelId: string, userId: string) {
|
||||||
const channel = await this.channelRepo.findOne({ where: { id: channelId } });
|
const channel = await this.channelRepo.findOne({ where: { id: channelId } });
|
||||||
if (!channel) throw new NotFoundException('channel not found');
|
if (!channel) throw new NotFoundException('channel not found');
|
||||||
|
|||||||
Reference in New Issue
Block a user