From 7a9e31fd869c7a0af4138a5bf2140a5699d713a5 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Tue, 17 Sep 2024 16:54:45 +0800 Subject: [PATCH] :sparkles: Supply access policy in grpc get realms --- pkg/internal/grpc/realms.go | 53 ++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/pkg/internal/grpc/realms.go b/pkg/internal/grpc/realms.go index fa6006a..af6343a 100644 --- a/pkg/internal/grpc/realms.go +++ b/pkg/internal/grpc/realms.go @@ -4,6 +4,7 @@ import ( "context" "fmt" + "git.solsynth.dev/hydrogen/dealer/pkg/hyper" "git.solsynth.dev/hydrogen/dealer/pkg/proto" "git.solsynth.dev/hydrogen/passport/pkg/internal/database" "git.solsynth.dev/hydrogen/passport/pkg/internal/models" @@ -20,12 +21,13 @@ func (v *Server) ListCommunityRealm(ctx context.Context, empty *proto.ListRealmR return &proto.ListRealmResponse{ Data: lo.Map(realms, func(item models.Realm, index int) *proto.RealmInfo { info := &proto.RealmInfo{ - Id: uint64(item.ID), - Alias: item.Alias, - Name: item.Name, - Description: item.Description, - IsPublic: item.IsPublic, - IsCommunity: item.IsCommunity, + Id: uint64(item.ID), + Alias: item.Alias, + Name: item.Name, + Description: item.Description, + IsPublic: item.IsPublic, + IsCommunity: item.IsCommunity, + AccessPolicy: hyper.EncodeAccessPolicy(item.AccessPolicy), } if item.Avatar != nil { info.Avatar = *item.Avatar @@ -51,12 +53,13 @@ func (v *Server) ListAvailableRealm(ctx context.Context, request *proto.LookupUs return &proto.ListRealmResponse{ Data: lo.Map(realms, func(item models.Realm, index int) *proto.RealmInfo { info := &proto.RealmInfo{ - Id: uint64(item.ID), - Alias: item.Alias, - Name: item.Name, - Description: item.Description, - IsPublic: item.IsPublic, - IsCommunity: item.IsCommunity, + Id: uint64(item.ID), + Alias: item.Alias, + Name: item.Name, + Description: item.Description, + IsPublic: item.IsPublic, + IsCommunity: item.IsCommunity, + AccessPolicy: hyper.EncodeAccessPolicy(item.AccessPolicy), } if item.Avatar != nil { info.Avatar = *item.Avatar @@ -82,12 +85,13 @@ func (v *Server) ListOwnedRealm(ctx context.Context, request *proto.LookupUserRe return &proto.ListRealmResponse{ Data: lo.Map(realms, func(item models.Realm, index int) *proto.RealmInfo { info := &proto.RealmInfo{ - Id: uint64(item.ID), - Alias: item.Alias, - Name: item.Name, - Description: item.Description, - IsPublic: item.IsPublic, - IsCommunity: item.IsCommunity, + Id: uint64(item.ID), + Alias: item.Alias, + Name: item.Name, + Description: item.Description, + IsPublic: item.IsPublic, + IsCommunity: item.IsCommunity, + AccessPolicy: hyper.EncodeAccessPolicy(item.AccessPolicy), } if item.Avatar != nil { info.Avatar = *item.Avatar @@ -122,12 +126,13 @@ func (v *Server) GetRealm(ctx context.Context, request *proto.LookupRealmRequest } info := &proto.RealmInfo{ - Id: uint64(realm.ID), - Alias: realm.Alias, - Name: realm.Name, - Description: realm.Description, - IsPublic: realm.IsPublic, - IsCommunity: realm.IsCommunity, + Id: uint64(realm.ID), + Alias: realm.Alias, + Name: realm.Name, + Description: realm.Description, + IsPublic: realm.IsPublic, + IsCommunity: realm.IsCommunity, + AccessPolicy: hyper.EncodeAccessPolicy(realm.AccessPolicy), } if realm.Avatar != nil { info.Avatar = *realm.Avatar