Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added expand request #167

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ image: alpine/edge
packages:
- go
sources:
- https://github.com/emersion/go-webdav
- https://github.com/jonyTF/go-webdav
tasks:
- test: |
cd go-webdav
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# go-webdav

[![Go Reference](https://pkg.go.dev/badge/github.com/emersion/go-webdav.svg)](https://pkg.go.dev/github.com/emersion/go-webdav)
[![Go Reference](https://pkg.go.dev/badge/github.com/jonyTF/go-webdav.svg)](https://pkg.go.dev/github.com/jonyTF/go-webdav)

A Go library for [WebDAV], [CalDAV] and [CardDAV].

Expand Down
10 changes: 8 additions & 2 deletions caldav/caldav.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"time"

"github.com/emersion/go-ical"
"github.com/emersion/go-webdav"
"github.com/emersion/go-webdav/internal"
"github.com/jonyTF/go-webdav"
"github.com/jonyTF/go-webdav/internal"
)

var CapabilityCalendar = webdav.Capability("calendar-access")
Expand Down Expand Up @@ -79,6 +79,12 @@ type CalendarCompRequest struct {

AllComps bool
Comps []CalendarCompRequest

Expand *CalendarExpandRequest
}

type CalendarExpandRequest struct {
Start, End time.Time
}

type CompFilter struct {
Expand Down
19 changes: 16 additions & 3 deletions caldav/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"time"

"github.com/emersion/go-ical"
"github.com/emersion/go-webdav"
"github.com/emersion/go-webdav/internal"
"github.com/jonyTF/go-webdav"
"github.com/jonyTF/go-webdav/internal"
)

// DiscoverContextURL performs a DNS-based CardDAV service discovery as
Expand Down Expand Up @@ -154,7 +154,9 @@ func encodeCalendarReq(c *CalendarCompRequest) (*internal.Prop, error) {
return nil, err
}

calDataReq := calendarDataReq{Comp: compReq}
expandReq := encodeExpandRequest(c.Expand)

calDataReq := calendarDataReq{Comp: compReq, Expand: expandReq}

getLastModReq := internal.NewRawXMLElement(internal.GetLastModifiedName, nil, nil)
getETagReq := internal.NewRawXMLElement(internal.GetETagName, nil, nil)
Expand All @@ -175,6 +177,17 @@ func encodeCompFilter(filter *CompFilter) *compFilter {
return &encoded
}

func encodeExpandRequest(e *CalendarExpandRequest) *expand {
if e == nil {
return nil
}
encoded := expand{
Start: dateWithUTCTime(e.Start),
End: dateWithUTCTime(e.End),
}
return &encoded
}

func decodeCalendarObjectList(ms *internal.MultiStatus) ([]CalendarObject, error) {
addrs := make([]CalendarObject, 0, len(ms.Responses))
for _, resp := range ms.Responses {
Expand Down
11 changes: 9 additions & 2 deletions caldav/elements.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"time"

"github.com/emersion/go-webdav/internal"
"github.com/jonyTF/go-webdav/internal"
)

const namespace = "urn:ietf:params:xml:ns:caldav"
Expand Down Expand Up @@ -179,7 +179,8 @@ func (t *dateWithUTCTime) MarshalText() ([]byte, error) {
type calendarDataReq struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:caldav calendar-data"`
Comp *comp `xml:"comp,omitempty"`
// TODO: expand, limit-recurrence-set, limit-freebusy-set
Expand *expand `xml:"expand,omitempty"`
// TODO: limit-recurrence-set, limit-freebusy-set
}

// https://tools.ietf.org/html/rfc4791#section-9.6.1
Expand All @@ -194,6 +195,12 @@ type comp struct {
Comp []comp `xml:"comp,omitempty"`
}

type expand struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:caldav expand"`
Start dateWithUTCTime `xml:"start,attr"`
End dateWithUTCTime `xml:"end,attr"`
}

// https://tools.ietf.org/html/rfc4791#section-9.6.4
type prop struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:caldav prop"`
Expand Down
4 changes: 2 additions & 2 deletions caldav/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"time"

"github.com/emersion/go-ical"
"github.com/emersion/go-webdav"
"github.com/emersion/go-webdav/internal"
"github.com/jonyTF/go-webdav"
"github.com/jonyTF/go-webdav/internal"
)

// TODO if nothing more Caldav-specific needs to be added this should be merged with carddav.PutAddressObjectOptions
Expand Down
4 changes: 2 additions & 2 deletions carddav/carddav.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"time"

"github.com/emersion/go-vcard"
"github.com/emersion/go-webdav"
"github.com/emersion/go-webdav/internal"
"github.com/jonyTF/go-webdav"
"github.com/jonyTF/go-webdav/internal"
)

var CapabilityAddressBook = webdav.Capability("addressbook")
Expand Down
2 changes: 1 addition & 1 deletion carddav/carddav_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"testing"

"github.com/emersion/go-vcard"
"github.com/emersion/go-webdav"
"github.com/jonyTF/go-webdav"
)

type testBackend struct {
Expand Down
4 changes: 2 additions & 2 deletions carddav/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"time"

"github.com/emersion/go-vcard"
"github.com/emersion/go-webdav"
"github.com/emersion/go-webdav/internal"
"github.com/jonyTF/go-webdav"
"github.com/jonyTF/go-webdav/internal"
)

// DiscoverContextURL performs a DNS-based CardDAV service discovery as
Expand Down
2 changes: 1 addition & 1 deletion carddav/elements.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/xml"
"fmt"

"github.com/emersion/go-webdav/internal"
"github.com/jonyTF/go-webdav/internal"
)

const namespace = "urn:ietf:params:xml:ns:carddav"
Expand Down
4 changes: 2 additions & 2 deletions carddav/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"strings"

"github.com/emersion/go-vcard"
"github.com/emersion/go-webdav"
"github.com/emersion/go-webdav/internal"
"github.com/jonyTF/go-webdav"
"github.com/jonyTF/go-webdav/internal"
)

type PutAddressObjectOptions struct {
Expand Down
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"net/http"
"time"

"github.com/emersion/go-webdav/internal"
"github.com/jonyTF/go-webdav/internal"
)

// HTTPClient performs HTTP requests. It's implemented by *http.Client.
Expand Down
2 changes: 1 addition & 1 deletion cmd/webdav-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"net/http"
"os"

"github.com/emersion/go-webdav"
"github.com/jonyTF/go-webdav"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion elements.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package webdav
import (
"encoding/xml"

"github.com/emersion/go-webdav/internal"
"github.com/jonyTF/go-webdav/internal"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion fs_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"path/filepath"
"strings"

"github.com/emersion/go-webdav/internal"
"github.com/jonyTF/go-webdav/internal"
)

// LocalFileSystem implements FileSystem for a local directory.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/emersion/go-webdav
module github.com/jonyTF/go-webdav

go 1.13

Expand Down
2 changes: 1 addition & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strconv"
"strings"

"github.com/emersion/go-webdav/internal"
"github.com/jonyTF/go-webdav/internal"
)

// FileSystem is a WebDAV server backend.
Expand Down
2 changes: 1 addition & 1 deletion webdav.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package webdav
import (
"time"

"github.com/emersion/go-webdav/internal"
"github.com/jonyTF/go-webdav/internal"
)

// FileInfo holds information about a WebDAV file.
Expand Down