From 4cfd62cddf509c184012a13f84986e3e15082717 Mon Sep 17 00:00:00 2001 From: Gusted Date: Wed, 9 Feb 2022 21:19:48 +0100 Subject: [PATCH] Let return correct perm (#18675) (#18689) Backport of #18675 --- models/unit/unit.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/models/unit/unit.go b/models/unit/unit.go index eb71276786..a6a47eb1f3 100644 --- a/models/unit/unit.go +++ b/models/unit/unit.go @@ -328,7 +328,12 @@ func AllUnitKeyNames() []string { // MinUnitAccessMode returns the minial permission of the permission map func MinUnitAccessMode(unitsMap map[Type]perm.AccessMode) perm.AccessMode { res := perm.AccessModeNone - for _, mode := range unitsMap { + for t, mode := range unitsMap { + // Don't allow `TypeExternal{Tracker,Wiki}` to influence this as they can only be set to READ perms. + if t == TypeExternalTracker || t == TypeExternalWiki { + continue + } + // get the minial permission great than AccessModeNone except all are AccessModeNone if mode > perm.AccessModeNone && (res == perm.AccessModeNone || mode < res) { res = mode