mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-04-28 14:59:49 -05:00
Groupware improvements
* ensure that all the jmap responses contain the SessionState * implement missing errors that were marked as TODO * moved common functions from pkg/jmap and pkg/services/groupware to pkg/log and pkg/structs to commonalize them across both source trees * implement error handling for SetError occurences * Email: replace anonymous map[string]bool for mailbox rights with a MailboxRights struct, as the keys are well-defined, which allows for properly documenting them * introduce ObjectType as an "enum" * fix JSON marshalling and unmarshalling of EmailBodyStructure * move the swagger documentation structs from groupware_api.go to groupware_docs.go * fix: change verb for /groupware/accounts/*/vacation from POST to PUT
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
// Package structs provides some utility functions for dealing with structs.
|
||||
package structs
|
||||
|
||||
import (
|
||||
orderedmap "github.com/wk8/go-ordered-map"
|
||||
)
|
||||
|
||||
// CopyOrZeroValue returns a copy of s if s is not nil otherwise the zero value of T will be returned.
|
||||
func CopyOrZeroValue[T any](s *T) *T {
|
||||
cp := new(T)
|
||||
@@ -9,3 +13,20 @@ func CopyOrZeroValue[T any](s *T) *T {
|
||||
}
|
||||
return cp
|
||||
}
|
||||
|
||||
// Returns a copy of an array with a unique set of elements.
|
||||
//
|
||||
// Element order is retained.
|
||||
func Uniq[T comparable](source []T) []T {
|
||||
m := orderedmap.New()
|
||||
for _, v := range source {
|
||||
m.Set(v, true)
|
||||
}
|
||||
set := make([]T, m.Len())
|
||||
i := 0
|
||||
for pair := m.Oldest(); pair != nil; pair = pair.Next() {
|
||||
set[i] = pair.Key.(T)
|
||||
i++
|
||||
}
|
||||
return set
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user