mirror of
https://github.com/andwati/zitadel.git
synced 2026-12-03 17:38:51 +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 <[email protected]>
This commit is contained in:
co-authored by
Fabiennne
parent
8dd6082b17
commit
1dd82ab1b7
@@ -1,11 +1,15 @@
|
||||
package grpc
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/caos/logging"
|
||||
"github.com/caos/zitadel/internal/eventstore/models"
|
||||
usr_model "github.com/caos/zitadel/internal/user/model"
|
||||
"github.com/golang/protobuf/ptypes"
|
||||
"golang.org/x/text/language"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
"google.golang.org/protobuf/types/known/structpb"
|
||||
)
|
||||
|
||||
func userFromModel(user *usr_model.User) *User {
|
||||
@@ -397,3 +401,31 @@ func mfaStateFromModel(state usr_model.MfaState) MFAState {
|
||||
return MFAState_MFASTATE_UNSPECIFIED
|
||||
}
|
||||
}
|
||||
|
||||
func userChangesToResponse(response *usr_model.UserChanges, offset uint64, limit uint64) (_ *Changes) {
|
||||
return &Changes{
|
||||
Limit: limit,
|
||||
Offset: offset,
|
||||
Changes: userChangesToMgtAPI(response),
|
||||
}
|
||||
}
|
||||
|
||||
func userChangesToMgtAPI(changes *usr_model.UserChanges) (_ []*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