|
|
|
@ -41,8 +41,6 @@ type VikunjaCaldavListStorage struct {
|
|
|
|
|
// The current user
|
|
|
|
|
user *models.User
|
|
|
|
|
isPrincipal bool
|
|
|
|
|
// A hack to give out the etag of a task instead of the list when asked, to let it properly update a task
|
|
|
|
|
isUpdatingATask bool
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetResources returns either all lists, links to the principal, or only one list, depending on the request
|
|
|
|
@ -52,9 +50,8 @@ func (vcls *VikunjaCaldavListStorage) GetResources(rpath string, withChildren bo
|
|
|
|
|
// If the request wants the principal url, we'll return that and nothing else
|
|
|
|
|
if vcls.isPrincipal {
|
|
|
|
|
r := data.NewResource(DavBasePath+`/lists`, &VikunjaListResourceAdapter{
|
|
|
|
|
isPrincipal: true,
|
|
|
|
|
isCollection: true,
|
|
|
|
|
isUpdatingATask: vcls.isUpdatingATask,
|
|
|
|
|
isPrincipal: true,
|
|
|
|
|
isCollection: true,
|
|
|
|
|
})
|
|
|
|
|
return []data.Resource{r}, nil
|
|
|
|
|
}
|
|
|
|
@ -81,9 +78,8 @@ func (vcls *VikunjaCaldavListStorage) GetResources(rpath string, withChildren bo
|
|
|
|
|
var resources []data.Resource
|
|
|
|
|
for _, l := range lists {
|
|
|
|
|
rr := VikunjaListResourceAdapter{
|
|
|
|
|
list: l,
|
|
|
|
|
isCollection: true,
|
|
|
|
|
isUpdatingATask: vcls.isUpdatingATask,
|
|
|
|
|
list: l,
|
|
|
|
|
isCollection: true,
|
|
|
|
|
}
|
|
|
|
|
r := data.NewResource(ListBasePath+"/"+strconv.FormatInt(l.ID, 10), &rr)
|
|
|
|
|
r.Name = l.Title
|
|
|
|
@ -137,10 +133,9 @@ func (vcls *VikunjaCaldavListStorage) GetResourcesByFilters(rpath string, filter
|
|
|
|
|
var resources []data.Resource
|
|
|
|
|
for _, t := range vcls.list.Tasks {
|
|
|
|
|
rr := VikunjaListResourceAdapter{
|
|
|
|
|
list: vcls.list,
|
|
|
|
|
task: t,
|
|
|
|
|
isCollection: false,
|
|
|
|
|
isUpdatingATask: vcls.isUpdatingATask,
|
|
|
|
|
list: vcls.list,
|
|
|
|
|
task: t,
|
|
|
|
|
isCollection: false,
|
|
|
|
|
}
|
|
|
|
|
r := data.NewResource(getTaskURL(t), &rr)
|
|
|
|
|
r.Name = t.Text
|
|
|
|
@ -186,18 +181,9 @@ func (vcls *VikunjaCaldavListStorage) GetResource(rpath string) (*data.Resource,
|
|
|
|
|
vcls.task.Updated = updated
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Also get the when updating since we'll need that for later checks
|
|
|
|
|
if vcls.isUpdatingATask {
|
|
|
|
|
err = vcls.list.GetSimpleByID()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, false, err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rr := VikunjaListResourceAdapter{
|
|
|
|
|
list: vcls.list,
|
|
|
|
|
task: &task,
|
|
|
|
|
isUpdatingATask: vcls.isUpdatingATask,
|
|
|
|
|
list: vcls.list,
|
|
|
|
|
task: &task,
|
|
|
|
|
}
|
|
|
|
|
r := data.NewResource(rpath, &rr)
|
|
|
|
|
return &r, true, nil
|
|
|
|
@ -249,9 +235,8 @@ func (vcls *VikunjaCaldavListStorage) CreateResource(rpath, content string) (*da
|
|
|
|
|
|
|
|
|
|
// Build up the proper response
|
|
|
|
|
rr := VikunjaListResourceAdapter{
|
|
|
|
|
list: vcls.list,
|
|
|
|
|
task: vTask,
|
|
|
|
|
isUpdatingATask: vcls.isUpdatingATask,
|
|
|
|
|
list: vcls.list,
|
|
|
|
|
task: vTask,
|
|
|
|
|
}
|
|
|
|
|
r := data.NewResource(rpath, &rr)
|
|
|
|
|
return &r, nil
|
|
|
|
@ -286,9 +271,8 @@ func (vcls *VikunjaCaldavListStorage) UpdateResource(rpath, content string) (*da
|
|
|
|
|
|
|
|
|
|
// Build up the proper response
|
|
|
|
|
rr := VikunjaListResourceAdapter{
|
|
|
|
|
list: vcls.list,
|
|
|
|
|
task: vTask,
|
|
|
|
|
isUpdatingATask: vcls.isUpdatingATask,
|
|
|
|
|
list: vcls.list,
|
|
|
|
|
task: vTask,
|
|
|
|
|
}
|
|
|
|
|
r := data.NewResource(rpath, &rr)
|
|
|
|
|
return &r, nil
|
|
|
|
@ -318,9 +302,8 @@ type VikunjaListResourceAdapter struct {
|
|
|
|
|
list *models.List
|
|
|
|
|
task *models.ListTask
|
|
|
|
|
|
|
|
|
|
isPrincipal bool
|
|
|
|
|
isCollection bool
|
|
|
|
|
isUpdatingATask bool
|
|
|
|
|
isPrincipal bool
|
|
|
|
|
isCollection bool
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// IsCollection checks if the resoure in the adapter is a collection
|
|
|
|
@ -338,9 +321,9 @@ func (vlra *VikunjaListResourceAdapter) CalculateEtag() string {
|
|
|
|
|
// And therefore, updating the task fails since these etags don't match.
|
|
|
|
|
// To fix that, we use this extra field to determine if we're currently updating a task and return the
|
|
|
|
|
// etag of the list instead.
|
|
|
|
|
if vlra.isUpdatingATask && vlra.list != nil {
|
|
|
|
|
return `"` + strconv.FormatInt(vlra.list.ID, 10) + `-` + strconv.FormatInt(vlra.list.Updated, 10) + `"`
|
|
|
|
|
}
|
|
|
|
|
//if vlra.list != nil {
|
|
|
|
|
// return `"` + strconv.FormatInt(vlra.list.ID, 10) + `-` + strconv.FormatInt(vlra.list.Updated, 10) + `"`
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
// Return the etag of a task if we have one
|
|
|
|
|
if vlra.task != nil {
|
|
|
|
@ -401,9 +384,8 @@ func (vcls *VikunjaCaldavListStorage) getListRessource(isCollection bool) (rr Vi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rr = VikunjaListResourceAdapter{
|
|
|
|
|
list: vcls.list,
|
|
|
|
|
isCollection: isCollection,
|
|
|
|
|
isUpdatingATask: vcls.isUpdatingATask,
|
|
|
|
|
list: vcls.list,
|
|
|
|
|
isCollection: isCollection,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|