mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-06 19:36:41 +00:00
Changes (#195)
* Changes added * Reading of events for applications changed. * Proto changed * Tests added * Added more tests. * Struct for Data expanded with additional fields. * refactoring * Changes from review. * Merge in to Master * Changes from review. * fix: generate proto Co-authored-by: Fabiennne <fabienne.gerschwiler@gmail.com>
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
package grpc
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/caos/logging"
|
||||
org_model "github.com/caos/zitadel/internal/org/model"
|
||||
"github.com/golang/protobuf/ptypes"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
"google.golang.org/protobuf/types/known/structpb"
|
||||
)
|
||||
|
||||
func orgsFromModel(orgs []*org_model.Org) []*Org {
|
||||
@@ -58,3 +62,31 @@ func orgStateFromModel(state org_model.OrgState) OrgState {
|
||||
return OrgState_ORGSTATE_UNSPECIFIED
|
||||
}
|
||||
}
|
||||
|
||||
func orgChangesToResponse(response *org_model.OrgChanges, offset uint64, limit uint64) (_ *Changes) {
|
||||
return &Changes{
|
||||
Limit: limit,
|
||||
Offset: offset,
|
||||
Changes: orgChangesToMgtAPI(response),
|
||||
}
|
||||
}
|
||||
|
||||
func orgChangesToMgtAPI(changes *org_model.OrgChanges) (_ []*Change) {
|
||||
result := make([]*Change, len(changes.Changes))
|
||||
|
||||
for i, change := range changes.Changes {
|
||||
b, err := json.Marshal(change.Data)
|
||||
data := &structpb.Struct{}
|
||||
err = protojson.Unmarshal(b, data)
|
||||
if err != nil {
|
||||
}
|
||||
result[i] = &Change{
|
||||
ChangeDate: change.ChangeDate,
|
||||
EventType: change.EventType,
|
||||
Sequence: change.Sequence,
|
||||
Data: data,
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user