oficina / calendar Public

Calendar team mode: Fable's #35 notes N1-N4, Paul's feed ruling

N1: an import the lease runs out on part-way says how many events landed
and that importing the same file again repeats them (import keeps no
source UID to dedupe on; recorded). N2: a removed member's reminder
occurrence is settled with nothing queued, the rule held dormant under
team:dormant, and their next request as a Member queues it again. N3:
the series split's writable-calendar read goes through grantJoin, and
the grant-read test refuses every spelling outside team_reach.go. N4:
the spec says what an unlinked local account gets in team mode. The
spec records Fable's approval and Paul's 2026-10-31 ruling: no
roster-owner revoke of a current member's feeds, for now.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 2697fe59dcd3aba4cdf9b1a36a51882e064abba3 parent e8e509d
13 files changed, +248 −36
  • AGENTS.md +3 −1
  • docs/superpowers/specs/2026-09-02-calendar-design.md +38 −10
  • internal/calendar/handlers_misc.go +1 −1
  • internal/calendar/store_override.go +4 −2
  • internal/calendar/store_split_overrides.go +9 −6
  • internal/calendar/team_access.go +12 −3
  • internal/calendar/team_answers.go +24 −0
  • internal/calendar/team_guard_test.go +35 −0
  • internal/calendar/team_identity_test.go +11 −4
  • internal/calendar/team_jobs.go +50 −7
  • internal/calendar/team_jobs_test.go +54 −0
  • internal/calendar/team_world_test.go +6 −1
  • internal/calendar/templates/import_done.html +1 −1

CI failed — run details

