Files
webmail/hooks/use-calendar-error-message.ts
T
Linus Rath 81b196a6ca fix: explain Stalwart 1.0's participant limit on events
Stalwart 1.0 enforces maxParticipantsPerEvent (20 by default) on every
CalendarEvent create and update, answers to invitations included, and
refuses anything over it with invalidProperties "An event cannot have
more than 20 participants.". 0.16 advertises the same value but never
enforced it. Creating, editing, moving or answering a bigger meeting
failed with a generic "Failed to save event".

- read the limit from the calendars account capability and warn in the
  event editor when the attendees go over it, without blocking the save
- name the limit, and that an administrator can raise it, when the
  server refuses a create, edit, move, resize or answer for it, in the
  calendar and in the invitation banner
- keep the SetError type on refused event creates and updates
2026-09-25 19:39:20 +02:00

18 lines
644 B
TypeScript

"use client";
import { useCallback } from "react";
import { useTranslations } from "next-intl";
import { participantLimitOf } from "@/lib/calendar-participants";
/**
* The message for a failed calendar change: why the server refused it when
* that is something the user can act on, `fallback` otherwise.
*/
export function useCalendarErrorMessage(): (error: unknown, fallback: string) => string {
const t = useTranslations("calendar.notifications");
return useCallback((error: unknown, fallback: string) => {
const max = participantLimitOf(error);
return max === null ? fallback : t("participant_limit", { max });
}, [t]);
}