From 224fa4fd10d51e99243461f2e1573f30ca7b73d8 Mon Sep 17 00:00:00 2001 From: kolaente Date: Sun, 9 Aug 2020 17:39:42 +0200 Subject: [PATCH] Update all calls to CanRead methods --- pkg/models/label_task.go | 2 +- pkg/models/link_sharing.go | 2 +- pkg/models/list_duplicate.go | 2 +- pkg/models/list_team.go | 2 +- pkg/models/list_users.go | 2 +- pkg/models/namespace_team.go | 2 +- pkg/models/namespace_users.go | 2 +- pkg/models/task_assignees.go | 4 ++-- pkg/models/task_collection.go | 2 +- pkg/models/task_comments.go | 2 +- pkg/models/task_relation_rights.go | 2 +- pkg/modules/background/handler/background.go | 2 +- pkg/routes/api/v1/list_by_namespace.go | 2 +- pkg/routes/api/v1/task_attachment.go | 2 +- pkg/routes/api/v1/user_list.go | 2 +- pkg/routes/caldav/listStorageProvider.go | 2 +- 16 files changed, 17 insertions(+), 17 deletions(-) diff --git a/pkg/models/label_task.go b/pkg/models/label_task.go index 181cea390..86d2cb6e2 100644 --- a/pkg/models/label_task.go +++ b/pkg/models/label_task.go @@ -113,7 +113,7 @@ func (lt *LabelTask) Create(a web.Auth) (err error) { func (lt *LabelTask) ReadAll(a web.Auth, search string, page int, perPage int) (result interface{}, resultCount int, numberOfTotalItems int64, err error) { // Check if the user has the right to see the task task := Task{ID: lt.TaskID} - canRead, err := task.CanRead(a) + canRead, _, err := task.CanRead(a) if err != nil { return nil, 0, 0, err } diff --git a/pkg/models/link_sharing.go b/pkg/models/link_sharing.go index e0a59cd25..2849fb012 100644 --- a/pkg/models/link_sharing.go +++ b/pkg/models/link_sharing.go @@ -153,7 +153,7 @@ func (share *LinkSharing) ReadOne() (err error) { // @Router /lists/{list}/shares [get] func (share *LinkSharing) ReadAll(a web.Auth, search string, page int, perPage int) (result interface{}, resultCount int, totalItems int64, err error) { list := &List{ID: share.ListID} - can, err := list.CanRead(a) + can, _, err := list.CanRead(a) if err != nil { return nil, 0, 0, err } diff --git a/pkg/models/list_duplicate.go b/pkg/models/list_duplicate.go index 7a70fd912..ed263ed65 100644 --- a/pkg/models/list_duplicate.go +++ b/pkg/models/list_duplicate.go @@ -41,7 +41,7 @@ type ListDuplicate struct { func (ld *ListDuplicate) CanCreate(a web.Auth) (canCreate bool, err error) { // List Exists + user has read access to list ld.List = &List{ID: ld.ListID} - canRead, err := ld.List.CanRead(a) + canRead, _, err := ld.List.CanRead(a) if err != nil || !canRead { return canRead, err } diff --git a/pkg/models/list_team.go b/pkg/models/list_team.go index 81d0c259d..47816b6d2 100644 --- a/pkg/models/list_team.go +++ b/pkg/models/list_team.go @@ -168,7 +168,7 @@ func (tl *TeamList) Delete() (err error) { func (tl *TeamList) ReadAll(a web.Auth, search string, page int, perPage int) (result interface{}, resultCount int, totalItems int64, err error) { // Check if the user can read the namespace l := &List{ID: tl.ListID} - canRead, err := l.CanRead(a) + canRead, _, err := l.CanRead(a) if err != nil { return nil, 0, 0, err } diff --git a/pkg/models/list_users.go b/pkg/models/list_users.go index 89bd542e9..4c2f8afa0 100644 --- a/pkg/models/list_users.go +++ b/pkg/models/list_users.go @@ -174,7 +174,7 @@ func (lu *ListUser) Delete() (err error) { func (lu *ListUser) ReadAll(a web.Auth, search string, page int, perPage int) (result interface{}, resultCount int, numberOfTotalItems int64, err error) { // Check if the user has access to the list l := &List{ID: lu.ListID} - canRead, err := l.CanRead(a) + canRead, _, err := l.CanRead(a) if err != nil { return nil, 0, 0, err } diff --git a/pkg/models/namespace_team.go b/pkg/models/namespace_team.go index fe14b4ce5..cb69d92c0 100644 --- a/pkg/models/namespace_team.go +++ b/pkg/models/namespace_team.go @@ -153,7 +153,7 @@ func (tn *TeamNamespace) Delete() (err error) { func (tn *TeamNamespace) ReadAll(a web.Auth, search string, page int, perPage int) (result interface{}, resultCount int, numberOfTotalItems int64, err error) { // Check if the user can read the namespace n := Namespace{ID: tn.NamespaceID} - canRead, err := n.CanRead(a) + canRead, _, err := n.CanRead(a) if err != nil { return nil, 0, 0, err } diff --git a/pkg/models/namespace_users.go b/pkg/models/namespace_users.go index 115bc81dc..3e5c4ffe3 100644 --- a/pkg/models/namespace_users.go +++ b/pkg/models/namespace_users.go @@ -160,7 +160,7 @@ func (nu *NamespaceUser) Delete() (err error) { func (nu *NamespaceUser) ReadAll(a web.Auth, search string, page int, perPage int) (result interface{}, resultCount int, numberOfTotalItems int64, err error) { // Check if the user has access to the namespace l := Namespace{ID: nu.NamespaceID} - canRead, err := l.CanRead(a) + canRead, _, err := l.CanRead(a) if err != nil { return nil, 0, 0, err } diff --git a/pkg/models/task_assignees.go b/pkg/models/task_assignees.go index f762d7b6d..f74f50dab 100644 --- a/pkg/models/task_assignees.go +++ b/pkg/models/task_assignees.go @@ -207,7 +207,7 @@ func (t *Task) addNewAssigneeByID(newAssigneeID int64, list *List) (err error) { if err != nil { return err } - canRead, err := list.CanRead(newAssignee) + canRead, _, err := list.CanRead(newAssignee) if err != nil { return err } @@ -247,7 +247,7 @@ func (la *TaskAssginee) ReadAll(a web.Auth, search string, page int, perPage int return nil, 0, 0, err } - can, err := task.CanRead(a) + can, _, err := task.CanRead(a) if err != nil { return nil, 0, 0, err } diff --git a/pkg/models/task_collection.go b/pkg/models/task_collection.go index 19b32a112..082b2f378 100644 --- a/pkg/models/task_collection.go +++ b/pkg/models/task_collection.go @@ -166,7 +166,7 @@ func (tf *TaskCollection) ReadAll(a web.Auth, search string, page int, perPage i } else { // Check the list exists and the user has acess on it list := &List{ID: tf.ListID} - canRead, err := list.CanRead(a) + canRead, _, err := list.CanRead(a) if err != nil { return nil, 0, 0, err } diff --git a/pkg/models/task_comments.go b/pkg/models/task_comments.go index 98658dc45..568a5fe59 100644 --- a/pkg/models/task_comments.go +++ b/pkg/models/task_comments.go @@ -165,7 +165,7 @@ func (tc *TaskComment) ReadOne() (err error) { func (tc *TaskComment) ReadAll(auth web.Auth, search string, page int, perPage int) (result interface{}, resultCount int, numberOfTotalItems int64, err error) { // Check if the user has access to the task - canRead, err := tc.CanRead(auth) + canRead, _, err := tc.CanRead(auth) if err != nil { return nil, 0, 0, err } diff --git a/pkg/models/task_relation_rights.go b/pkg/models/task_relation_rights.go index 5239b2846..ca4e00b7a 100644 --- a/pkg/models/task_relation_rights.go +++ b/pkg/models/task_relation_rights.go @@ -42,7 +42,7 @@ func (rel *TaskRelation) CanCreate(a web.Auth) (bool, error) { // We explicitly don't check if the two tasks are on the same list. otherTask := &Task{ID: rel.OtherTaskID} - has, err = otherTask.CanRead(a) + has, _, err = otherTask.CanRead(a) if err != nil { return false, err } diff --git a/pkg/modules/background/handler/background.go b/pkg/modules/background/handler/background.go index c4a462e6f..9c482ab1d 100644 --- a/pkg/modules/background/handler/background.go +++ b/pkg/modules/background/handler/background.go @@ -191,7 +191,7 @@ func GetListBackground(c echo.Context) error { // Check if a background for this list exists + Rights list := &models.List{ID: listID} - can, err := list.CanRead(auth) + can, _, err := list.CanRead(auth) if err != nil { return handler.HandleHTTPError(err, c) } diff --git a/pkg/routes/api/v1/list_by_namespace.go b/pkg/routes/api/v1/list_by_namespace.go index b103ff59e..3142b1d98 100644 --- a/pkg/routes/api/v1/list_by_namespace.go +++ b/pkg/routes/api/v1/list_by_namespace.go @@ -79,7 +79,7 @@ func getNamespace(c echo.Context) (namespace *models.Namespace, err error) { return } namespace = &models.Namespace{ID: namespaceID} - canRead, err := namespace.CanRead(user) + canRead, _, err := namespace.CanRead(user) if err != nil { return namespace, err } diff --git a/pkg/routes/api/v1/task_attachment.go b/pkg/routes/api/v1/task_attachment.go index 95fc7d368..b524408ee 100644 --- a/pkg/routes/api/v1/task_attachment.go +++ b/pkg/routes/api/v1/task_attachment.go @@ -119,7 +119,7 @@ func GetTaskAttachment(c echo.Context) error { if err != nil { return handler.HandleHTTPError(err, c) } - can, err := taskAttachment.CanRead(auth) + can, _, err := taskAttachment.CanRead(auth) if err != nil { return handler.HandleHTTPError(err, c) } diff --git a/pkg/routes/api/v1/user_list.go b/pkg/routes/api/v1/user_list.go index ad22d5697..1f9061deb 100644 --- a/pkg/routes/api/v1/user_list.go +++ b/pkg/routes/api/v1/user_list.go @@ -78,7 +78,7 @@ func ListUsersForList(c echo.Context) error { return handler.HandleHTTPError(err, c) } - canRead, err := list.CanRead(auth) + canRead, _, err := list.CanRead(auth) if err != nil { return handler.HandleHTTPError(err, c) } diff --git a/pkg/routes/caldav/listStorageProvider.go b/pkg/routes/caldav/listStorageProvider.go index 7691a321e..1abc683d0 100644 --- a/pkg/routes/caldav/listStorageProvider.go +++ b/pkg/routes/caldav/listStorageProvider.go @@ -383,7 +383,7 @@ func (vlra *VikunjaListResourceAdapter) GetModTime() time.Time { } func (vcls *VikunjaCaldavListStorage) getListRessource(isCollection bool) (rr VikunjaListResourceAdapter, err error) { - can, err := vcls.list.CanRead(vcls.user) + can, _, err := vcls.list.CanRead(vcls.user) if err != nil { return }