diff --git a/AGENTS.md b/AGENTS.md
index 091ad72..484bd79 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -318,7 +318,9 @@ every rule above stands; the one difference is `GET /api/team` answering
(`team_feed.go`: Unknown is a 503, never a short calendar), a booking
page on its host's (`team_booking.go`), a reminder or host mail on its
recipient's (`team_jobs.go`). The drain itself is the system's and
- unguarded; what it delivers is decided on the person's standing.
+ unguarded; what it delivers is decided on the person's standing. A
+ removed member's reminder rules go dormant (claim `team:dormant`) and
+ wake on their next request as a Member.
- **Home-only people have no address** (`team_home_only.go`,
`teamstate/`): their `people.address` is a `home-only:` placeholder the
triggers keep that way. Never mail it, show it, or treat it as an
diff --git a/docs/superpowers/specs/2026-09-02-calendar-design.md b/docs/superpowers/specs/2026-09-02-calendar-design.md
index 04287e3..436c7f5 100644
--- a/docs/superpowers/specs/2026-09-02-calendar-design.md
+++ b/docs/superpowers/specs/2026-09-02-calendar-design.md
@@ -314,7 +314,12 @@ proof flow and account screens; Calendar keeps its own page shell and grants.
and `implementation/teammode-package.md` §7.3, on Home's shared
`home/teammode` package (pinned with `roster` and `connect` at Home main
`67c12e3`). Reference ports: Sheets (`35dd773`, #52–#54), Slides
-(`951373f`, #33), Memoria (branch `team-mode`, #32). Not deployed.
+(`951373f`, #33), Memoria (branch `team-mode`, #32). Not deployed. **Reviewed by Claude Fable 5.1 (claude-fable-5-1) on
+oficina/calendar #35, APPROVED at `e8e509d`**, all thirteen deviations
+accepted; notes N1–N4 applied before merge (below). **Paul, 2026-10-31:**
+no roster-owner revoke of a current member's feeds, for now; reminders for
+Home-only members still under discussion, so this ships with no address
+column (Fable recommends option (a)).
**Configuration.** The five `CALENDAR_TEAM_*` variables (`_ID`,
`_DIRECTORY_ORIGIN`, `_PROVISIONING_BASE64`, `_OPERATOR_KEYS_BASE64`,
@@ -354,7 +359,9 @@ reach nothing. So:
Standing is read from the request's `teammode.Access` once, before each
scoped read (`team_reach.go`: the grant join matches nothing without
Member), so reach is never decided before standing; a view asks again as
-the page is drawn. The roster's role is not consulted: owners and members
+the page is drawn. Every grant read goes through `grantJoin`, the series
+split's writable-calendar subquery included (Fable #35 N3);
+`TestTeamEveryGrantJoinIsTheRungs` refuses any other spelling. The roster's role is not consulted: owners and members
reach the same calendars, and Calendar has no owner-only power.
**Orphans.** Paul's rule (share/retitle only, no delete or narrowing,
@@ -387,10 +394,10 @@ either rendering under Unknown (deciding reach without standing) or storing
a plaintext copy of the calendar to replay, which the one rule forbids.
Google, Apple and Outlook keep the copy they last fetched when a poll
fails, so the subscriber's calendar does not go blank; it goes stale until
-Home answers. **Flagged for Paul.** The roster-owner revoke §7.3 asked for
-is not built: tying the feed to its minter's standing does what that revoke
-was for (a departed member's URLs die by themselves); a roster owner
-revoking a *current* member's feeds is a new power, his to rule on.
+Home answers. The roster-owner revoke §7.3 asked for is not built: tying
+the feed to its minter's standing does what that revoke was for (a
+departed member's URLs die by themselves). **RULED by Paul, 2026-10-31: no
+roster-owner revoke of a current member's feeds, for now.**
**The dashboard pull** (`/api/oficina/dashboard`, another origin) is
unavailable under Unknown, never short; empty for NotMember. The calendar
@@ -411,10 +418,16 @@ and the drain a page view runs) acts as the system, under nobody's lease,
as Memoria's connector runs do. What it **delivers** to a person is decided
on that person's own standing as it is about to go (`team_jobs.go`): a
reminder only to a Member who still reaches the event and has an address
-(NotMember, out of reach or addressless: that occurrence is settled unsent
-and the next is decided on its own day; Unknown: deferred, unsent and
-unattempted, by five minutes, so a Home outage does not keep the instance
-awake). A booking's host mail goes only to a Member host with an address
+(out of reach or addressless: that occurrence is settled unsent and the
+next is decided on its own day; Unknown: deferred, unsent and unattempted,
+by five minutes, so a Home outage does not keep the instance awake).
+**NotMember: the occurrence is settled unsent and nothing is queued** —
+the rule goes dormant (its queue row fired, under the claim
+`team:dormant`), so a removed member's daily standup does not wake the
+instance every day for nobody; their next request as a Member (re-added)
+queues every dormant rule of theirs again from now (Fable #35 N2; the
+alternative, re-queueing each occurrence and settling it on its day, leaks
+nothing but costs a wake per occurrence per removed member). A booking's host mail goes only to a Member host with an address
(otherwise retired unsent; Unknown deferred); the booker's mail is
unchanged (B5). A removed member is sent nothing about the team's events.
@@ -459,6 +472,21 @@ Options, none built:
(`?alarms=1`), so a Home-only member could get reminders from their own
calendar app — but only for reminder rules they cannot currently make.
+**Unlinked local accounts** (Fable #35 N4): a local account with no Oficina
+link has no Home subject, so the roster's answer about it is NotMember —
+its reminders go dormant and its published booking page is a 404 until it
+links and is on the roster. Alta provisions team instances fresh, so
+nothing is affected today; an instance activated with existing local
+people would go quiet for them until they link.
+
+**Import** (Fable #35 N1): import is one guarded write per event, and does
+not dedupe on UID (`buildEvent` mints a fresh UID; the source UID is not
+kept). A lapse part-way answers the retryable 503 and, when some events had
+already landed, says how many and that importing the same file again adds
+them a second time. Keeping the source UID so a re-import can skip what
+landed is a change to every import's exported UIDs, left for its own
+branch.
+
**Allowlist.** `CALENDAR_ALLOWED_ADDRESSES` becomes optional in team mode
(every Env; empty admits nobody locally, never the development default). It
admits the local door and nothing more: a linked person stands on the
diff --git a/internal/calendar/handlers_misc.go b/internal/calendar/handlers_misc.go
index 8eab4bd..656a04a 100644
--- a/internal/calendar/handlers_misc.go
+++ b/internal/calendar/handlers_misc.go
@@ -230,7 +230,7 @@ func (h *handlers) importICS(w http.ResponseWriter, r *http.Request) {
// Team mode: standing that lapsed mid-file stops the import
// with a retry, never a count of "skipped" events that were
// refused for who was importing them (team_guard.go).
- if h.guardRefused(w, r, err) {
+ if h.importRefused(w, r, err, res) {
return
}
// One unusable event does not fail the file. It is counted
diff --git a/internal/calendar/store_override.go b/internal/calendar/store_override.go
index 161a74b..c25cdbd 100644
--- a/internal/calendar/store_override.go
+++ b/internal/calendar/store_override.go
@@ -167,8 +167,10 @@ func (s *Store) SplitSeries(ctx context.Context, personID, seriesID int64, origi
// splitOn is SplitSeries' write, on its transaction.
func (s *Store) splitOn(tx *gorm.DB, personID, seriesID int64, master EventView, headRule string, cut time.Time, in EventInput) error {
+ // Standing is read once, before the reads it decides (team_reach.go).
+ rung := s.reaches(tx.Statement.Context)
headUntil, _ := RuleUntilUTC(headRule, master.StartLocal, master.TZ, master.AllDay)
- head := splitWritableEvents(tx, personID, master.CalendarID).
+ head := splitWritableEvents(tx, personID, master.CalendarID, rung).
Where("id = ? AND deleted_at IS NULL AND sequence = ?", seriesID, master.Sequence).
Select("rrule", "until_utc", "sequence", "updated_at").
Updates(map[string]any{
@@ -200,7 +202,7 @@ func (s *Store) splitOn(tx *gorm.DB, personID, seriesID int64, master EventView,
return fmt.Errorf("calendar: create the tail series: %w", err)
}
- if err := moveSplitOverrides(tx, personID, master.Event, ev, cut); err != nil {
+ if err := moveSplitOverrides(tx, personID, master.Event, ev, cut, rung); err != nil {
return err
}
return s.rescheduleAllForTx(tx, seriesID)
diff --git a/internal/calendar/store_split_overrides.go b/internal/calendar/store_split_overrides.go
index d13658c..30be886 100644
--- a/internal/calendar/store_split_overrides.go
+++ b/internal/calendar/store_split_overrides.go
@@ -4,16 +4,15 @@ import (
"fmt"
"time"
- "amadan.net/rastrillo/rastrillo/scope"
"gorm.io/gorm"
)
// An exception belongs to the series containing its original occurrence,
// even when someone moved it across the split date. Cancelled exceptions
// move too, so splitting cannot restore a deleted occurrence.
-func moveSplitOverrides(tx *gorm.DB, personID int64, master, tail Event, cut time.Time) error {
+func moveSplitOverrides(tx *gorm.DB, personID int64, master, tail Event, cut time.Time, rung bool) error {
writable := func() *gorm.DB {
- return splitWritableEvents(tx, personID, master.CalendarID).Where("series_id = ?", master.ID)
+ return splitWritableEvents(tx, personID, master.CalendarID, rung).Where("series_id = ?", master.ID)
}
var overrides []Event
if err := writable().Find(&overrides).Error; err != nil {
@@ -45,8 +44,12 @@ func moveSplitOverrides(tx *gorm.DB, personID int64, master, tail Event, cut tim
return nil
}
-func splitWritableEvents(tx *gorm.DB, personID, calendarID int64) *gorm.DB {
- calendars := scope.OwnedBy(tx.Model(&Grant{}), "person_id", personID).
- Select("calendar_id").Where("role IN ?", []string{RoleOwner, RoleEditor})
+// splitWritableEvents is the events on calendarID that personID may write,
+// through the person's grant joined the way every scoped read joins it
+// (grantJoin, on the reach the caller read once: team_reach.go).
+func splitWritableEvents(tx *gorm.DB, personID, calendarID int64, rung bool) *gorm.DB {
+ calendars := tx.Table("calendars").Select("calendars.id").
+ Joins(grantJoin("calendars.id", rung), personID).
+ Where("grants.role IN ?", []string{RoleOwner, RoleEditor})
return tx.Model(&Event{}).Where("calendar_id = ? AND calendar_id IN (?)", calendarID, calendars)
}
diff --git a/internal/calendar/team_access.go b/internal/calendar/team_access.go
index c8448bc..22ef596 100644
--- a/internal/calendar/team_access.go
+++ b/internal/calendar/team_access.go
@@ -180,9 +180,18 @@ func (a *App) teamRequirePerson(w http.ResponseWriter, r *http.Request, next htt
}
}
tp := &teamPerson{person: p, subject: subject, method: s.Method, access: a.team.Access(r.Context(), subject)}
- if tp.access.State() == roster.NotMember && !tp.unlinkedLocal() {
- a.offboard(w, r)
- return
+ switch tp.access.State() {
+ case roster.NotMember:
+ if !tp.unlinkedLocal() {
+ a.offboard(w, r)
+ return
+ }
+ case roster.Member:
+ // Back on the team: reminders that went dormant when they left
+ // are queued again (team_jobs.go).
+ if err := a.store.wakeDormantReminders(r.Context(), p.ID); err != nil {
+ a.logger.Error("calendar: wake dormant reminders", "stage", "team.wake", "err", scrubErr(err))
+ }
}
ctx := context.WithValue(withTeamPerson(r.Context(), tp), personCtxKey{}, p)
next.ServeHTTP(w, r.WithContext(ctx))
diff --git a/internal/calendar/team_answers.go b/internal/calendar/team_answers.go
index b53af0f..70b59f0 100644
--- a/internal/calendar/team_answers.go
+++ b/internal/calendar/team_answers.go
@@ -112,3 +112,27 @@ func (a *App) teamProbe(w http.ResponseWriter, r *http.Request) {
// (team_answers.go), for the team-partial template.
func (PageData) PartialTitle() string { return partialTitle }
func (PageData) PartialBody() string { return partialBody }
+
+// importRefused is guardRefused for an import, which is one guarded write
+// per event: standing that lapsed part-way stops the file with the
+// retryable 503, and when some events had already landed the page says how
+// many and that importing the same file again adds them a second time
+// (import does not dedupe on UID: Fable #35 N1). Nothing landed is the
+// plain retry. False for any other error.
+func (h *handlers) importRefused(w http.ResponseWriter, r *http.Request, err error, res ImportResult) bool {
+ if !errors.Is(err, teammode.ErrUnavailable) || res.Created == 0 {
+ return h.guardRefused(w, r, err)
+ }
+ events := "events were"
+ if res.Created == 1 {
+ events = "event was"
+ }
+ w.Header().Set("Cache-Control", "no-store")
+ w.Header().Set("Retry-After", retryAfter)
+ renderStatus(w, "import_done", http.StatusServiceUnavailable, h.page(r, "Import stopped", map[string]any{
+ "Result": res,
+ "Interrupted": strconv.Itoa(res.Created) + " " + events + " imported before your team access could no longer be checked. " +
+ "Importing the same file again will add those a second time; import the rest from a file without them, or try again in a moment and remove the duplicates.",
+ }))
+ return true
+}
diff --git a/internal/calendar/team_guard_test.go b/internal/calendar/team_guard_test.go
index a1d82b5..6b46b41 100644
--- a/internal/calendar/team_guard_test.go
+++ b/internal/calendar/team_guard_test.go
@@ -250,3 +250,38 @@ func TestTeamGuardRefusesWithoutStanding(t *testing.T) {
}
_ = url.Values{}
}
+
+// An import the lease runs out on part-way is a retry that says how many
+// events landed and that importing the same file again repeats them
+// (Fable #35 N1): the events before the lapse are committed, each under
+// its own guard, and import does not dedupe on UID.
+func TestTeamImportStoppedPartWaySaysWhatLanded(t *testing.T) {
+ w := newTeamWriteWorld(t)
+ f := w.f
+ defer func() { teamGuard = teammode.Guard }()
+ writes := 0
+ teamGuard = func(ctx context.Context, authorize func(roster.State) error, write func() error) error {
+ writes++
+ if writes == 2 {
+ return f.lapsingGuard(ctx, authorize, write)
+ }
+ return teammode.Guard(ctx, authorize, write)
+ }
+ before := func() int64 {
+ var n int64
+ f.app.db.G.Model(&Event{}).Count(&n)
+ return n
+ }
+ n := before()
+ got := w.importFile("BEGIN:VCALENDAR\r\n" +
+ "BEGIN:VEVENT\r\nUID:a\r\nSUMMARY:First\r\nDTSTART;TZID=UTC:20270111T100000\r\nDTEND;TZID=UTC:20270111T110000\r\nEND:VEVENT\r\n" +
+ "BEGIN:VEVENT\r\nUID:b\r\nSUMMARY:Second\r\nDTSTART;TZID=UTC:20270112T100000\r\nDTEND;TZID=UTC:20270112T110000\r\nEND:VEVENT\r\n" +
+ "END:VCALENDAR\r\n")
+ retryable(t, "an import stopped part-way", got)
+ if body := got.Body.String(); !strings.Contains(body, "1 event was imported") || !strings.Contains(body, "add those a second time") {
+ t.Fatal("the stopped import does not say what landed and what a retry does")
+ }
+ if before() != n+1 {
+ t.Fatalf("events %d → %d, want the one before the lapse", n, before())
+ }
+}
diff --git a/internal/calendar/team_identity_test.go b/internal/calendar/team_identity_test.go
index 29ab7af..943890b 100644
--- a/internal/calendar/team_identity_test.go
+++ b/internal/calendar/team_identity_test.go
@@ -201,8 +201,9 @@ func TestTeamHomeOnlyAllocationRefusesLinksAndAddresses(t *testing.T) {
}
// Every scoped read joins through grantJoin, which withholds the team
-// rung without Member standing (team_reach.go). A raw grant join written
-// anywhere else would reach the team calendar on no standing at all.
+// rung without Member standing (team_reach.go). A raw grant read written
+// anywhere else would reach the team calendar on no standing at all —
+// or rest on a guard it might one day be moved in front of (Fable #35 N3).
func TestTeamEveryGrantJoinIsTheRungs(t *testing.T) {
files, err := filepath.Glob("*.go")
if err != nil {
@@ -216,8 +217,14 @@ func TestTeamEveryGrantJoinIsTheRungs(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- if strings.Contains(strings.ToUpper(string(src)), "JOIN GRANTS") {
- t.Fatalf("%s joins grants itself; use grantJoin", name)
+ // A grant read by any spelling: a join, a model, a table or a
+ // FROM. ensureGrant's FirstOrCreate (store_calendar.go) writes a
+ // person's own grant and reads nothing, and is the one other use.
+ upper := strings.ToUpper(string(src))
+ for _, spelling := range []string{"JOIN GRANTS", "MODEL(&GRANT{})", `TABLE("GRANTS")`, "FROM GRANTS"} {
+ if strings.Contains(upper, spelling) {
+ t.Fatalf("%s reads grants itself (%s); use grantJoin", name, spelling)
+ }
}
}
}
diff --git a/internal/calendar/team_jobs.go b/internal/calendar/team_jobs.go
index a7e18ed..e621451 100644
--- a/internal/calendar/team_jobs.go
+++ b/internal/calendar/team_jobs.go
@@ -11,10 +11,13 @@ package calendar
//
// - a reminder is sent only to a recipient the roster says is a Member
// now, who still reaches the event on that standing, and who has an
-// address. NotMember, no reach, or a Home-only recipient settles that
-// occurrence unsent and queues the next, which is decided the same way
-// when it comes due (re-added, they are reminded again). Unknown defers
-// it, unsent and unattempted, by standingRetry.
+// address. No reach, or a Home-only recipient, settles that occurrence
+// unsent and queues the next, decided the same way on its day.
+// NotMember settles it unsent and queues NOTHING: the rule goes
+// dormant, so a removed member's daily standup does not wake the
+// instance every day for nobody (Fable #35 N2). Re-added, their next
+// request wakes every dormant rule of theirs (wakeDormantReminders).
+// Unknown defers it, unsent and unattempted, by standingRetry.
// - a booking's HOST mail goes only to a host who is a Member with an
// address; NotMember or addressless retires it unsent, Unknown defers
// it. The booker's own mail is theirs (they typed the address to be
@@ -42,11 +45,19 @@ const (
// deliverLater: standing cannot be read now. Nothing is sent and
// nothing is decided against the person.
deliverLater
- // deliverNever: definitely not to them — off the team, out of reach,
- // or no address.
+ // deliverNever: definitely not this occurrence — out of reach, or no
+ // address. The next is queued and decided on its own day.
deliverNever
+ // deliverDormant: off the team. Not this occurrence, and none after it
+ // until they are back.
+ deliverDormant
)
+// dormantClaim marks a reminder queue row settled because its person left
+// the team: fired (so nothing claims it and NextDue ignores it) and held
+// under this claim instead of a random one, so their return can find it.
+const dormantClaim = "team:dormant"
+
// standingRetry is how long a reminder waits when its recipient's
// standing cannot be read. Longer than the sender's own deferral: every
// wake costs a quarter hour of residency (AGENTS.md §Ticks), and a Home
@@ -67,7 +78,7 @@ func (h *handlers) reminderDelivery(ctx context.Context, due DueReminder) delive
acc := h.standingFor(ctx, due.PersonID)
switch acc.State() {
case roster.NotMember:
- return deliverNever
+ return deliverDormant
case roster.Unknown:
return deliverLater
}
@@ -96,10 +107,42 @@ func (h *handlers) settleWithoutSending(ctx context.Context, due DueReminder, no
// This occurrence is settled, unsent; the next is queued and
// decided on its own day.
return true, h.store.CompleteReminder(keep(ctx), due, now.Unix())
+ case deliverDormant:
+ return true, h.store.settleDormant(keep(ctx), due, now.Unix())
}
return false, nil
}
+// settleDormant settles a claimed reminder unsent and queues nothing,
+// conditional on the claim as every completion is: the row is fired and
+// held under dormantClaim until its person returns.
+func (s *Store) settleDormant(ctx context.Context, due DueReminder, now int64) error {
+ return s.g.WithContext(ctx).Model(&ReminderQueue{}).
+ Where("id = ? AND claim_id = ?", due.Queue.ID, due.ClaimID).
+ Updates(map[string]any{"fired_at": now, "claimed_at": nil, "claim_id": dormantClaim}).Error
+}
+
+// wakeDormantReminders reschedules every rule of personID's that went
+// dormant when they left the team, from now: run on a request whose
+// standing is Member, which is how a re-added member is noticed. One
+// indexed read when there is nothing to wake. A failure costs only the
+// wake, which the next request tries again.
+func (s *Store) wakeDormantReminders(ctx context.Context, personID int64) error {
+ var ids []int64
+ if err := s.g.WithContext(ctx).Model(&ReminderQueue{}).
+ Joins("JOIN reminders ON reminders.id = reminder_queues.reminder_id").
+ Where("reminders.person_id = ? AND reminder_queues.claim_id = ?", personID, dormantClaim).
+ Pluck("reminder_queues.reminder_id", &ids).Error; err != nil {
+ return fmt.Errorf("calendar: find dormant reminders: %w", err)
+ }
+ for _, id := range ids {
+ if err := s.rescheduleAfterTx(s.g.WithContext(ctx), id, 0); err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
// hostMail decides a booking's host mail on the host's standing.
func (h *handlers) hostMail(ctx context.Context, host Person) delivery {
if h.team == nil {
diff --git a/internal/calendar/team_jobs_test.go b/internal/calendar/team_jobs_test.go
index 9faf21f..d05934a 100644
--- a/internal/calendar/team_jobs_test.go
+++ b/internal/calendar/team_jobs_test.go
@@ -266,3 +266,57 @@ func TestTeamReminderNeedsReach(t *testing.T) {
t.Fatal("a reminder out of reach was left due")
}
}
+
+// A removed member's recurring reminder goes quiet rather than waking the
+// instance every day for nobody, and their return queues it again (Fable
+// #35 N2).
+func TestTeamRemovedMembersRemindersGoDormantAndWakeOnReturn(t *testing.T) {
+ f := newTeamFixture(t)
+ box := f.mailbox()
+ subject := teamSubject('z')
+ alice := f.linkedAlice(subject, "member")
+ team, _ := f.calendarsOf(alice)
+ start, end := soon(5)
+ e, err := f.app.store.CreateEvent(f.withAccess(subject), alice.ID, EventInput{CalendarID: team, Title: "Daily standup", StartLocal: start, EndLocal: end, TZ: "UTC", Kind: KindMeeting, Status: StatusConfirmed, RRule: "FREQ=DAILY"})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err := f.app.store.AddReminder(f.withAccess(subject), alice.ID, e.ID, 10); err != nil {
+ t.Fatal(err)
+ }
+ row := func() ReminderQueue {
+ var q ReminderQueue
+ f.app.db.G.Joins("JOIN reminders ON reminders.id = reminder_queues.reminder_id").Where("reminders.event_id = ?", e.ID).First(&q)
+ return q
+ }
+ f.dir.Set(subject, "")
+ f.refreshed()
+ if sent, _, err := f.app.h.drain(context.Background(), time.Now()); err != nil || sent != 0 || len(box.sent) != 0 {
+ t.Fatalf("drain for a removed member = %d %v %v", sent, box.sent, err)
+ }
+ q := row()
+ if q.FiredAt == nil || q.ClaimID == nil || *q.ClaimID != dormantClaim {
+ t.Fatalf("a removed member's daily reminder = fired %v claim %v, want dormant", q.FiredAt, q.ClaimID)
+ }
+ // Nothing queued: no wake tomorrow, or the day after, for nobody.
+ if due := f.app.store.NextDueAt(context.Background()); !due.IsZero() {
+ t.Fatalf("a dormant reminder still asks for a wake at %v", due)
+ }
+ if sent, _, _ := f.app.h.drain(context.Background(), time.Now().Add(72*time.Hour)); sent != 0 {
+ t.Fatal("a dormant reminder fired days later")
+ }
+ // Back on the team: their next request queues it again.
+ f.dir.Set(subject, "member")
+ f.refreshed()
+ f.signInHome(subject)
+ if w := f.get("/day/2026-11-02"); w.Code != 200 {
+ t.Fatalf("re-added member's page = %d", w.Code)
+ }
+ q = row()
+ if q.FiredAt != nil || (q.ClaimID != nil && *q.ClaimID == dormantClaim) || q.DueAt <= time.Now().Unix()-3600 {
+ t.Fatalf("a returning member's reminder = fired %v claim %v due %d, want queued again", q.FiredAt, q.ClaimID, q.DueAt)
+ }
+ if due := f.app.store.NextDueAt(context.Background()); due.IsZero() {
+ t.Fatal("a woken reminder asks for no wake")
+ }
+}
diff --git a/internal/calendar/team_world_test.go b/internal/calendar/team_world_test.go
index 59aaa80..c780c10 100644
--- a/internal/calendar/team_world_test.go
+++ b/internal/calendar/team_world_test.go
@@ -116,11 +116,16 @@ func mustRedirect(t *testing.T, what string, w *httptest.ResponseRecorder) {
// importICS posts a one-event .ics file to the team calendar.
func (w *teamWriteWorld) importICS() *httptest.ResponseRecorder {
+ return w.importFile("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:imported-1\r\nSUMMARY:Imported\r\nDTSTART;TZID=UTC:20270111T100000\r\nDTEND;TZID=UTC:20270111T110000\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n")
+}
+
+// importFile posts ics as a file to the team calendar.
+func (w *teamWriteWorld) importFile(ics string) *httptest.ResponseRecorder {
var body bytes.Buffer
mw := multipart.NewWriter(&body)
_ = mw.WriteField("calendar_id", itoa(w.team))
fw, _ := mw.CreateFormFile("file", "in.ics")
- fmt.Fprint(fw, "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:imported-1\r\nSUMMARY:Imported\r\nDTSTART;TZID=UTC:20270111T100000\r\nDTEND;TZID=UTC:20270111T110000\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n")
+ fmt.Fprint(fw, ics)
mw.Close()
r := httptest.NewRequest("POST", homeTestOrigin+"/import", &body)
r.Header.Set("Content-Type", mw.FormDataContentType())
diff --git a/internal/calendar/templates/import_done.html b/internal/calendar/templates/import_done.html
index cf18760..3d0d362 100644
--- a/internal/calendar/templates/import_done.html
+++ b/internal/calendar/templates/import_done.html
@@ -12,7 +12,7 @@
{{$items := list
(dict "Label" "Events added" "Value" (printf "%d" .Data.Result.Created))
(dict "Label" "Skipped" "Value" (printf "%d" .Data.Result.Skipped))}}
-{{template "detail-list" dict "Items" $items}}
+{{template "detail-list" dict "Items" $items}}{{with .Data.Interrupted}}{{template "callout" dict "Tone" "warning" "Title" "The import stopped part-way" "Body" . "Alert" true}}{{end}}
{{if .Data.Result.Floating}}
{{template "callout" dict "Tone" "warning"