vikunja-api/pkg/models/list_users_readall.go

23 lines
520 B
Go
Raw Normal View History

package models
// ReadAll gets all users who have access to a list
2018-10-31 13:42:38 +01:00
func (ul *ListUser) ReadAll(u *User) (interface{}, error) {
// Check if the user has access to the list
l := &List{ID: ul.ListID}
if err := l.GetSimpleByID(); err != nil {
return nil, err
}
2018-10-31 13:42:38 +01:00
if !l.CanRead(u) {
return nil, ErrNeedToHaveListReadAccess{}
}
// Get all users
all := []*userWithRight{}
err := x.
Join("INNER", "users_list", "user_id = users.id").
Where("users_list.list_id = ?", ul.ListID).
Find(&all)
return all, err
}