mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2026-04-25 06:35:18 +00:00
fix: past due meetings are now 8h for ics (#958)
This commit is contained in:
committed by
GitHub
parent
aa7f4cdb39
commit
52888f692f
@@ -83,9 +83,6 @@ def _should_sync(room) -> bool:
|
|||||||
return time_since_sync.total_seconds() >= room.ics_fetch_interval
|
return time_since_sync.total_seconds() >= room.ics_fetch_interval
|
||||||
|
|
||||||
|
|
||||||
MEETING_DEFAULT_DURATION = timedelta(hours=1)
|
|
||||||
|
|
||||||
|
|
||||||
async def create_upcoming_meetings_for_event(event, create_window, room: Room):
|
async def create_upcoming_meetings_for_event(event, create_window, room: Room):
|
||||||
if event.start_time <= create_window:
|
if event.start_time <= create_window:
|
||||||
return
|
return
|
||||||
@@ -102,7 +99,9 @@ async def create_upcoming_meetings_for_event(event, create_window, room: Room):
|
|||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
end_date = event.end_time or (event.start_time + MEETING_DEFAULT_DURATION)
|
# 8h rejoin window matches manual on-the-fly meetings; the scheduled
|
||||||
|
# DTEND stays in calendar_events.end_time for reference.
|
||||||
|
end_date = event.start_time + timedelta(hours=8)
|
||||||
|
|
||||||
client = create_platform_client(room.platform)
|
client = create_platform_client(room.platform)
|
||||||
|
|
||||||
|
|||||||
@@ -5,11 +5,14 @@ import pytest
|
|||||||
from icalendar import Calendar, Event
|
from icalendar import Calendar, Event
|
||||||
|
|
||||||
from reflector.db import get_database
|
from reflector.db import get_database
|
||||||
from reflector.db.calendar_events import calendar_events_controller
|
from reflector.db.calendar_events import CalendarEvent, calendar_events_controller
|
||||||
|
from reflector.db.meetings import meetings_controller
|
||||||
from reflector.db.rooms import rooms, rooms_controller
|
from reflector.db.rooms import rooms, rooms_controller
|
||||||
from reflector.services.ics_sync import ics_sync_service
|
from reflector.services.ics_sync import ics_sync_service
|
||||||
|
from reflector.video_platforms.models import MeetingData
|
||||||
from reflector.worker.ics_sync import (
|
from reflector.worker.ics_sync import (
|
||||||
_should_sync,
|
_should_sync,
|
||||||
|
create_upcoming_meetings_for_event,
|
||||||
sync_room_ics,
|
sync_room_ics,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -225,6 +228,68 @@ async def test_sync_respects_fetch_interval():
|
|||||||
assert mock_delay.call_args[0][0] == room2.id
|
assert mock_delay.call_args[0][0] == room2.id
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_create_upcoming_meeting_uses_8h_end_date():
|
||||||
|
# ICS-pre-created meetings get an 8h rejoin window anchored to the
|
||||||
|
# scheduled start, ignoring the calendar event's DTEND. Regression
|
||||||
|
# guard for the "Meeting has ended" bug when participants run over a
|
||||||
|
# short scheduled window.
|
||||||
|
room = await rooms_controller.add(
|
||||||
|
name="ics-8h-room",
|
||||||
|
user_id="test-user",
|
||||||
|
zulip_auto_post=False,
|
||||||
|
zulip_stream="",
|
||||||
|
zulip_topic="",
|
||||||
|
is_locked=False,
|
||||||
|
room_mode="normal",
|
||||||
|
recording_type="cloud",
|
||||||
|
recording_trigger="automatic-2nd-participant",
|
||||||
|
is_shared=False,
|
||||||
|
ics_url="https://calendar.example.com/ics-8h.ics",
|
||||||
|
ics_enabled=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
now = datetime.now(timezone.utc)
|
||||||
|
event_start = now + timedelta(minutes=1)
|
||||||
|
event_end = event_start + timedelta(minutes=30)
|
||||||
|
|
||||||
|
event = await calendar_events_controller.upsert(
|
||||||
|
CalendarEvent(
|
||||||
|
room_id=room.id,
|
||||||
|
ics_uid="ics-8h-evt",
|
||||||
|
title="Short meeting that runs over",
|
||||||
|
start_time=event_start,
|
||||||
|
end_time=event_end,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
create_window = now - timedelta(minutes=6)
|
||||||
|
|
||||||
|
fake_client = MagicMock()
|
||||||
|
fake_client.create_meeting = AsyncMock(
|
||||||
|
return_value=MeetingData(
|
||||||
|
meeting_id="ics-8h-meeting",
|
||||||
|
room_name=room.name,
|
||||||
|
room_url="https://daily.example/ics-8h",
|
||||||
|
host_room_url="https://daily.example/ics-8h",
|
||||||
|
platform=room.platform,
|
||||||
|
extra_data={},
|
||||||
|
)
|
||||||
|
)
|
||||||
|
fake_client.upload_logo = AsyncMock(return_value=True)
|
||||||
|
|
||||||
|
with patch(
|
||||||
|
"reflector.worker.ics_sync.create_platform_client",
|
||||||
|
return_value=fake_client,
|
||||||
|
):
|
||||||
|
await create_upcoming_meetings_for_event(event, create_window, room)
|
||||||
|
|
||||||
|
meeting = await meetings_controller.get_by_calendar_event(event.id, room)
|
||||||
|
assert meeting is not None
|
||||||
|
assert meeting.start_date == event_start
|
||||||
|
assert meeting.end_date == event_start + timedelta(hours=8)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_sync_handles_errors_gracefully():
|
async def test_sync_handles_errors_gracefully():
|
||||||
room = await rooms_controller.add(
|
room = await rooms_controller.add(
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import {
|
|||||||
} from "../lib/apiHooks";
|
} from "../lib/apiHooks";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { formatDateTime, formatStartedAgo } from "../lib/timeUtils";
|
import { formatDateTime, formatStartedAgo } from "../lib/timeUtils";
|
||||||
|
import { formatJoinError } from "../lib/errorUtils";
|
||||||
import MeetingMinimalHeader from "../components/MeetingMinimalHeader";
|
import MeetingMinimalHeader from "../components/MeetingMinimalHeader";
|
||||||
import { NonEmptyString } from "../lib/utils";
|
import { NonEmptyString } from "../lib/utils";
|
||||||
import { MeetingId, assertMeetingId } from "../lib/types";
|
import { MeetingId, assertMeetingId } from "../lib/types";
|
||||||
@@ -188,6 +189,19 @@ export default function MeetingSelection({
|
|||||||
flex="1"
|
flex="1"
|
||||||
gap={{ base: 4, md: 6 }}
|
gap={{ base: 4, md: 6 }}
|
||||||
>
|
>
|
||||||
|
{joinMeetingMutation.isError && (
|
||||||
|
<Box
|
||||||
|
p={4}
|
||||||
|
borderRadius="md"
|
||||||
|
bg="red.50"
|
||||||
|
borderLeft="4px solid"
|
||||||
|
borderColor="red.400"
|
||||||
|
>
|
||||||
|
<Text color="red.700">
|
||||||
|
{formatJoinError(joinMeetingMutation.error)}
|
||||||
|
</Text>
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
{/* Current Ongoing Meetings - BIG DISPLAY */}
|
{/* Current Ongoing Meetings - BIG DISPLAY */}
|
||||||
{currentMeetings.length > 0 ? (
|
{currentMeetings.length > 0 ? (
|
||||||
<VStack align="stretch" gap={6} mb={8}>
|
<VStack align="stretch" gap={6} mb={8}>
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import {
|
|||||||
useRoomJoinMeeting,
|
useRoomJoinMeeting,
|
||||||
useMeetingStartRecording,
|
useMeetingStartRecording,
|
||||||
} from "../../lib/apiHooks";
|
} from "../../lib/apiHooks";
|
||||||
|
import { formatJoinError } from "../../lib/errorUtils";
|
||||||
import { omit } from "remeda";
|
import { omit } from "remeda";
|
||||||
import {
|
import {
|
||||||
assertExists,
|
assertExists,
|
||||||
@@ -428,7 +429,7 @@ export default function DailyRoom({ meeting, room }: DailyRoomProps) {
|
|||||||
if (joinMutation.isError) {
|
if (joinMutation.isError) {
|
||||||
return (
|
return (
|
||||||
<Center width="100vw" height="100vh">
|
<Center width="100vw" height="100vh">
|
||||||
<Text color="red.500">Failed to join meeting. Please try again.</Text>
|
<Text color="red.500">{formatJoinError(joinMutation.error)}</Text>
|
||||||
</Center>
|
</Center>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
import type { components } from "../../reflector-api";
|
import type { components } from "../../reflector-api";
|
||||||
import { useAuth } from "../../lib/AuthProvider";
|
import { useAuth } from "../../lib/AuthProvider";
|
||||||
import { useRoomJoinMeeting } from "../../lib/apiHooks";
|
import { useRoomJoinMeeting } from "../../lib/apiHooks";
|
||||||
|
import { formatJoinError } from "../../lib/errorUtils";
|
||||||
import { assertMeetingId } from "../../lib/types";
|
import { assertMeetingId } from "../../lib/types";
|
||||||
import {
|
import {
|
||||||
ConsentDialogButton,
|
ConsentDialogButton,
|
||||||
@@ -66,7 +67,6 @@ export default function LiveKitRoom({ meeting, room }: LiveKitRoomProps) {
|
|||||||
|
|
||||||
const joinMutation = useRoomJoinMeeting();
|
const joinMutation = useRoomJoinMeeting();
|
||||||
const [joinedMeeting, setJoinedMeeting] = useState<Meeting | null>(null);
|
const [joinedMeeting, setJoinedMeeting] = useState<Meeting | null>(null);
|
||||||
const [connectionError, setConnectionError] = useState(false);
|
|
||||||
const [userChoices, setUserChoices] = useState<LocalUserChoices | null>(null);
|
const [userChoices, setUserChoices] = useState<LocalUserChoices | null>(null);
|
||||||
|
|
||||||
// ── Consent dialog (same hooks as Daily/Whereby) ──────────
|
// ── Consent dialog (same hooks as Daily/Whereby) ──────────
|
||||||
@@ -99,7 +99,7 @@ export default function LiveKitRoom({ meeting, room }: LiveKitRoomProps) {
|
|||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
})();
|
})();
|
||||||
const isJoining = !!userChoices && !joinedMeeting && !connectionError;
|
const isJoining = !!userChoices && !joinedMeeting && !joinMutation.isError;
|
||||||
|
|
||||||
// ── Join meeting via backend API after PreJoin submit ─────
|
// ── Join meeting via backend API after PreJoin submit ─────
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -123,7 +123,6 @@ export default function LiveKitRoom({ meeting, room }: LiveKitRoomProps) {
|
|||||||
if (!cancelled) setJoinedMeeting(result);
|
if (!cancelled) setJoinedMeeting(result);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Failed to join LiveKit meeting:", err);
|
console.error("Failed to join LiveKit meeting:", err);
|
||||||
if (!cancelled) setConnectionError(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,10 +181,10 @@ export default function LiveKitRoom({ meeting, room }: LiveKitRoomProps) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connectionError) {
|
if (joinMutation.isError) {
|
||||||
return (
|
return (
|
||||||
<Center h="100vh" bg="gray.50">
|
<Center h="100vh" bg="gray.50">
|
||||||
<Text fontSize="lg">Failed to connect to meeting</Text>
|
<Text fontSize="lg">{formatJoinError(joinMutation.error)}</Text>
|
||||||
</Center>
|
</Center>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -863,16 +863,9 @@ export function useRoomGetMeeting(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function useRoomJoinMeeting() {
|
export function useRoomJoinMeeting() {
|
||||||
const { setError } = useError();
|
|
||||||
|
|
||||||
return $api.useMutation(
|
return $api.useMutation(
|
||||||
"post",
|
"post",
|
||||||
"/v1/rooms/{room_name}/meetings/{meeting_id}/join",
|
"/v1/rooms/{room_name}/meetings/{meeting_id}/join",
|
||||||
{
|
|
||||||
onError: (error) => {
|
|
||||||
setError(error as Error, "There was an error joining the meeting");
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,35 @@
|
|||||||
import { isNonEmptyArray, NonEmptyArray } from "./array";
|
import { isNonEmptyArray, NonEmptyArray } from "./array";
|
||||||
|
|
||||||
|
export function getErrorDetail(error: unknown, fallback: string): string {
|
||||||
|
if (!error) return fallback;
|
||||||
|
if (typeof error === "object" && error !== null) {
|
||||||
|
const detail = (error as { detail?: unknown }).detail;
|
||||||
|
if (typeof detail === "string" && detail.length > 0) return detail;
|
||||||
|
const response = (error as { response?: { data?: { detail?: unknown } } })
|
||||||
|
.response;
|
||||||
|
const nestedDetail = response?.data?.detail;
|
||||||
|
if (typeof nestedDetail === "string" && nestedDetail.length > 0)
|
||||||
|
return nestedDetail;
|
||||||
|
}
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function formatJoinError(error: unknown): string {
|
||||||
|
const detail = getErrorDetail(error, "");
|
||||||
|
switch (detail) {
|
||||||
|
case "Meeting has ended":
|
||||||
|
return "This meeting has ended. The organizer can start a new one.";
|
||||||
|
case "Meeting is not active":
|
||||||
|
return "This meeting is no longer active. Ask the organizer to start it again.";
|
||||||
|
case "Meeting not found":
|
||||||
|
return "This meeting no longer exists. Check the link or ask the organizer for a new one.";
|
||||||
|
case "Room not found":
|
||||||
|
return "This room doesn't exist.";
|
||||||
|
default:
|
||||||
|
return detail || "We couldn't join the meeting. Please try again.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function shouldShowError(error: Error | null | undefined) {
|
export function shouldShowError(error: Error | null | undefined) {
|
||||||
if (
|
if (
|
||||||
error?.name == "ResponseError" &&
|
error?.name == "ResponseError" &&
|
||||||
|
|||||||
Reference in New Issue
Block a user