Download this file
| 1 | package sheets |
| 2 | |
| 3 | import ( |
| 4 | "amadan.net/oficina/home/roster" |
| 5 | "context" |
| 6 | ) |
| 7 | |
| 8 | // Check standing after the last permission query. An independent grant may |
| 9 | // remain valid while the list's team-wide authority expires during that read. |
| 10 | func (a *sheetAgent) checkVisible(ctx context.Context, state *sheetAgentContext, fresh Member) error { |
| 11 | for id := range state.sheets { |
| 12 | role, err := a.role(ctx, a.app.db, id, fresh) |
| 13 | if err != nil { |
| 14 | return err |
| 15 | } |
| 16 | need := SheetViewer |
| 17 | if state.edits[id] { |
| 18 | need = SheetEditor |
| 19 | } |
| 20 | if !role.Allows(need) { |
| 21 | return errNoAccess |
| 22 | } |
| 23 | } |
| 24 | if state.list && a.app.team != nil && fresh.team.state() == roster.Unknown { |
| 25 | return errTeamUnavailable |
| 26 | } |
| 27 | return nil |
| 28 | } |
| 29 | |