mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 19:44:21 +00:00
25ef3da9d5
chore(fmt): run gci on complete project Fix global import formatting in go code by running the `gci` command. This allows us to just use the command directly, instead of fixing the import order manually for the linter, on each PR. Co-authored-by: Elio Bischof <elio@zitadel.com>
32 lines
1.1 KiB
Go
32 lines
1.1 KiB
Go
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 EventsToChangesPb(changes []*query.Event, assetAPIPrefix string) []*change_pb.Change {
|
|
c := make([]*change_pb.Change, len(changes))
|
|
for i, change := range changes {
|
|
c[i] = EventToChangePb(change, assetAPIPrefix)
|
|
}
|
|
return c
|
|
}
|
|
|
|
func EventToChangePb(change *query.Event, assetAPIPrefix string) *change_pb.Change {
|
|
return &change_pb.Change{
|
|
ChangeDate: timestamppb.New(change.CreationDate),
|
|
EventType: message.NewLocalizedEventType(change.Type),
|
|
Sequence: change.Sequence,
|
|
EditorId: change.Editor.ID,
|
|
EditorDisplayName: change.Editor.DisplayName,
|
|
EditorPreferredLoginName: change.Editor.PreferedLoginName,
|
|
EditorAvatarUrl: domain.AvatarURL(assetAPIPrefix, change.Aggregate.ResourceOwner, change.Editor.AvatarKey),
|
|
ResourceOwnerId: change.Aggregate.ResourceOwner,
|
|
}
|
|
}
|