storage/filesystem: simplify UserPrincipalBackend
Use composition to expose UserPrincipalBackend in filesystemBackend. That way, no need to re-define the CurrentUserPrincipal method.
This commit is contained in:
parent
e443b02acf
commit
5edd0f5a0e
@ -26,10 +26,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type filesystemBackend struct {
|
type filesystemBackend struct {
|
||||||
|
webdav.UserPrincipalBackend
|
||||||
path string
|
path string
|
||||||
caldavPrefix string
|
caldavPrefix string
|
||||||
carddavPrefix string
|
carddavPrefix string
|
||||||
userPrincipalBackend webdav.UserPrincipalBackend
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -45,20 +45,16 @@ func NewFilesystem(fsPath, caldavPrefix, carddavPrefix string, userPrincipalBack
|
|||||||
return nil, nil, fmt.Errorf("base path for filesystem backend must be a directory")
|
return nil, nil, fmt.Errorf("base path for filesystem backend must be a directory")
|
||||||
}
|
}
|
||||||
backend := &filesystemBackend{
|
backend := &filesystemBackend{
|
||||||
|
UserPrincipalBackend: userPrincipalBackend,
|
||||||
path: fsPath,
|
path: fsPath,
|
||||||
caldavPrefix: caldavPrefix,
|
caldavPrefix: caldavPrefix,
|
||||||
carddavPrefix: carddavPrefix,
|
carddavPrefix: carddavPrefix,
|
||||||
userPrincipalBackend: userPrincipalBackend,
|
|
||||||
}
|
}
|
||||||
return backend, backend, nil
|
return backend, backend, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *filesystemBackend) CurrentUserPrincipal(ctx context.Context) (string, error) {
|
|
||||||
return b.userPrincipalBackend.CurrentUserPrincipal(ctx)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *filesystemBackend) AddressbookHomeSetPath(ctx context.Context) (string, error) {
|
func (b *filesystemBackend) AddressbookHomeSetPath(ctx context.Context) (string, error) {
|
||||||
upPath, err := b.userPrincipalBackend.CurrentUserPrincipal(ctx)
|
upPath, err := b.CurrentUserPrincipal(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
@ -67,7 +63,7 @@ func (b *filesystemBackend) AddressbookHomeSetPath(ctx context.Context) (string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *filesystemBackend) CalendarHomeSetPath(ctx context.Context) (string, error) {
|
func (b *filesystemBackend) CalendarHomeSetPath(ctx context.Context) (string, error) {
|
||||||
upPath, err := b.userPrincipalBackend.CurrentUserPrincipal(ctx)
|
upPath, err := b.CurrentUserPrincipal(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user