aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/caldav
diff options
context:
space:
mode:
authorLibravatarLibravatar Simon Ser <[email protected]> 2023-12-27 23:32:49 +0100
committerLibravatarLibravatar Simon Ser <[email protected]> 2023-12-27 23:32:49 +0100
commit84a72320e2309c6e3f60574e22cb61a5eefd9c15 (patch)
treed92788333d2ce03b00110abb5a6f6715113fa8e8 /plugins/caldav
parent39d5377855b54653ef43bceb5e317bbaec87ca15 (diff)
downloadalps-84a72320e2309c6e3f60574e22cb61a5eefd9c15.tar.gz
alps-84a72320e2309c6e3f60574e22cb61a5eefd9c15.tar.bz2
alps-84a72320e2309c6e3f60574e22cb61a5eefd9c15.zip
Upgrade go-webdav
Diffstat (limited to 'plugins/caldav')
-rw-r--r--plugins/caldav/caldav.go9
-rw-r--r--plugins/caldav/routes.go22
2 files changed, 16 insertions, 15 deletions
diff --git a/plugins/caldav/caldav.go b/plugins/caldav/caldav.go
index 05d57fe..07aa162 100644
--- a/plugins/caldav/caldav.go
+++ b/plugins/caldav/caldav.go
@@ -1,6 +1,7 @@
package alpscaldav
import (
+ "context"
"fmt"
"net/http"
"net/url"
@@ -34,23 +35,23 @@ func newClient(u *url.URL, session *alps.Session) (*caldav.Client, error) {
return c, nil
}
-func getCalendar(u *url.URL, session *alps.Session) (*caldav.Client, *caldav.Calendar, error) {
+func getCalendar(ctx context.Context, u *url.URL, session *alps.Session) (*caldav.Client, *caldav.Calendar, error) {
c, err := newClient(u, session)
if err != nil {
return nil, nil, err
}
- principal, err := c.FindCurrentUserPrincipal()
+ principal, err := c.FindCurrentUserPrincipal(ctx)
if err != nil {
return nil, nil, fmt.Errorf("failed to query CalDAV principal: %v", err)
}
- calendarHomeSet, err := c.FindCalendarHomeSet(principal)
+ calendarHomeSet, err := c.FindCalendarHomeSet(ctx, principal)
if err != nil {
return nil, nil, fmt.Errorf("failed to query CalDAV calendar home set: %v", err)
}
- calendars, err := c.FindCalendars(calendarHomeSet)
+ calendars, err := c.FindCalendars(ctx, calendarHomeSet)
if err != nil {
return nil, nil, fmt.Errorf("failed to find calendars: %v", err)
}
diff --git a/plugins/caldav/routes.go b/plugins/caldav/routes.go
index d551434..3e283bd 100644
--- a/plugins/caldav/routes.go
+++ b/plugins/caldav/routes.go
@@ -96,7 +96,7 @@ func registerRoutes(p *alps.GoPlugin, u *url.URL) {
end := start.AddDate(0, 1, 0)
// TODO: multi-calendar support
- c, calendar, err := getCalendar(u, ctx.Session)
+ c, calendar, err := getCalendar(ctx.Request().Context(), u, ctx.Session)
if err != nil {
return err
}
@@ -125,7 +125,7 @@ func registerRoutes(p *alps.GoPlugin, u *url.URL) {
}},
},
}
- events, err := c.QueryCalendar(calendar.Path, &query)
+ events, err := c.QueryCalendar(ctx.Request().Context(), calendar.Path, &query)
if err != nil {
return fmt.Errorf("failed to query calendar: %v", err)
}
@@ -209,7 +209,7 @@ func registerRoutes(p *alps.GoPlugin, u *url.URL) {
end := start.AddDate(0, 0, 1)
// TODO: multi-calendar support
- c, calendar, err := getCalendar(u, ctx.Session)
+ c, calendar, err := getCalendar(ctx.Request().Context(), u, ctx.Session)
if err != nil {
return err
}
@@ -238,7 +238,7 @@ func registerRoutes(p *alps.GoPlugin, u *url.URL) {
}},
},
}
- events, err := c.QueryCalendar(calendar.Path, &query)
+ events, err := c.QueryCalendar(ctx.Request().Context(), calendar.Path, &query)
if err != nil {
return fmt.Errorf("failed to query calendar: %v", err)
}
@@ -260,7 +260,7 @@ func registerRoutes(p *alps.GoPlugin, u *url.URL) {
return err
}
- c, calendar, err := getCalendar(u, ctx.Session)
+ c, calendar, err := getCalendar(ctx.Request().Context(), u, ctx.Session)
if err != nil {
return err
}
@@ -283,7 +283,7 @@ func registerRoutes(p *alps.GoPlugin, u *url.URL) {
},
}
- events, err := c.MultiGetCalendar(path, &multiGet)
+ events, err := c.MultiGetCalendar(ctx.Request().Context(), path, &multiGet)
if err != nil {
return fmt.Errorf("failed to multi-get calendar: %v", err)
}
@@ -306,7 +306,7 @@ func registerRoutes(p *alps.GoPlugin, u *url.URL) {
return err
}
- c, calendar, err := getCalendar(u, ctx.Session)
+ c, calendar, err := getCalendar(ctx.Request().Context(), u, ctx.Session)
if err != nil {
return err
}
@@ -314,7 +314,7 @@ func registerRoutes(p *alps.GoPlugin, u *url.URL) {
var co *caldav.CalendarObject
var event *ical.Event
if calendarObjectPath != "" {
- co, err = c.GetCalendarObject(calendarObjectPath)
+ co, err = c.GetCalendarObject(ctx.Request().Context(), calendarObjectPath)
if err != nil {
return fmt.Errorf("failed to get CalDAV event: %v", err)
}
@@ -377,7 +377,7 @@ func registerRoutes(p *alps.GoPlugin, u *url.URL) {
} else {
p = path.Join(calendar.Path, newID.String()+".ics")
}
- co, err = c.PutCalendarObject(p, cal)
+ co, err = c.PutCalendarObject(ctx.Request().Context(), p, cal)
if err != nil {
return fmt.Errorf("failed to put calendar object: %v", err)
}
@@ -407,12 +407,12 @@ func registerRoutes(p *alps.GoPlugin, u *url.URL) {
return err
}
- c, _, err := getCalendar(u, ctx.Session)
+ c, _, err := getCalendar(ctx.Request().Context(), u, ctx.Session)
if err != nil {
return err
}
- if err := c.RemoveAll(path); err != nil {
+ if err := c.RemoveAll(ctx.Request().Context(), path); err != nil {
return fmt.Errorf("failed to delete calendar object: %v", err)
}