Added more props to caldav todos
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
konrad 2019-05-12 12:51:52 +02:00
parent 7136a037c5
commit 8972e34960
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
4 changed files with 91 additions and 5 deletions

View File

@ -195,6 +195,7 @@ Sorry for some of them being in German, I'll tranlate them at some point.
* [ ] Check if only needed things are queried from the db when accessing dav (for ex. no need to get all tasks when we actually only need the title)
* [x] Fix OPTIONS Requests to the rest of the api being broken
* [ ] Parse all props defined in rfc5545
* [ ] COMPLETED -> Need to actually save the time the task was completed
* [ ] Tests
### Refactor

View File

@ -0,0 +1,53 @@
---
date: "2019-05-12:00:00+01:00"
title: "Caldav"
draft: false
type: "doc"
menu:
sidebar:
parent: "usage"
---
# Caldav
Vikunja supports managing tasks via the [caldav VTODO](https://tools.ietf.org/html/rfc5545#section-3.6.2) extension.
## URLs
// TODO
## Supported properties
Vikunja currently supports the following properties:
* `UID`
* `SUMMARY`
* `DESCRIPTION`
* `PRIORITY`
* `COMPLETED`
* `DUE`
* `DTSTART`
* `DURATION`
* `ORGANIZER`
* `RELATED-TO`
* `CREATED`
* `DTSTAMP`
* `LAST-MODIFIED`
Vikunja **does currently not** support these properties:
* `ATTACH`
* `CATEGORIES`
* `CLASS`
* `COMMENT`
* `GEO`
* `LOCATION`
* `PERCENT-COMPLETE`
* `RESOURCES`
* `STATUS`
* `CONTACT`
* `RECURRENCE-ID`
* `URL`
* Recurrence
* `SEQUENCE`

View File

@ -19,6 +19,7 @@ package caldav
import (
"code.vikunja.io/api/pkg/models"
"code.vikunja.io/api/pkg/utils"
"fmt"
"strconv"
"time"
)
@ -47,9 +48,12 @@ type Todo struct {
CompletedUnix int64
Organizer *models.User
Priority int64 // 0-9, 1 is highest
RelatedToUID string
StartUnix int64
EndUnix int64
StartUnix int64
EndUnix int64
DueDateUnix int64
Duration time.Duration
CreatedUnix int64
UpdatedUnix int64 // last-mod
@ -147,6 +151,26 @@ COMPLETED: ` + makeCalDavTimeFromUnixTime(t.CompletedUnix)
ORGANIZER;CN=:` + t.Organizer.Username
}
if t.RelatedToUID != "" {
caldavtodos += `
RELATED-TO:` + t.RelatedToUID
}
if t.DueDateUnix != 0 {
caldavtodos += `
DUE:` + makeCalDavTimeFromUnixTime(t.DueDateUnix)
}
if t.CreatedUnix != 0 {
caldavtodos += `
CREATED:` + makeCalDavTimeFromUnixTime(t.CreatedUnix)
}
if t.Duration != 0 {
caldavtodos += `
DURATION:PT` + fmt.Sprintf("%.6f", t.Duration.Hours()) + `H` + fmt.Sprintf("%.6f", t.Duration.Minutes()) + `M` + fmt.Sprintf("%.6f", t.Duration.Seconds()) + `S`
}
caldavtodos += `
PRIORITY:` + strconv.Itoa(int(t.Priority))

View File

@ -82,9 +82,17 @@ func parseTaskFromVTODO(content string) (vTask *models.ListTask, err error) {
// FIXME: add more values to tasks
// @see https://tools.ietf.org/html/rfc5545#section-3.8
vTask = &models.ListTask{
Text: task["SUMMARY"],
Priority: priority,
UID: task["UID"],
Text: task["SUMMARY"],
Description: task["DESCRIPTION"],
Priority: priority,
UID: task["UID"],
//DueDateUnix: task["DUE"],
//COMPLETED (datetime)
//StartDateUnix: task["DTSTART"]
// DURATION (startdate - enddate)
// DTSTAMP (last modified)
}
return