-
Notifications
You must be signed in to change notification settings - Fork 483
/
changes.go
39 lines (33 loc) · 1.29 KB
/
changes.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package change
import (
"google.golang.org/protobuf/types/known/timestamppb"
"github.com/zitadel/zitadel/internal/domain"
"github.com/zitadel/zitadel/internal/query"
change_pb "github.com/zitadel/zitadel/pkg/grpc/change"
"github.com/zitadel/zitadel/pkg/grpc/message"
)
func ChangeQueryToQuery(query *change_pb.ChangeQuery) (sequence uint64, limit uint64, asc bool) {
if query == nil {
return 0, 0, false
}
return query.Sequence, uint64(query.Limit), query.Asc
}
func ChangesToPb(changes []*query.Change, assetAPIPrefix string) []*change_pb.Change {
c := make([]*change_pb.Change, len(changes))
for i, change := range changes {
c[i] = ChangeToPb(change, assetAPIPrefix)
}
return c
}
func ChangeToPb(change *query.Change, assetAPIPrefix string) *change_pb.Change {
return &change_pb.Change{
ChangeDate: timestamppb.New(change.ChangeDate),
EventType: message.NewLocalizedEventType(change.EventType),
Sequence: change.Sequence,
EditorId: change.ModifierId,
EditorDisplayName: change.ModifierName,
EditorPreferredLoginName: change.ModifierLoginName,
EditorAvatarUrl: domain.AvatarURL(assetAPIPrefix, change.ModifierResourceOwner, change.ModifierAvatarKey),
ResourceOwnerId: change.ResourceOwner,
}
}