diff --git a/pkg/migration/20210209204715.go b/pkg/migration/20210209204715.go index 7b16357c8..1bca9e508 100644 --- a/pkg/migration/20210209204715.go +++ b/pkg/migration/20210209204715.go @@ -17,8 +17,9 @@ package migration import ( - "src.techknowlogick.com/xormigrate" "time" + + "src.techknowlogick.com/xormigrate" "xorm.io/xorm" ) diff --git a/pkg/models/list.go b/pkg/models/list.go index 20636059c..0db32e7be 100644 --- a/pkg/models/list.go +++ b/pkg/models/list.go @@ -241,7 +241,7 @@ func (l *List) ReadOne(s *xorm.Session, a web.Auth) (err error) { } l.Subscription, err = getSubscription(s, SubscriptionEntityList, l.ID, a) - return nil + return } // GetListSimpleByID gets a list with only the basic items, aka no tasks or user objects. Returns an error if the list does not exist. diff --git a/pkg/models/subscription.go b/pkg/models/subscription.go index 0a4dd5554..cf6e44a93 100644 --- a/pkg/models/subscription.go +++ b/pkg/models/subscription.go @@ -17,9 +17,10 @@ package models import ( + "time" + "code.vikunja.io/api/pkg/user" "code.vikunja.io/web" - "time" "xorm.io/builder" "xorm.io/xorm" ) diff --git a/pkg/models/subscription_rights.go b/pkg/models/subscription_rights.go index 72e43ecfd..10c6c030b 100644 --- a/pkg/models/subscription_rights.go +++ b/pkg/models/subscription_rights.go @@ -21,6 +21,7 @@ import ( "xorm.io/xorm" ) +// CanCreate checks if a user can subscribe to an entity func (sb *Subscription) CanCreate(s *xorm.Session, a web.Auth) (can bool, err error) { if _, is := a.(*LinkSharing); is { return false, &ErrGenericForbidden{} @@ -45,6 +46,7 @@ func (sb *Subscription) CanCreate(s *xorm.Session, a web.Auth) (can bool, err er return } +// CanDelete checks if a user can delete a subscription func (sb *Subscription) CanDelete(s *xorm.Session, a web.Auth) (can bool, err error) { if _, is := a.(*LinkSharing); is { return false, &ErrGenericForbidden{} @@ -59,7 +61,6 @@ func (sb *Subscription) CanDelete(s *xorm.Session, a web.Auth) (can bool, err er if err != nil { return false, err } - // TODO: Return a 404 if the subscription does not exist return realSb.UserID == a.GetID(), nil } diff --git a/pkg/models/subscription_test.go b/pkg/models/subscription_test.go index 3803524ab..e0f5c1a21 100644 --- a/pkg/models/subscription_test.go +++ b/pkg/models/subscription_test.go @@ -17,10 +17,11 @@ package models import ( + "testing" + "code.vikunja.io/api/pkg/db" "code.vikunja.io/api/pkg/user" "github.com/stretchr/testify/assert" - "testing" ) func TestSubscriptionGetTypeFromString(t *testing.T) {