canEditInCollection is requireEditPermission's decision without the response, for callers that report per row (bulk) rather than per request. An editor or owner ROLE applies only inside the collections the member's access reaches (TASK-3376, PR #1756). Before it, the role short-circuited before the
(r *http.Request, workspaceID, itemID, collectionID string)
| 4103 | // could edit it, comment on it and create beside it. Outside their reach the |
| 4104 | // grant decides, through ResolveUserPermission, and only 'edit' writes. |
| 4105 | func (s *Server) canEditInCollection(r *http.Request, workspaceID, itemID, collectionID string) (bool, error) { |
| 4106 | role := workspaceRole(r) |
| 4107 | if role != "guest" && requireRole(r, "editor") { |
| 4108 | reaches, err := s.editorRoleReaches(r, workspaceID, collectionID) |
| 4109 | if err != nil { |
| 4110 | return false, err |
| 4111 | } |
| 4112 | if reaches { |
| 4113 | return true, nil |
| 4114 | } |
| 4115 | } |
| 4116 | |
| 4117 | // Guests, viewers, and editors outside their collection access: the |
| 4118 | // grant cascade decides. |
| 4119 | user := currentUser(r) |
| 4120 | if user == nil { |
| 4121 | return false, nil |
| 4122 | } |
| 4123 | perm, err := s.store.ResolveUserPermission(workspaceID, user.ID, itemID, collectionID) |
| 4124 | if err != nil { |
| 4125 | return false, err |
| 4126 | } |
| 4127 | return permissionLevel(perm) >= permissionLevel("edit"), nil |
| 4128 | } |
| 4129 | |
| 4130 | // editorRoleReaches reports whether the caller's editor/owner role applies to |
| 4131 | // collectionID: always for a member with 'all' collection access, and for a |
no test coverage detected