From 88b9ea6a968943f745943cfb4fce524690789d3f Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 26 May 2021 11:04:29 +0200 Subject: [PATCH] Fix error when searching for a namespace with subscribers --- pkg/models/namespace.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/models/namespace.go b/pkg/models/namespace.go index ebe5cd14..97a6fe9e 100644 --- a/pkg/models/namespace.go +++ b/pkg/models/namespace.go @@ -291,6 +291,11 @@ func getNamespaceOwnerIDs(namespaces map[int64]*NamespaceWithLists) (namespaceID } func getNamespaceSubscriptions(s *xorm.Session, namespaceIDs []int64, userID int64) (map[int64]*Subscription, error) { + subscriptionsMap := make(map[int64]*Subscription) + if len(namespaceIDs) == 0 { + return subscriptionsMap, nil + } + subscriptions := []*Subscription{} err := s. Where("entity_type = ? AND user_id = ?", SubscriptionEntityNamespace, userID). @@ -299,7 +304,6 @@ func getNamespaceSubscriptions(s *xorm.Session, namespaceIDs []int64, userID int if err != nil { return nil, err } - subscriptionsMap := make(map[int64]*Subscription) for _, sub := range subscriptions { sub.Entity = sub.EntityType.String() subscriptionsMap[sub.EntityID] = sub