This commit is contained in:
kolaente 2021-02-13 21:07:05 +01:00
parent 5443487958
commit 76c72b31de
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
5 changed files with 9 additions and 5 deletions

View File

@ -17,8 +17,9 @@
package migration
import (
"src.techknowlogick.com/xormigrate"
"time"
"src.techknowlogick.com/xormigrate"
"xorm.io/xorm"
)

View File

@ -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.

View File

@ -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"
)

View File

@ -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
}

View File

@ -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) {