Fix schedule endpoint so it only returns public channels

This commit is contained in:
Hendrik Belitz
2026-05-11 11:17:51 +02:00
parent 518717b325
commit f47320dd8a
2 changed files with 21 additions and 19 deletions
@@ -10,8 +10,8 @@ import { checkPermission } from "$lib/server/utils/permissions";
registerOpenAPIRoute("/tenants/{id}/calendar", "GET", {
summary: "Get tenant calendar",
description:
"Retrieves the appointment calendar for a specific tenant within a date range. Shows available time slots, existing appointments, and agent availability. This is a public endpoint that doesn't require authentication.",
tags: ["Calendar", "Public"],
"Retrieves the appointment calendar for a specific tenant within a date range. Shows available time slots, existing appointments, and agent availability. This is a private endpoint that requires authentication.",
tags: ["Calendar", "Private"],
parameters: [
{
name: "id",
+19 -17
View File
@@ -187,24 +187,26 @@ export const GET: RequestHandler = async ({ params, url }) => {
const clientSchedule = schedule.schedule.map((daySchedule) => ({
date: daySchedule.date,
channels: Object.fromEntries(
Object.entries(daySchedule.channels).map(([channelId, channelData]) => [
channelId,
{
channel: {
id: channelData.channel.id,
names: channelData.channel.names,
descriptions: channelData.channel.descriptions,
requiresConfirmation: channelData.channel.requiresConfirmation,
pause: channelData.channel.pause,
Object.entries(daySchedule.channels)
.filter(([_, channelData]) => channelData.channel.isPublic)
.map(([channelId, channelData]) => [
channelId,
{
channel: {
id: channelData.channel.id,
names: channelData.channel.names,
descriptions: channelData.channel.descriptions,
requiresConfirmation: channelData.channel.requiresConfirmation,
pause: channelData.channel.pause,
},
availableSlots: channelData.availableSlots.map((slot) => ({
from: slot.from,
to: slot.to,
duration: slot.duration,
availableAgents: slot.availableAgents,
})),
},
availableSlots: channelData.availableSlots.map((slot) => ({
from: slot.from,
to: slot.to,
duration: slot.duration,
availableAgents: slot.availableAgents,
})),
},
]),
]),
),
}));