mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 03:24:26 +00:00
7451ed58f2
* feat: user meta data events * feat: user meta data set tests * feat: user meta data tests * feat: user meta data in protos * feat: user meta data command api * feat: user meta data query side * feat: proto correct order, fix handlers * feat: proto correct order * feat: fixes of pr comments * feat: fixes of pr comments * feat: value as byte array * feat: metadata feature * Update internal/auth/repository/eventsourcing/handler/meta_data.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * Update internal/command/user_meta_data.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * Update proto/zitadel/metadata.proto Co-authored-by: Silvan <silvan.reusser@gmail.com> * Update proto/zitadel/metadata.proto Co-authored-by: Silvan <silvan.reusser@gmail.com> * fix: rename metadata files and table * fix: rename meta data to metadat in protos * Update internal/domain/metadata.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * fix: rename vars * fix: rebiuld docs * Update internal/iam/repository/view/metadata_view.go Co-authored-by: Silvan <silvan.reusser@gmail.com> Co-authored-by: Silvan <silvan.reusser@gmail.com>
54 lines
1.3 KiB
Go
54 lines
1.3 KiB
Go
package metadata
|
|
|
|
import (
|
|
"github.com/caos/zitadel/internal/api/grpc/object"
|
|
"github.com/caos/zitadel/internal/domain"
|
|
meta_pb "github.com/caos/zitadel/pkg/grpc/metadata"
|
|
)
|
|
|
|
func MetadataListToPb(dataList []*domain.Metadata) []*meta_pb.Metadata {
|
|
mds := make([]*meta_pb.Metadata, len(dataList))
|
|
for i, data := range dataList {
|
|
mds[i] = DomainMetadataToPb(data)
|
|
}
|
|
return mds
|
|
}
|
|
|
|
func DomainMetadataToPb(data *domain.Metadata) *meta_pb.Metadata {
|
|
return &meta_pb.Metadata{
|
|
Key: data.Key,
|
|
Value: data.Value,
|
|
Details: object.ToViewDetailsPb(
|
|
data.Sequence,
|
|
data.CreationDate,
|
|
data.ChangeDate,
|
|
data.ResourceOwner,
|
|
),
|
|
}
|
|
}
|
|
|
|
func MetadataQueriesToModel(queries []*meta_pb.MetadataQuery) []*domain.MetadataSearchQuery {
|
|
q := make([]*domain.MetadataSearchQuery, len(queries))
|
|
for i, query := range queries {
|
|
q[i] = MetadataQueryToModel(query)
|
|
}
|
|
return q
|
|
}
|
|
|
|
func MetadataQueryToModel(query *meta_pb.MetadataQuery) *domain.MetadataSearchQuery {
|
|
switch q := query.Query.(type) {
|
|
case *meta_pb.MetadataQuery_KeyQuery:
|
|
return MetadataKeyQueryToModel(q.KeyQuery)
|
|
default:
|
|
return nil
|
|
}
|
|
}
|
|
|
|
func MetadataKeyQueryToModel(q *meta_pb.MetadataKeyQuery) *domain.MetadataSearchQuery {
|
|
return &domain.MetadataSearchQuery{
|
|
Key: domain.MetadataSearchKeyKey,
|
|
Method: object.TextMethodToModel(q.Method),
|
|
Value: q.Key,
|
|
}
|
|
}
|