fix: make sure pseudo namespaces and lists always have the current user as owner
This commit is contained in:
parent
96ed1e33e3
commit
878d19beb8
1 changed files with 5 additions and 3 deletions
|
@ -335,7 +335,7 @@ func getListsForNamespaces(s *xorm.Session, namespaceIDs []int64, archived bool)
|
||||||
func getSharedListsInNamespace(s *xorm.Session, archived bool, doer *user.User) (sharedListsNamespace *NamespaceWithLists, err error) {
|
func getSharedListsInNamespace(s *xorm.Session, archived bool, doer *user.User) (sharedListsNamespace *NamespaceWithLists, err error) {
|
||||||
// Create our pseudo namespace to hold the shared lists
|
// Create our pseudo namespace to hold the shared lists
|
||||||
sharedListsPseudonamespace := SharedListsPseudoNamespace
|
sharedListsPseudonamespace := SharedListsPseudoNamespace
|
||||||
sharedListsPseudonamespace.Owner = doer
|
sharedListsPseudonamespace.OwnerID = doer.ID
|
||||||
sharedListsNamespace = &NamespaceWithLists{
|
sharedListsNamespace = &NamespaceWithLists{
|
||||||
sharedListsPseudonamespace,
|
sharedListsPseudonamespace,
|
||||||
[]*List{},
|
[]*List{},
|
||||||
|
@ -385,12 +385,13 @@ func getSharedListsInNamespace(s *xorm.Session, archived bool, doer *user.User)
|
||||||
func getFavoriteLists(s *xorm.Session, lists []*List, namespaceIDs []int64, doer *user.User) (favoriteNamespace *NamespaceWithLists, err error) {
|
func getFavoriteLists(s *xorm.Session, lists []*List, namespaceIDs []int64, doer *user.User) (favoriteNamespace *NamespaceWithLists, err error) {
|
||||||
// Create our pseudo namespace with favorite lists
|
// Create our pseudo namespace with favorite lists
|
||||||
pseudoFavoriteNamespace := FavoritesPseudoNamespace
|
pseudoFavoriteNamespace := FavoritesPseudoNamespace
|
||||||
pseudoFavoriteNamespace.Owner = doer
|
pseudoFavoriteNamespace.OwnerID = doer.ID
|
||||||
favoriteNamespace = &NamespaceWithLists{
|
favoriteNamespace = &NamespaceWithLists{
|
||||||
Namespace: pseudoFavoriteNamespace,
|
Namespace: pseudoFavoriteNamespace,
|
||||||
Lists: []*List{{}},
|
Lists: []*List{{}},
|
||||||
}
|
}
|
||||||
*favoriteNamespace.Lists[0] = FavoritesPseudoList // Copying the list to be able to modify it later
|
*favoriteNamespace.Lists[0] = FavoritesPseudoList // Copying the list to be able to modify it later
|
||||||
|
favoriteNamespace.Lists[0].Owner = doer
|
||||||
|
|
||||||
for _, list := range lists {
|
for _, list := range lists {
|
||||||
if !list.IsFavorite {
|
if !list.IsFavorite {
|
||||||
|
@ -448,7 +449,7 @@ func getSavedFilters(s *xorm.Session, doer *user.User) (savedFiltersNamespace *N
|
||||||
}
|
}
|
||||||
|
|
||||||
savedFiltersPseudoNamespace := SavedFiltersPseudoNamespace
|
savedFiltersPseudoNamespace := SavedFiltersPseudoNamespace
|
||||||
savedFiltersPseudoNamespace.Owner = doer
|
savedFiltersPseudoNamespace.OwnerID = doer.ID
|
||||||
savedFiltersNamespace = &NamespaceWithLists{
|
savedFiltersNamespace = &NamespaceWithLists{
|
||||||
Namespace: savedFiltersPseudoNamespace,
|
Namespace: savedFiltersPseudoNamespace,
|
||||||
Lists: make([]*List, 0, len(savedFilters)),
|
Lists: make([]*List, 0, len(savedFilters)),
|
||||||
|
@ -517,6 +518,7 @@ func (n *Namespace) ReadAll(s *xorm.Session, a web.Auth, search string, page int
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, 0, err
|
return nil, 0, 0, err
|
||||||
}
|
}
|
||||||
|
ownerMap[doer.ID] = doer
|
||||||
|
|
||||||
if n.NamespacesOnly {
|
if n.NamespacesOnly {
|
||||||
all := makeNamespaceSlice(namespaces, ownerMap, subscriptionsMap)
|
all := makeNamespaceSlice(namespaces, ownerMap, subscriptionsMap)
|
||||||
|
|
Loading…
Reference in a new issue