diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 697d8cf..bef9cd8 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,9 +4,14 @@
-
-
+
+
+
+
+
+
+
@@ -140,7 +145,7 @@
-
+
@@ -154,7 +159,6 @@
-
@@ -179,7 +183,8 @@
-
+
+
diff --git a/pkg/authkit/models/realms.go b/pkg/authkit/models/realms.go
index 39c3d36..87a114b 100644
--- a/pkg/authkit/models/realms.go
+++ b/pkg/authkit/models/realms.go
@@ -1,6 +1,10 @@
package models
-import "gorm.io/datatypes"
+import (
+ "git.solsynth.dev/hypernet/nexus/pkg/nex"
+ "git.solsynth.dev/hypernet/passport/pkg/proto"
+ "gorm.io/datatypes"
+)
type Realm struct {
BaseModel
@@ -17,6 +21,22 @@ type Realm struct {
AccountID uint `json:"account_id"`
}
+func NewRealmFromProto(proto *proto.RealmInfo) Realm {
+ return Realm{
+ BaseModel: BaseModel{
+ ID: uint(proto.GetId()),
+ },
+ Alias: proto.GetAlias(),
+ Name: proto.GetName(),
+ Description: proto.GetDescription(),
+ Avatar: &proto.Avatar,
+ Banner: &proto.Banner,
+ IsPublic: proto.GetIsPublic(),
+ IsCommunity: proto.GetIsCommunity(),
+ AccessPolicy: nex.DecodeMap(proto.GetAccessPolicy()),
+ }
+}
+
type RealmMember struct {
BaseModel
@@ -26,3 +46,14 @@ type RealmMember struct {
Account Account `json:"account"`
PowerLevel int `json:"power_level"`
}
+
+func NewRealmMemberFromProto(proto *proto.RealmMemberInfo) RealmMember {
+ return RealmMember{
+ BaseModel: BaseModel{
+ ID: uint(proto.GetId()),
+ },
+ RealmID: uint(proto.GetRealmId()),
+ AccountID: uint(proto.GetUserId()),
+ PowerLevel: int(proto.GetPowerLevel()),
+ }
+}
diff --git a/pkg/authkit/realm.go b/pkg/authkit/realm.go
new file mode 100644
index 0000000..e7eae04
--- /dev/null
+++ b/pkg/authkit/realm.go
@@ -0,0 +1,108 @@
+package authkit
+
+import (
+ "git.solsynth.dev/hypernet/nexus/pkg/nex"
+ "git.solsynth.dev/hypernet/passport/pkg/authkit/models"
+ "git.solsynth.dev/hypernet/passport/pkg/proto"
+ "github.com/samber/lo"
+)
+
+func GetRealm(nx *nex.Conn, id uint) (models.Realm, error) {
+ var realm models.Realm
+ conn, err := nx.GetClientGrpcConn(nex.ServiceTypeAuth)
+ if err != nil {
+ return realm, err
+ }
+ resp, err := proto.NewRealmServiceClient(conn).GetRealm(nil, &proto.LookupRealmRequest{
+ Id: lo.ToPtr(uint64(id)),
+ })
+ if err != nil {
+ return realm, err
+ }
+ return models.NewRealmFromProto(resp), nil
+}
+
+func GetRealmByAlias(nx *nex.Conn, alias string) (models.Realm, error) {
+ var realm models.Realm
+ conn, err := nx.GetClientGrpcConn(nex.ServiceTypeAuth)
+ if err != nil {
+ return realm, err
+ }
+ resp, err := proto.NewRealmServiceClient(conn).GetRealm(nil, &proto.LookupRealmRequest{
+ Alias: &alias,
+ })
+ if err != nil {
+ return realm, err
+ }
+ return models.NewRealmFromProto(resp), nil
+}
+
+func ListRealm(nx *nex.Conn, id []uint) ([]models.Realm, error) {
+ var realms []models.Realm
+ conn, err := nx.GetClientGrpcConn(nex.ServiceTypeAuth)
+ if err != nil {
+ return realms, err
+ }
+ resp, err := proto.NewRealmServiceClient(conn).ListRealm(nil, &proto.ListRealmRequest{
+ Id: lo.Map(id, func(item uint, _ int) uint64 {
+ return uint64(item)
+ }),
+ })
+ if err != nil {
+ return realms, err
+ }
+ for _, realm := range resp.GetData() {
+ realms = append(realms, models.NewRealmFromProto(realm))
+ }
+ return realms, nil
+}
+
+func GetRealmMember(nx *nex.Conn, realmID, userID uint) (models.RealmMember, error) {
+ var member models.RealmMember
+ conn, err := nx.GetClientGrpcConn(nex.ServiceTypeAuth)
+ if err != nil {
+ return member, err
+ }
+ resp, err := proto.NewRealmServiceClient(conn).GetRealmMember(nil, &proto.RealmMemberLookupRequest{
+ RealmId: lo.ToPtr(uint64(realmID)),
+ UserId: lo.ToPtr(uint64(userID)),
+ })
+ if err != nil {
+ return member, err
+ }
+ return models.NewRealmMemberFromProto(resp), nil
+}
+
+func ListRealmMember(nx *nex.Conn, realmID uint) ([]models.RealmMember, error) {
+ var members []models.RealmMember
+ conn, err := nx.GetClientGrpcConn(nex.ServiceTypeAuth)
+ if err != nil {
+ return members, err
+ }
+ resp, err := proto.NewRealmServiceClient(conn).ListRealmMember(nil, &proto.RealmMemberLookupRequest{
+ RealmId: lo.ToPtr(uint64(realmID)),
+ })
+ if err != nil {
+ return members, err
+ }
+ for _, member := range resp.GetData() {
+ members = append(members, models.NewRealmMemberFromProto(member))
+ }
+ return members, nil
+}
+
+func CheckRealmMemberPerm(nx *nex.Conn, realmID uint, userID, power int) bool {
+ conn, err := nx.GetClientGrpcConn(nex.ServiceTypeAuth)
+ if err != nil {
+ return false
+ }
+ resp, err := proto.NewRealmServiceClient(conn).CheckRealmMemberPerm(nil, &proto.CheckRealmPermRequest{
+ RealmId: uint64(realmID),
+ UserId: uint64(userID),
+ PowerLevel: int32(power),
+ })
+ if err != nil {
+ return false
+ }
+ return resp.GetIsSuccess()
+}
diff --git a/pkg/internal/grpc/realms.go b/pkg/internal/grpc/realms.go
index 049ff08..fdac079 100644
--- a/pkg/internal/grpc/realms.go
+++ b/pkg/internal/grpc/realms.go
@@ -12,34 +12,6 @@ import (
"github.com/samber/lo"
)
-func (v *App) ListCommunityRealm(ctx context.Context, empty *proto.ListRealmRequest) (*proto.ListRealmResponse, error) {
- realms, err := services.ListCommunityRealm()
- if err != nil {
- return nil, err
- }
-
- 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,
- AccessPolicy: nex.EncodeMap(item.AccessPolicy),
- }
- if item.Avatar != nil {
- info.Avatar = *item.Avatar
- }
- if item.Banner != nil {
- info.Banner = *item.Banner
- }
- return info
- }),
- }, nil
-}
-
func (v *App) ListAvailableRealm(ctx context.Context, request *proto.LookupUserRealmRequest) (*proto.ListRealmResponse, error) {
account, err := services.GetAccount(uint(request.GetUserId()))
if err != nil {
@@ -104,6 +76,34 @@ func (v *App) ListOwnedRealm(ctx context.Context, request *proto.LookupUserRealm
}, nil
}
+func (v *App) ListRealm(ctx context.Context, request *proto.ListRealmRequest) (*proto.ListRealmResponse, error) {
+ var realms []models.Realm
+ if err := database.C.Where("id IN ?", request.GetId()).Find(&realms).Error; err != nil {
+ return nil, err
+ }
+
+ 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,
+ AccessPolicy: nex.EncodeMap(item.AccessPolicy),
+ }
+ if item.Avatar != nil {
+ info.Avatar = *item.Avatar
+ }
+ if item.Banner != nil {
+ info.Banner = *item.Banner
+ }
+ return info
+ }),
+ }, nil
+}
+
func (v *App) GetRealm(ctx context.Context, request *proto.LookupRealmRequest) (*proto.RealmInfo, error) {
var realm models.Realm
@@ -163,6 +163,7 @@ func (v *App) ListRealmMember(ctx context.Context, request *proto.RealmMemberLoo
return &proto.ListRealmMemberResponse{
Data: lo.Map(members, func(item models.RealmMember, index int) *proto.RealmMemberInfo {
return &proto.RealmMemberInfo{
+ Id: uint64(item.ID),
RealmId: uint64(item.RealmID),
UserId: uint64(item.AccountID),
PowerLevel: int32(item.PowerLevel),
@@ -189,6 +190,7 @@ func (v *App) GetRealmMember(ctx context.Context, request *proto.RealmMemberLook
}
return &proto.RealmMemberInfo{
+ Id: uint64(member.ID),
RealmId: uint64(member.RealmID),
UserId: uint64(member.AccountID),
PowerLevel: int32(member.PowerLevel),
diff --git a/pkg/proto/realm.pb.go b/pkg/proto/realm.pb.go
index 274e46d..7a1d1b8 100644
--- a/pkg/proto/realm.pb.go
+++ b/pkg/proto/realm.pb.go
@@ -133,6 +133,8 @@ type ListRealmRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
+
+ Id []uint64 `protobuf:"varint,1,rep,packed,name=id,proto3" json:"id,omitempty"`
}
func (x *ListRealmRequest) Reset() {
@@ -165,6 +167,13 @@ func (*ListRealmRequest) Descriptor() ([]byte, []int) {
return file_realm_proto_rawDescGZIP(), []int{1}
}
+func (x *ListRealmRequest) GetId() []uint64 {
+ if x != nil {
+ return x.Id
+ }
+ return nil
+}
+
type LookupUserRealmRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@@ -382,9 +391,10 @@ type RealmMemberInfo struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
- RealmId uint64 `protobuf:"varint,1,opt,name=realm_id,json=realmId,proto3" json:"realm_id,omitempty"`
- UserId uint64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
- PowerLevel int32 `protobuf:"varint,3,opt,name=power_level,json=powerLevel,proto3" json:"power_level,omitempty"`
+ Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
+ RealmId uint64 `protobuf:"varint,2,opt,name=realm_id,json=realmId,proto3" json:"realm_id,omitempty"`
+ UserId uint64 `protobuf:"varint,3,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
+ PowerLevel int32 `protobuf:"varint,4,opt,name=power_level,json=powerLevel,proto3" json:"power_level,omitempty"`
}
func (x *RealmMemberInfo) Reset() {
@@ -417,6 +427,13 @@ func (*RealmMemberInfo) Descriptor() ([]byte, []int) {
return file_realm_proto_rawDescGZIP(), []int{6}
}
+func (x *RealmMemberInfo) GetId() uint64 {
+ if x != nil {
+ return x.Id
+ }
+ return 0
+}
+
func (x *RealmMemberInfo) GetRealmId() uint64 {
if x != nil {
return x.RealmId
@@ -609,8 +626,9 @@ var file_realm_proto_rawDesc = []byte{
0x08, 0x52, 0x0b, 0x69, 0x73, 0x43, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x74, 0x79, 0x12, 0x23,
0x0a, 0x0d, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x18,
0x0b, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x50, 0x6f, 0x6c,
- 0x69, 0x63, 0x79, 0x22, 0x12, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x61, 0x6c, 0x6d,
- 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x31, 0x0a, 0x16, 0x4c, 0x6f, 0x6f, 0x6b, 0x75,
+ 0x69, 0x63, 0x79, 0x22, 0x22, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x61, 0x6c, 0x6d,
+ 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20,
+ 0x03, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, 0x22, 0x31, 0x0a, 0x16, 0x4c, 0x6f, 0x6f, 0x6b, 0x75,
0x70, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
0x28, 0x04, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0xbe, 0x01, 0x0a, 0x12, 0x4c,
@@ -636,13 +654,14 @@ var file_realm_proto_rawDesc = []byte{
0x01, 0x01, 0x12, 0x1c, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20,
0x01, 0x28, 0x04, 0x48, 0x01, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x88, 0x01, 0x01,
0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x72, 0x65, 0x61, 0x6c, 0x6d, 0x5f, 0x69, 0x64, 0x42, 0x0a, 0x0a,
- 0x08, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x22, 0x66, 0x0a, 0x0f, 0x52, 0x65, 0x61,
- 0x6c, 0x6d, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x19, 0x0a, 0x08,
- 0x72, 0x65, 0x61, 0x6c, 0x6d, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07,
+ 0x08, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x22, 0x76, 0x0a, 0x0f, 0x52, 0x65, 0x61,
+ 0x6c, 0x6d, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0e, 0x0a, 0x02,
+ 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, 0x12, 0x19, 0x0a, 0x08,
+ 0x72, 0x65, 0x61, 0x6c, 0x6d, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07,
0x72, 0x65, 0x61, 0x6c, 0x6d, 0x49, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f,
- 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64,
+ 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64,
0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x5f, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18,
- 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x4c, 0x65, 0x76, 0x65,
+ 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x4c, 0x65, 0x76, 0x65,
0x6c, 0x22, 0x45, 0x0a, 0x17, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x4d, 0x65,
0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x04,
0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x70, 0x72, 0x6f,
@@ -658,43 +677,42 @@ var file_realm_proto_rawDesc = []byte{
0x65, 0x61, 0x6c, 0x6d, 0x50, 0x65, 0x72, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x12, 0x1d, 0x0a, 0x0a, 0x69, 0x73, 0x5f, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01,
0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x69, 0x73, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x32,
- 0xac, 0x04, 0x0a, 0x0c, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
- 0x12, 0x49, 0x0a, 0x12, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x74,
- 0x79, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x12, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4c,
- 0x69, 0x73, 0x74, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
- 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x61, 0x6c,
- 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4f, 0x0a, 0x12, 0x4c,
- 0x69, 0x73, 0x74, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x61, 0x6c,
- 0x6d, 0x12, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70,
- 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
- 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x61,
- 0x6c, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4b, 0x0a, 0x0e,
- 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x77, 0x6e, 0x65, 0x64, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x12, 0x1d,
- 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x55, 0x73, 0x65,
- 0x72, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e,
- 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x52,
- 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x39, 0x0a, 0x08, 0x47, 0x65, 0x74,
- 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x12, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4c, 0x6f,
- 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
- 0x1a, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x49, 0x6e,
- 0x66, 0x6f, 0x22, 0x00, 0x12, 0x54, 0x0a, 0x0f, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x61, 0x6c,
- 0x6d, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x1f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
- 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x4c, 0x6f, 0x6f, 0x6b, 0x75,
- 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
- 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72,
- 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4b, 0x0a, 0x0e, 0x47, 0x65,
- 0x74, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x1f, 0x2e, 0x70,
- 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72,
- 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e,
- 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x4d, 0x65, 0x6d, 0x62, 0x65,
- 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0x00, 0x12, 0x55, 0x0a, 0x14, 0x43, 0x68, 0x65, 0x63, 0x6b,
- 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x50, 0x65, 0x72, 0x6d, 0x12,
- 0x1c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x61,
- 0x6c, 0x6d, 0x50, 0x65, 0x72, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e,
- 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x61, 0x6c, 0x6d,
- 0x50, 0x65, 0x72, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x09,
- 0x5a, 0x07, 0x2e, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
- 0x33,
+ 0xa3, 0x04, 0x0a, 0x0c, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
+ 0x12, 0x4f, 0x0a, 0x12, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c,
+ 0x65, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x12, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4c,
+ 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x52, 0x65,
+ 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4c, 0x69,
+ 0x73, 0x74, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
+ 0x00, 0x12, 0x4b, 0x0a, 0x0e, 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x77, 0x6e, 0x65, 0x64, 0x52, 0x65,
+ 0x61, 0x6c, 0x6d, 0x12, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4c, 0x6f, 0x6f, 0x6b,
+ 0x75, 0x70, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65,
+ 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52,
+ 0x65, 0x61, 0x6c, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x40,
+ 0x0a, 0x09, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x12, 0x17, 0x2e, 0x70, 0x72,
+ 0x6f, 0x74, 0x6f, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x52, 0x65, 0x71,
+ 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4c, 0x69, 0x73,
+ 0x74, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00,
+ 0x12, 0x39, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x12, 0x19, 0x2e, 0x70,
+ 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x61, 0x6c, 0x6d,
+ 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
+ 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0x00, 0x12, 0x54, 0x0a, 0x0f, 0x4c,
+ 0x69, 0x73, 0x74, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x1f,
+ 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x4d, 0x65, 0x6d, 0x62,
+ 0x65, 0x72, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
+ 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x61, 0x6c,
+ 0x6d, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
+ 0x00, 0x12, 0x4b, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x4d, 0x65, 0x6d,
+ 0x62, 0x65, 0x72, 0x12, 0x1f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x61, 0x6c,
+ 0x6d, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x71,
+ 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x61,
+ 0x6c, 0x6d, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0x00, 0x12, 0x55,
+ 0x0a, 0x14, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x4d, 0x65, 0x6d, 0x62,
+ 0x65, 0x72, 0x50, 0x65, 0x72, 0x6d, 0x12, 0x1c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43,
+ 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x50, 0x65, 0x72, 0x6d, 0x52, 0x65, 0x71,
+ 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x68, 0x65,
+ 0x63, 0x6b, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x50, 0x65, 0x72, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f,
+ 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x09, 0x5a, 0x07, 0x2e, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f,
+ 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -725,16 +743,16 @@ var file_realm_proto_goTypes = []any{
var file_realm_proto_depIdxs = []int32{
0, // 0: proto.ListRealmResponse.data:type_name -> proto.RealmInfo
6, // 1: proto.ListRealmMemberResponse.data:type_name -> proto.RealmMemberInfo
- 1, // 2: proto.RealmService.ListCommunityRealm:input_type -> proto.ListRealmRequest
- 2, // 3: proto.RealmService.ListAvailableRealm:input_type -> proto.LookupUserRealmRequest
- 2, // 4: proto.RealmService.ListOwnedRealm:input_type -> proto.LookupUserRealmRequest
+ 2, // 2: proto.RealmService.ListAvailableRealm:input_type -> proto.LookupUserRealmRequest
+ 2, // 3: proto.RealmService.ListOwnedRealm:input_type -> proto.LookupUserRealmRequest
+ 1, // 4: proto.RealmService.ListRealm:input_type -> proto.ListRealmRequest
3, // 5: proto.RealmService.GetRealm:input_type -> proto.LookupRealmRequest
5, // 6: proto.RealmService.ListRealmMember:input_type -> proto.RealmMemberLookupRequest
5, // 7: proto.RealmService.GetRealmMember:input_type -> proto.RealmMemberLookupRequest
8, // 8: proto.RealmService.CheckRealmMemberPerm:input_type -> proto.CheckRealmPermRequest
- 4, // 9: proto.RealmService.ListCommunityRealm:output_type -> proto.ListRealmResponse
- 4, // 10: proto.RealmService.ListAvailableRealm:output_type -> proto.ListRealmResponse
- 4, // 11: proto.RealmService.ListOwnedRealm:output_type -> proto.ListRealmResponse
+ 4, // 9: proto.RealmService.ListAvailableRealm:output_type -> proto.ListRealmResponse
+ 4, // 10: proto.RealmService.ListOwnedRealm:output_type -> proto.ListRealmResponse
+ 4, // 11: proto.RealmService.ListRealm:output_type -> proto.ListRealmResponse
0, // 12: proto.RealmService.GetRealm:output_type -> proto.RealmInfo
7, // 13: proto.RealmService.ListRealmMember:output_type -> proto.ListRealmMemberResponse
6, // 14: proto.RealmService.GetRealmMember:output_type -> proto.RealmMemberInfo
diff --git a/pkg/proto/realm.proto b/pkg/proto/realm.proto
index c4bc85c..74439e0 100644
--- a/pkg/proto/realm.proto
+++ b/pkg/proto/realm.proto
@@ -5,9 +5,9 @@ option go_package = ".;proto";
package proto;
service RealmService {
- rpc ListCommunityRealm(ListRealmRequest) returns (ListRealmResponse) {}
rpc ListAvailableRealm(LookupUserRealmRequest) returns (ListRealmResponse) {}
rpc ListOwnedRealm(LookupUserRealmRequest) returns (ListRealmResponse) {}
+ rpc ListRealm(ListRealmRequest) returns (ListRealmResponse) {}
rpc GetRealm(LookupRealmRequest) returns (RealmInfo) {}
rpc ListRealmMember(RealmMemberLookupRequest) returns (ListRealmMemberResponse) {}
rpc GetRealmMember(RealmMemberLookupRequest) returns (RealmMemberInfo) {}
@@ -27,6 +27,7 @@ message RealmInfo {
}
message ListRealmRequest {
+ repeated uint64 id = 1;
}
message LookupUserRealmRequest {
@@ -50,9 +51,10 @@ message RealmMemberLookupRequest {
}
message RealmMemberInfo {
- uint64 realm_id = 1;
- uint64 user_id = 2;
- int32 power_level = 3;
+ uint64 id = 1;
+ uint64 realm_id = 2;
+ uint64 user_id = 3;
+ int32 power_level = 4;
}
message ListRealmMemberResponse {
diff --git a/pkg/proto/realm_grpc.pb.go b/pkg/proto/realm_grpc.pb.go
index ab25f03..7746b9e 100644
--- a/pkg/proto/realm_grpc.pb.go
+++ b/pkg/proto/realm_grpc.pb.go
@@ -19,9 +19,9 @@ import (
const _ = grpc.SupportPackageIsVersion9
const (
- RealmService_ListCommunityRealm_FullMethodName = "/proto.RealmService/ListCommunityRealm"
RealmService_ListAvailableRealm_FullMethodName = "/proto.RealmService/ListAvailableRealm"
RealmService_ListOwnedRealm_FullMethodName = "/proto.RealmService/ListOwnedRealm"
+ RealmService_ListRealm_FullMethodName = "/proto.RealmService/ListRealm"
RealmService_GetRealm_FullMethodName = "/proto.RealmService/GetRealm"
RealmService_ListRealmMember_FullMethodName = "/proto.RealmService/ListRealmMember"
RealmService_GetRealmMember_FullMethodName = "/proto.RealmService/GetRealmMember"
@@ -32,9 +32,9 @@ const (
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type RealmServiceClient interface {
- ListCommunityRealm(ctx context.Context, in *ListRealmRequest, opts ...grpc.CallOption) (*ListRealmResponse, error)
ListAvailableRealm(ctx context.Context, in *LookupUserRealmRequest, opts ...grpc.CallOption) (*ListRealmResponse, error)
ListOwnedRealm(ctx context.Context, in *LookupUserRealmRequest, opts ...grpc.CallOption) (*ListRealmResponse, error)
+ ListRealm(ctx context.Context, in *ListRealmRequest, opts ...grpc.CallOption) (*ListRealmResponse, error)
GetRealm(ctx context.Context, in *LookupRealmRequest, opts ...grpc.CallOption) (*RealmInfo, error)
ListRealmMember(ctx context.Context, in *RealmMemberLookupRequest, opts ...grpc.CallOption) (*ListRealmMemberResponse, error)
GetRealmMember(ctx context.Context, in *RealmMemberLookupRequest, opts ...grpc.CallOption) (*RealmMemberInfo, error)
@@ -49,16 +49,6 @@ func NewRealmServiceClient(cc grpc.ClientConnInterface) RealmServiceClient {
return &realmServiceClient{cc}
}
-func (c *realmServiceClient) ListCommunityRealm(ctx context.Context, in *ListRealmRequest, opts ...grpc.CallOption) (*ListRealmResponse, error) {
- cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
- out := new(ListRealmResponse)
- err := c.cc.Invoke(ctx, RealmService_ListCommunityRealm_FullMethodName, in, out, cOpts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
func (c *realmServiceClient) ListAvailableRealm(ctx context.Context, in *LookupUserRealmRequest, opts ...grpc.CallOption) (*ListRealmResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ListRealmResponse)
@@ -79,6 +69,16 @@ func (c *realmServiceClient) ListOwnedRealm(ctx context.Context, in *LookupUserR
return out, nil
}
+func (c *realmServiceClient) ListRealm(ctx context.Context, in *ListRealmRequest, opts ...grpc.CallOption) (*ListRealmResponse, error) {
+ cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
+ out := new(ListRealmResponse)
+ err := c.cc.Invoke(ctx, RealmService_ListRealm_FullMethodName, in, out, cOpts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
func (c *realmServiceClient) GetRealm(ctx context.Context, in *LookupRealmRequest, opts ...grpc.CallOption) (*RealmInfo, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(RealmInfo)
@@ -123,9 +123,9 @@ func (c *realmServiceClient) CheckRealmMemberPerm(ctx context.Context, in *Check
// All implementations must embed UnimplementedRealmServiceServer
// for forward compatibility.
type RealmServiceServer interface {
- ListCommunityRealm(context.Context, *ListRealmRequest) (*ListRealmResponse, error)
ListAvailableRealm(context.Context, *LookupUserRealmRequest) (*ListRealmResponse, error)
ListOwnedRealm(context.Context, *LookupUserRealmRequest) (*ListRealmResponse, error)
+ ListRealm(context.Context, *ListRealmRequest) (*ListRealmResponse, error)
GetRealm(context.Context, *LookupRealmRequest) (*RealmInfo, error)
ListRealmMember(context.Context, *RealmMemberLookupRequest) (*ListRealmMemberResponse, error)
GetRealmMember(context.Context, *RealmMemberLookupRequest) (*RealmMemberInfo, error)
@@ -140,15 +140,15 @@ type RealmServiceServer interface {
// pointer dereference when methods are called.
type UnimplementedRealmServiceServer struct{}
-func (UnimplementedRealmServiceServer) ListCommunityRealm(context.Context, *ListRealmRequest) (*ListRealmResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method ListCommunityRealm not implemented")
-}
func (UnimplementedRealmServiceServer) ListAvailableRealm(context.Context, *LookupUserRealmRequest) (*ListRealmResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListAvailableRealm not implemented")
}
func (UnimplementedRealmServiceServer) ListOwnedRealm(context.Context, *LookupUserRealmRequest) (*ListRealmResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListOwnedRealm not implemented")
}
+func (UnimplementedRealmServiceServer) ListRealm(context.Context, *ListRealmRequest) (*ListRealmResponse, error) {
+ return nil, status.Errorf(codes.Unimplemented, "method ListRealm not implemented")
+}
func (UnimplementedRealmServiceServer) GetRealm(context.Context, *LookupRealmRequest) (*RealmInfo, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetRealm not implemented")
}
@@ -182,24 +182,6 @@ func RegisterRealmServiceServer(s grpc.ServiceRegistrar, srv RealmServiceServer)
s.RegisterService(&RealmService_ServiceDesc, srv)
}
-func _RealmService_ListCommunityRealm_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(ListRealmRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(RealmServiceServer).ListCommunityRealm(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: RealmService_ListCommunityRealm_FullMethodName,
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(RealmServiceServer).ListCommunityRealm(ctx, req.(*ListRealmRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
func _RealmService_ListAvailableRealm_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(LookupUserRealmRequest)
if err := dec(in); err != nil {
@@ -236,6 +218,24 @@ func _RealmService_ListOwnedRealm_Handler(srv interface{}, ctx context.Context,
return interceptor(ctx, in, info, handler)
}
+func _RealmService_ListRealm_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(ListRealmRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(RealmServiceServer).ListRealm(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: RealmService_ListRealm_FullMethodName,
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(RealmServiceServer).ListRealm(ctx, req.(*ListRealmRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
func _RealmService_GetRealm_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(LookupRealmRequest)
if err := dec(in); err != nil {
@@ -315,10 +315,6 @@ var RealmService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "proto.RealmService",
HandlerType: (*RealmServiceServer)(nil),
Methods: []grpc.MethodDesc{
- {
- MethodName: "ListCommunityRealm",
- Handler: _RealmService_ListCommunityRealm_Handler,
- },
{
MethodName: "ListAvailableRealm",
Handler: _RealmService_ListAvailableRealm_Handler,
@@ -327,6 +323,10 @@ var RealmService_ServiceDesc = grpc.ServiceDesc{
MethodName: "ListOwnedRealm",
Handler: _RealmService_ListOwnedRealm_Handler,
},
+ {
+ MethodName: "ListRealm",
+ Handler: _RealmService_ListRealm_Handler,
+ },
{
MethodName: "GetRealm",
Handler: _RealmService_GetRealm_Handler,