Add CurrentUserPrivilegeSet to find carddav

This commit is contained in:
Melon 2024-05-13 16:16:43 +01:00 committed by Captain ALM
parent 7f8c17ad71
commit 266c39c655
Signed by: alfred
GPG Key ID: 4E4ADD02609997B1
3 changed files with 30 additions and 0 deletions

1
.gitignore vendored
View File

@ -12,3 +12,4 @@
# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736 # Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
.glide/ .glide/
.idea/

View File

@ -524,6 +524,9 @@ func (b *backend) propFindAddressBook(ctx context.Context, propfind *internal.Pr
return &maxResourceSize{Size: ab.MaxResourceSize}, nil return &maxResourceSize{Size: ab.MaxResourceSize}, nil
} }
} }
props[internal.CurrentUserPrivilegeSetName] = func(*internal.RawXMLValue) (interface{}, error) {
return &internal.CurrentUserPrivilegeSet{Privilege: internal.NewAllPrivileges()}, nil
}
return internal.NewPropFindResponse(ab.Path, propfind, props) return internal.NewPropFindResponse(ab.Path, propfind, props)
} }

View File

@ -22,6 +22,8 @@ var (
GetETagName = xml.Name{Namespace, "getetag"} GetETagName = xml.Name{Namespace, "getetag"}
CurrentUserPrincipalName = xml.Name{Namespace, "current-user-principal"} CurrentUserPrincipalName = xml.Name{Namespace, "current-user-principal"}
CurrentUserPrivilegeSetName = xml.Name{Namespace, "current-user-privilege-set"}
) )
type Status struct { type Status struct {
@ -417,6 +419,30 @@ type CurrentUserPrincipal struct {
Unauthenticated *struct{} `xml:"unauthenticated,omitempty"` Unauthenticated *struct{} `xml:"unauthenticated,omitempty"`
} }
type CurrentUserPrivilegeSet struct {
XMLName xml.Name `xml:"DAV: current-user-privilege-set"`
Privilege []Privilege `xml:"privilege"`
}
type Privilege struct {
XMLName xml.Name `xml:"DAV: privilege"`
Read *struct{} `xml:"DAV: read,omitempty"`
All *struct{} `xml:"DAV: all,omitempty"`
Write *struct{} `xml:"DAV: write,omitempty"`
WriteProperties *struct{} `xml:"DAV: write-properties,omitempty"`
WriteContent *struct{} `xml:"DAV: write-content,omitempty"`
}
func NewAllPrivileges() []Privilege {
return []Privilege{
{Read: &struct{}{}},
{All: &struct{}{}},
{Write: &struct{}{}},
{WriteProperties: &struct{}{}},
{WriteContent: &struct{}{}},
}
}
// https://tools.ietf.org/html/rfc4918#section-14.19 // https://tools.ietf.org/html/rfc4918#section-14.19
type PropertyUpdate struct { type PropertyUpdate struct {
XMLName xml.Name `xml:"DAV: propertyupdate"` XMLName xml.Name `xml:"DAV: propertyupdate"`