Browse Source

plugins/carddav: add route to delete a contact

master
Simon Ser 4 years ago
parent
commit
37be46c047
No known key found for this signature in database GPG Key ID: FDE7BE0E88F5E48
2 changed files with 21 additions and 0 deletions
  1. +3
    -0
      plugins/carddav/public/address-object.html
  2. +18
    -0
      plugins/carddav/routes.go

+ 3
- 0
plugins/carddav/public/address-object.html View File

@@ -14,6 +14,9 @@
<a href="{{.AddressObject.URL}}/edit">
Edit
</a>
<form action="{{.AddressObject.URL}}/delete" method="post">
<input type="submit" value="Delete">
</form>
</p>

<ul>


+ 18
- 0
plugins/carddav/routes.go View File

@@ -211,4 +211,22 @@ func registerRoutes(p *plugin) {

p.GET("/contacts/:path/edit", updateContact)
p.POST("/contacts/:path/edit", updateContact)

p.POST("/contacts/:path/delete", func(ctx *alps.Context) error {
path, err := parseObjectPath(ctx.Param("path"))
if err != nil {
return err
}

c, err := p.client(ctx.Session)
if err != nil {
return err
}

if err := c.RemoveAll(path); err != nil {
return fmt.Errorf("failed to delete address object: %v", err)
}

return ctx.Redirect(http.StatusFound, "/contacts")
})
}

Loading…
Cancel
Save