fix(projects): don't try to share for nonexisting namespace

This commit is contained in:
kolaente 2023-06-05 18:12:12 +02:00
parent 50b0d3f95c
commit d758bdc5e2
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 11 additions and 0 deletions

View File

@ -17,6 +17,7 @@
package migration
import (
"code.vikunja.io/api/pkg/log"
"time"
"src.techknowlogick.com/xormigrate"
@ -245,6 +246,11 @@ func setTeamNamespacesShare(tx *xorm.Engine, namespacesToProjects map[int64]*pro
}
for _, tn := range teamNamespaces {
if _, exists := namespacesToProjects[tn.NamespaceID]; !exists {
log.Warningf("Namespace %d does not exist but is shared with team %d - this is probably caused by an old share which was not properly deleted.", tn.NamespaceID, tn.TeamID)
continue
}
_, err = tx.Insert(&teamProject20221228112131{
TeamID: tn.TeamID,
Right: tn.Right,
@ -268,6 +274,11 @@ func setUserNamespacesShare(tx *xorm.Engine, namespacesToProjects map[int64]*pro
}
for _, un := range userNamespace {
if _, exists := namespacesToProjects[un.NamespaceID]; !exists {
log.Warningf("Namespace %d does not exist but is shared with user %d - this is probably caused by an old share which was not properly deleted.", un.NamespaceID, un.UserID)
continue
}
_, err = tx.Insert(&projectUser20221228112131{
UserID: un.UserID,
Right: un.Right,