aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/carddav
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/carddav
parent39d5377855b54653ef43bceb5e317bbaec87ca15 (diff)
downloadalps-84a72320e2309c6e3f60574e22cb61a5eefd9c15.tar.gz
alps-84a72320e2309c6e3f60574e22cb61a5eefd9c15.tar.bz2
alps-84a72320e2309c6e3f60574e22cb61a5eefd9c15.zip
Upgrade go-webdav
Diffstat (limited to 'plugins/carddav')
-rw-r--r--plugins/carddav/plugin.go15
-rw-r--r--plugins/carddav/routes.go16
2 files changed, 16 insertions, 15 deletions
diff --git a/plugins/carddav/plugin.go b/plugins/carddav/plugin.go
index 5f1667e..54f3046 100644
--- a/plugins/carddav/plugin.go
+++ b/plugins/carddav/plugin.go
@@ -1,6 +1,7 @@
package alpscarddav
import (
+ "context"
"fmt"
"net/http"
"net/url"
@@ -40,7 +41,7 @@ func (p *plugin) client(session *alps.Session) (*carddav.Client, error) {
return newClient(p.url, session)
}
-func (p *plugin) clientWithAddressBook(session *alps.Session) (*carddav.Client, *carddav.AddressBook, error) {
+func (p *plugin) clientWithAddressBook(ctx context.Context, session *alps.Session) (*carddav.Client, *carddav.AddressBook, error) {
c, err := newClient(p.url, session)
if err != nil {
return nil, nil, fmt.Errorf("failed to create CardDAV client: %v", err)
@@ -48,12 +49,12 @@ func (p *plugin) clientWithAddressBook(session *alps.Session) (*carddav.Client,
homeSet, ok := p.homeSetCache[session.Username()]
if !ok {
- principal, err := c.FindCurrentUserPrincipal()
+ principal, err := c.FindCurrentUserPrincipal(ctx)
if err != nil {
return nil, nil, fmt.Errorf("failed to query CardDAV principal: %v", err)
}
- homeSet, err = c.FindAddressBookHomeSet(principal)
+ homeSet, err = c.FindAddressBookHomeSet(ctx, principal)
if err != nil {
return nil, nil, fmt.Errorf("failed to query CardDAV address book home set: %v", err)
}
@@ -62,7 +63,7 @@ func (p *plugin) clientWithAddressBook(session *alps.Session) (*carddav.Client,
// TODO: evict entries from the cache if it's getting too big
}
- addressBooks, err := c.FindAddressBooks(homeSet)
+ addressBooks, err := c.FindAddressBooks(ctx, homeSet)
if err != nil {
return nil, nil, fmt.Errorf("failed to query CardDAV address books: %v", err)
}
@@ -86,7 +87,7 @@ func newPlugin(srv *alps.Server) (alps.Plugin, error) {
u.Scheme = "http"
}
if u.Scheme == "" {
- s, err := carddav.Discover(u.Host)
+ s, err := carddav.DiscoverContextURL(context.Background(), u.Host)
if err != nil {
srv.Logger().Printf("carddav: failed to discover CardDAV server: %v", err)
return nil, nil
@@ -114,7 +115,7 @@ func newPlugin(srv *alps.Server) (alps.Plugin, error) {
p.Inject("compose.html", func(ctx *alps.Context, _data alps.RenderData) error {
data := _data.(*alpsbase.ComposeRenderData)
- c, addressBook, err := p.clientWithAddressBook(ctx.Session)
+ c, addressBook, err := p.clientWithAddressBook(ctx.Request().Context(), ctx.Session)
if err == errNoAddressBook {
return nil
} else if err != nil {
@@ -129,7 +130,7 @@ func newPlugin(srv *alps.Server) (alps.Plugin, error) {
Name: vcard.FieldEmail,
}},
}
- addrs, err := c.QueryAddressBook(addressBook.Path, &query)
+ addrs, err := c.QueryAddressBook(ctx.Request().Context(), addressBook.Path, &query)
if err != nil {
return fmt.Errorf("failed to query CardDAV addresses: %v", err)
}
diff --git a/plugins/carddav/routes.go b/plugins/carddav/routes.go
index 6c8a85f..c51ed23 100644
--- a/plugins/carddav/routes.go
+++ b/plugins/carddav/routes.go
@@ -47,7 +47,7 @@ func registerRoutes(p *plugin) {
p.GET("/contacts", func(ctx *alps.Context) error {
queryText := ctx.QueryParam("query")
- c, addressBook, err := p.clientWithAddressBook(ctx.Session)
+ c, addressBook, err := p.clientWithAddressBook(ctx.Request().Context(), ctx.Session)
if err != nil {
return err
}
@@ -78,7 +78,7 @@ func registerRoutes(p *plugin) {
}
}
- aos, err := c.QueryAddressBook(addressBook.Path, &query)
+ aos, err := c.QueryAddressBook(ctx.Request().Context(), addressBook.Path, &query)
if err != nil {
return fmt.Errorf("failed to query CardDAV addresses: %v", err)
}
@@ -97,7 +97,7 @@ func registerRoutes(p *plugin) {
return err
}
- c, addressBook, err := p.clientWithAddressBook(ctx.Session)
+ c, addressBook, err := p.clientWithAddressBook(ctx.Request().Context(), ctx.Session)
if err != nil {
return err
}
@@ -111,7 +111,7 @@ func registerRoutes(p *plugin) {
},
},
}
- aos, err := c.MultiGetAddressBook(path, &multiGet)
+ aos, err := c.MultiGetAddressBook(ctx.Request().Context(), path, &multiGet)
if err != nil {
return fmt.Errorf("failed to query CardDAV address: %v", err)
}
@@ -133,7 +133,7 @@ func registerRoutes(p *plugin) {
return err
}
- c, addressBook, err := p.clientWithAddressBook(ctx.Session)
+ c, addressBook, err := p.clientWithAddressBook(ctx.Request().Context(), ctx.Session)
if err != nil {
return err
}
@@ -141,7 +141,7 @@ func registerRoutes(p *plugin) {
var ao *carddav.AddressObject
var card vcard.Card
if addressObjectPath != "" {
- ao, err = c.GetAddressObject(addressObjectPath)
+ ao, err = c.GetAddressObject(ctx.Request().Context(), addressObjectPath)
if err != nil {
return fmt.Errorf("failed to query CardDAV address: %v", err)
}
@@ -194,7 +194,7 @@ func registerRoutes(p *plugin) {
} else {
p = path.Join(addressBook.Path, id.String()+".vcf")
}
- ao, err = c.PutAddressObject(p, card)
+ ao, err = c.PutAddressObject(ctx.Request().Context(), p, card)
if err != nil {
return fmt.Errorf("failed to put address object: %v", err)
}
@@ -227,7 +227,7 @@ func registerRoutes(p *plugin) {
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 address object: %v", err)
}