Let each person decide whether a shared calendar reminds them
reminders_enabled belongs to the calendar, so it belongs to its owner: whoever shares a calendar decides whether it notifies everyone it reaches, and a recipient's PUT is refused with 404 by the owner-only filter. For a group calendar that is worse than it sounds — the creator owns it, so silencing it for themselves would silence every member. CalendarReminderPref follows CalendarColorPref exactly, which already solves this for colours. Only local calendars are shareable (CalendarShare, GroupCalendar and group_visible_calendar_id all point at local_calendars.id), so no source discrimination is needed and the other four routers are untouched. No migration: create_all makes new tables, which is why calendar_color_prefs has no migration entry either. A recipient without an override gets reminders on, rather than inheriting the owner's choice. Muting is personal and should not spread. The new endpoint decides owner-vs-override server-side, so the existing owner-only PUT stays the guard it already is, and GET keeps returning reminders_enabled — now carrying the effective value, so no client model has to change. Birthday reminders were injected without consulting the flag at all, so a muted birthday calendar still handed the schedulers something to fire. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
c811486ea7
commit
25f015a15b
@@ -432,6 +432,24 @@ class CalendarColorPref(Base):
|
||||
color = Column(String(16), nullable=False)
|
||||
|
||||
|
||||
class CalendarReminderPref(Base):
|
||||
"""A user's personal reminder mute for a calendar they don't own — works for
|
||||
any way a foreign calendar becomes visible (direct share, group calendar, or
|
||||
a co-member's group-visible calendar). Absent = reminders on, regardless of
|
||||
what the owner chose: muting is a personal decision and must not spread from
|
||||
the owner to everyone a calendar reaches."""
|
||||
|
||||
__tablename__ = "calendar_reminder_prefs"
|
||||
__table_args__ = (
|
||||
UniqueConstraint("calendar_id", "user_id", name="uq_calendar_reminder_pref"),
|
||||
)
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
calendar_id = Column(Integer, ForeignKey("local_calendars.id"), nullable=False)
|
||||
user_id = Column(Integer, ForeignKey("users.id"), nullable=False)
|
||||
enabled = Column(Boolean, nullable=False)
|
||||
|
||||
|
||||
class Group(Base):
|
||||
__tablename__ = "groups"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user