package wire import "strings" // Placement binds visible labels to repository choices. NewRepo is proposed, // never created by asking the question. type Placement struct { NewFirst bool `json:"new_first,omitempty"` Repos []string `json:"repos"` NewRepo string `json:"new_repo,omitempty"` } // MoveTask is an owner's revision-checked project correction. type MoveTask struct { Abandon bool `json:"abandon,omitempty"` NewProject bool `json:"new_project,omitempty"` Repo string `json:"repo"` Revision int64 `json:"revision"` } const MaxPlacementNotes = 16 // PersonalNotes excludes the separate, system-owned correction slot. func PersonalNotes(entries []NotebookEntry) []NotebookEntry { out := []NotebookEntry{} for _, e := range entries { if e.Source != NoteSystem && !(e.Source == NoteOwn && strings.HasPrefix(e.ID, "mv")) { out = append(out, e) } } return out } func BoundedPlacementNotes(entries []NotebookEntry) []NotebookEntry { out := []NotebookEntry{} for _, e := range entries { if e.Source != NoteSystem || !strings.HasPrefix(e.ID, "mv") || len(e.Text) > MaxEntryBytes { continue } found := false for i, old := range out { if old.ID == e.ID { out[i] = e found = true break } } if !found { out = append(out, e) } } if len(out) > MaxPlacementNotes { out = out[len(out)-MaxPlacementNotes:] } return out } // MergePlacementNotes replaces the correction slot with the server snapshot. // Personal entries keep their independent count and byte bounds. func MergePlacementNotes(entries, corrections []NotebookEntry) []NotebookEntry { return append(PersonalNotes(entries), BoundedPlacementNotes(corrections)...) }