✨ Realm GRPC
This commit is contained in:
parent
5de68bb9b9
commit
854a50f63f
@ -4,14 +4,14 @@
|
|||||||
<option name="autoReloadType" value="ALL" />
|
<option name="autoReloadType" value="ALL" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":bug: Bug fixes of risk detection :lipstick: Optimized UI">
|
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":sparkles: Realm in passport">
|
||||||
<change afterPath="$PROJECT_DIR$/pkg/models/realms.go" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/pkg/grpc/proto/realms.proto" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/pkg/server/realm_members_api.go" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/pkg/grpc/realms.go" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/pkg/server/realms_api.go" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/pkg/services/realms.go" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/database/migrator.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/database/migrator.go" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/pkg/grpc/proto/friendships.proto" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/grpc/proto/friendships.proto" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/server/startup.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/server/startup.go" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/pkg/grpc/server.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/grpc/server.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/server/realms_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/server/realms_api.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/services/realms.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/services/realms.go" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@ -146,7 +146,8 @@
|
|||||||
<MESSAGE value=":sparkles: Bug fixes" />
|
<MESSAGE value=":sparkles: Bug fixes" />
|
||||||
<MESSAGE value=":sparkles: Batch mark notify as read API" />
|
<MESSAGE value=":sparkles: Batch mark notify as read API" />
|
||||||
<MESSAGE value=":bug: Bug fixes of risk detection :lipstick: Optimized UI" />
|
<MESSAGE value=":bug: Bug fixes of risk detection :lipstick: Optimized UI" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value=":bug: Bug fixes of risk detection :lipstick: Optimized UI" />
|
<MESSAGE value=":sparkles: Realm in passport" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value=":sparkles: Realm in passport" />
|
||||||
</component>
|
</component>
|
||||||
<component name="VgoProject">
|
<component name="VgoProject">
|
||||||
<settings-migrated>true</settings-migrated>
|
<settings-migrated>true</settings-migrated>
|
||||||
|
@ -20,12 +20,12 @@ message FriendshipTwoSideLookupRequest {
|
|||||||
uint32 status = 3;
|
uint32 status = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ListFriendshipResponse {
|
|
||||||
repeated FriendshipResponse data = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message FriendshipResponse {
|
message FriendshipResponse {
|
||||||
uint64 account_id = 1;
|
uint64 account_id = 1;
|
||||||
uint64 related_id = 2;
|
uint64 related_id = 2;
|
||||||
uint32 status = 3;
|
uint32 status = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message ListFriendshipResponse {
|
||||||
|
repeated FriendshipResponse data = 1;
|
||||||
|
}
|
||||||
|
438
pkg/grpc/proto/realms.pb.go
Normal file
438
pkg/grpc/proto/realms.pb.go
Normal file
@ -0,0 +1,438 @@
|
|||||||
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
|
// versions:
|
||||||
|
// protoc-gen-go v1.33.0
|
||||||
|
// protoc v5.26.1
|
||||||
|
// source: realms.proto
|
||||||
|
|
||||||
|
package proto
|
||||||
|
|
||||||
|
import (
|
||||||
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
|
emptypb "google.golang.org/protobuf/types/known/emptypb"
|
||||||
|
reflect "reflect"
|
||||||
|
sync "sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Verify that this generated code is sufficiently up-to-date.
|
||||||
|
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||||
|
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||||
|
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||||
|
)
|
||||||
|
|
||||||
|
type RealmLookupWithUserRequest struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
UserId uint64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *RealmLookupWithUserRequest) Reset() {
|
||||||
|
*x = RealmLookupWithUserRequest{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_realms_proto_msgTypes[0]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *RealmLookupWithUserRequest) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*RealmLookupWithUserRequest) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *RealmLookupWithUserRequest) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_realms_proto_msgTypes[0]
|
||||||
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use RealmLookupWithUserRequest.ProtoReflect.Descriptor instead.
|
||||||
|
func (*RealmLookupWithUserRequest) Descriptor() ([]byte, []int) {
|
||||||
|
return file_realms_proto_rawDescGZIP(), []int{0}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *RealmLookupWithUserRequest) GetUserId() uint64 {
|
||||||
|
if x != nil {
|
||||||
|
return x.UserId
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
type RealmLookupRequest struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Id *uint64 `protobuf:"varint,1,opt,name=id,proto3,oneof" json:"id,omitempty"`
|
||||||
|
Alias *string `protobuf:"bytes,2,opt,name=alias,proto3,oneof" json:"alias,omitempty"`
|
||||||
|
IsPublic *bool `protobuf:"varint,3,opt,name=is_public,json=isPublic,proto3,oneof" json:"is_public,omitempty"`
|
||||||
|
IsCommunity *bool `protobuf:"varint,4,opt,name=is_community,json=isCommunity,proto3,oneof" json:"is_community,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *RealmLookupRequest) Reset() {
|
||||||
|
*x = RealmLookupRequest{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_realms_proto_msgTypes[1]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *RealmLookupRequest) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*RealmLookupRequest) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *RealmLookupRequest) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_realms_proto_msgTypes[1]
|
||||||
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use RealmLookupRequest.ProtoReflect.Descriptor instead.
|
||||||
|
func (*RealmLookupRequest) Descriptor() ([]byte, []int) {
|
||||||
|
return file_realms_proto_rawDescGZIP(), []int{1}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *RealmLookupRequest) GetId() uint64 {
|
||||||
|
if x != nil && x.Id != nil {
|
||||||
|
return *x.Id
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *RealmLookupRequest) GetAlias() string {
|
||||||
|
if x != nil && x.Alias != nil {
|
||||||
|
return *x.Alias
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *RealmLookupRequest) GetIsPublic() bool {
|
||||||
|
if x != nil && x.IsPublic != nil {
|
||||||
|
return *x.IsPublic
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *RealmLookupRequest) GetIsCommunity() bool {
|
||||||
|
if x != nil && x.IsCommunity != nil {
|
||||||
|
return *x.IsCommunity
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
type RealmResponse struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Alias string `protobuf:"bytes,1,opt,name=alias,proto3" json:"alias,omitempty"`
|
||||||
|
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
|
||||||
|
Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"`
|
||||||
|
IsPublic bool `protobuf:"varint,4,opt,name=is_public,json=isPublic,proto3" json:"is_public,omitempty"`
|
||||||
|
IsCommunity bool `protobuf:"varint,5,opt,name=is_community,json=isCommunity,proto3" json:"is_community,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *RealmResponse) Reset() {
|
||||||
|
*x = RealmResponse{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_realms_proto_msgTypes[2]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *RealmResponse) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*RealmResponse) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *RealmResponse) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_realms_proto_msgTypes[2]
|
||||||
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use RealmResponse.ProtoReflect.Descriptor instead.
|
||||||
|
func (*RealmResponse) Descriptor() ([]byte, []int) {
|
||||||
|
return file_realms_proto_rawDescGZIP(), []int{2}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *RealmResponse) GetAlias() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Alias
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *RealmResponse) GetName() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Name
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *RealmResponse) GetDescription() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Description
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *RealmResponse) GetIsPublic() bool {
|
||||||
|
if x != nil {
|
||||||
|
return x.IsPublic
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *RealmResponse) GetIsCommunity() bool {
|
||||||
|
if x != nil {
|
||||||
|
return x.IsCommunity
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListRealmResponse struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Data []*RealmResponse `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ListRealmResponse) Reset() {
|
||||||
|
*x = ListRealmResponse{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_realms_proto_msgTypes[3]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ListRealmResponse) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*ListRealmResponse) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *ListRealmResponse) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_realms_proto_msgTypes[3]
|
||||||
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use ListRealmResponse.ProtoReflect.Descriptor instead.
|
||||||
|
func (*ListRealmResponse) Descriptor() ([]byte, []int) {
|
||||||
|
return file_realms_proto_rawDescGZIP(), []int{3}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ListRealmResponse) GetData() []*RealmResponse {
|
||||||
|
if x != nil {
|
||||||
|
return x.Data
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var File_realms_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
|
var file_realms_proto_rawDesc = []byte{
|
||||||
|
0x0a, 0x0c, 0x72, 0x65, 0x61, 0x6c, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05,
|
||||||
|
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72,
|
||||||
|
0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f,
|
||||||
|
0x74, 0x6f, 0x22, 0x35, 0x0a, 0x1a, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x4c, 0x6f, 0x6f, 0x6b, 0x75,
|
||||||
|
0x70, 0x57, 0x69, 0x74, 0x68, 0x55, 0x73, 0x65, 0x72, 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, 0x52, 0x65,
|
||||||
|
0x61, 0x6c, 0x6d, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
|
||||||
|
0x12, 0x13, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x48, 0x00, 0x52, 0x02,
|
||||||
|
0x69, 0x64, 0x88, 0x01, 0x01, 0x12, 0x19, 0x0a, 0x05, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x18, 0x02,
|
||||||
|
0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x05, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x88, 0x01, 0x01,
|
||||||
|
0x12, 0x20, 0x0a, 0x09, 0x69, 0x73, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x18, 0x03, 0x20,
|
||||||
|
0x01, 0x28, 0x08, 0x48, 0x02, 0x52, 0x08, 0x69, 0x73, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x88,
|
||||||
|
0x01, 0x01, 0x12, 0x26, 0x0a, 0x0c, 0x69, 0x73, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69,
|
||||||
|
0x74, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x48, 0x03, 0x52, 0x0b, 0x69, 0x73, 0x43, 0x6f,
|
||||||
|
0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x74, 0x79, 0x88, 0x01, 0x01, 0x42, 0x05, 0x0a, 0x03, 0x5f, 0x69,
|
||||||
|
0x64, 0x42, 0x08, 0x0a, 0x06, 0x5f, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x42, 0x0c, 0x0a, 0x0a, 0x5f,
|
||||||
|
0x69, 0x73, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x42, 0x0f, 0x0a, 0x0d, 0x5f, 0x69, 0x73,
|
||||||
|
0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x74, 0x79, 0x22, 0x9b, 0x01, 0x0a, 0x0d, 0x52,
|
||||||
|
0x65, 0x61, 0x6c, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05,
|
||||||
|
0x61, 0x6c, 0x69, 0x61, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x61, 0x6c, 0x69,
|
||||||
|
0x61, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
|
||||||
|
0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69,
|
||||||
|
0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73,
|
||||||
|
0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x69, 0x73, 0x5f, 0x70,
|
||||||
|
0x75, 0x62, 0x6c, 0x69, 0x63, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x69, 0x73, 0x50,
|
||||||
|
0x75, 0x62, 0x6c, 0x69, 0x63, 0x12, 0x21, 0x0a, 0x0c, 0x69, 0x73, 0x5f, 0x63, 0x6f, 0x6d, 0x6d,
|
||||||
|
0x75, 0x6e, 0x69, 0x74, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x69, 0x73, 0x43,
|
||||||
|
0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x74, 0x79, 0x22, 0x3d, 0x0a, 0x11, 0x4c, 0x69, 0x73, 0x74,
|
||||||
|
0x52, 0x65, 0x61, 0x6c, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x28, 0x0a,
|
||||||
|
0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x70, 0x72,
|
||||||
|
0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
|
||||||
|
0x65, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x32, 0xb7, 0x02, 0x0a, 0x06, 0x52, 0x65, 0x61, 0x6c,
|
||||||
|
0x6d, 0x73, 0x12, 0x48, 0x0a, 0x12, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x75, 0x6e,
|
||||||
|
0x69, 0x74, 0x79, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c,
|
||||||
|
0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79,
|
||||||
|
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, 0x53, 0x0a, 0x12,
|
||||||
|
0x4c, 0x69, 0x73, 0x74, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x61,
|
||||||
|
0x6c, 0x6d, 0x12, 0x21, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x61, 0x6c, 0x6d,
|
||||||
|
0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x57, 0x69, 0x74, 0x68, 0x55, 0x73, 0x65, 0x72, 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, 0x0e, 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x77, 0x6e, 0x65, 0x64, 0x52, 0x65,
|
||||||
|
0x61, 0x6c, 0x6d, 0x12, 0x21, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x61, 0x6c,
|
||||||
|
0x6d, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x57, 0x69, 0x74, 0x68, 0x55, 0x73, 0x65, 0x72, 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, 0x3d, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x12, 0x19,
|
||||||
|
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x4c, 0x6f, 0x6f, 0x6b,
|
||||||
|
0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||||
|
0x6f, 0x2e, 0x52, 0x65, 0x61, 0x6c, 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 (
|
||||||
|
file_realms_proto_rawDescOnce sync.Once
|
||||||
|
file_realms_proto_rawDescData = file_realms_proto_rawDesc
|
||||||
|
)
|
||||||
|
|
||||||
|
func file_realms_proto_rawDescGZIP() []byte {
|
||||||
|
file_realms_proto_rawDescOnce.Do(func() {
|
||||||
|
file_realms_proto_rawDescData = protoimpl.X.CompressGZIP(file_realms_proto_rawDescData)
|
||||||
|
})
|
||||||
|
return file_realms_proto_rawDescData
|
||||||
|
}
|
||||||
|
|
||||||
|
var file_realms_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
||||||
|
var file_realms_proto_goTypes = []interface{}{
|
||||||
|
(*RealmLookupWithUserRequest)(nil), // 0: proto.RealmLookupWithUserRequest
|
||||||
|
(*RealmLookupRequest)(nil), // 1: proto.RealmLookupRequest
|
||||||
|
(*RealmResponse)(nil), // 2: proto.RealmResponse
|
||||||
|
(*ListRealmResponse)(nil), // 3: proto.ListRealmResponse
|
||||||
|
(*emptypb.Empty)(nil), // 4: google.protobuf.Empty
|
||||||
|
}
|
||||||
|
var file_realms_proto_depIdxs = []int32{
|
||||||
|
2, // 0: proto.ListRealmResponse.data:type_name -> proto.RealmResponse
|
||||||
|
4, // 1: proto.Realms.ListCommunityRealm:input_type -> google.protobuf.Empty
|
||||||
|
0, // 2: proto.Realms.ListAvailableRealm:input_type -> proto.RealmLookupWithUserRequest
|
||||||
|
0, // 3: proto.Realms.ListOwnedRealm:input_type -> proto.RealmLookupWithUserRequest
|
||||||
|
1, // 4: proto.Realms.GetRealm:input_type -> proto.RealmLookupRequest
|
||||||
|
3, // 5: proto.Realms.ListCommunityRealm:output_type -> proto.ListRealmResponse
|
||||||
|
3, // 6: proto.Realms.ListAvailableRealm:output_type -> proto.ListRealmResponse
|
||||||
|
3, // 7: proto.Realms.ListOwnedRealm:output_type -> proto.ListRealmResponse
|
||||||
|
2, // 8: proto.Realms.GetRealm:output_type -> proto.RealmResponse
|
||||||
|
5, // [5:9] is the sub-list for method output_type
|
||||||
|
1, // [1:5] is the sub-list for method input_type
|
||||||
|
1, // [1:1] is the sub-list for extension type_name
|
||||||
|
1, // [1:1] is the sub-list for extension extendee
|
||||||
|
0, // [0:1] is the sub-list for field type_name
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() { file_realms_proto_init() }
|
||||||
|
func file_realms_proto_init() {
|
||||||
|
if File_realms_proto != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !protoimpl.UnsafeEnabled {
|
||||||
|
file_realms_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*RealmLookupWithUserRequest); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_realms_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*RealmLookupRequest); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_realms_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*RealmResponse); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_realms_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*ListRealmResponse); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_realms_proto_msgTypes[1].OneofWrappers = []interface{}{}
|
||||||
|
type x struct{}
|
||||||
|
out := protoimpl.TypeBuilder{
|
||||||
|
File: protoimpl.DescBuilder{
|
||||||
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
|
RawDescriptor: file_realms_proto_rawDesc,
|
||||||
|
NumEnums: 0,
|
||||||
|
NumMessages: 4,
|
||||||
|
NumExtensions: 0,
|
||||||
|
NumServices: 1,
|
||||||
|
},
|
||||||
|
GoTypes: file_realms_proto_goTypes,
|
||||||
|
DependencyIndexes: file_realms_proto_depIdxs,
|
||||||
|
MessageInfos: file_realms_proto_msgTypes,
|
||||||
|
}.Build()
|
||||||
|
File_realms_proto = out.File
|
||||||
|
file_realms_proto_rawDesc = nil
|
||||||
|
file_realms_proto_goTypes = nil
|
||||||
|
file_realms_proto_depIdxs = nil
|
||||||
|
}
|
37
pkg/grpc/proto/realms.proto
Normal file
37
pkg/grpc/proto/realms.proto
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
import "google/protobuf/empty.proto";
|
||||||
|
|
||||||
|
option go_package = ".;proto";
|
||||||
|
|
||||||
|
package proto;
|
||||||
|
|
||||||
|
service Realms {
|
||||||
|
rpc ListCommunityRealm(google.protobuf.Empty) returns (ListRealmResponse) {}
|
||||||
|
rpc ListAvailableRealm(RealmLookupWithUserRequest) returns (ListRealmResponse) {}
|
||||||
|
rpc ListOwnedRealm(RealmLookupWithUserRequest) returns (ListRealmResponse) {}
|
||||||
|
rpc GetRealm(RealmLookupRequest) returns (RealmResponse) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
message RealmLookupWithUserRequest {
|
||||||
|
uint64 user_id = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message RealmLookupRequest {
|
||||||
|
optional uint64 id = 1;
|
||||||
|
optional string alias = 2;
|
||||||
|
optional bool is_public = 3;
|
||||||
|
optional bool is_community = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message RealmResponse {
|
||||||
|
string alias = 1;
|
||||||
|
string name = 2;
|
||||||
|
string description = 3;
|
||||||
|
bool is_public = 4;
|
||||||
|
bool is_community = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ListRealmResponse {
|
||||||
|
repeated RealmResponse data = 1;
|
||||||
|
}
|
221
pkg/grpc/proto/realms_grpc.pb.go
Normal file
221
pkg/grpc/proto/realms_grpc.pb.go
Normal file
@ -0,0 +1,221 @@
|
|||||||
|
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||||
|
// versions:
|
||||||
|
// - protoc-gen-go-grpc v1.3.0
|
||||||
|
// - protoc v5.26.1
|
||||||
|
// source: realms.proto
|
||||||
|
|
||||||
|
package proto
|
||||||
|
|
||||||
|
import (
|
||||||
|
context "context"
|
||||||
|
grpc "google.golang.org/grpc"
|
||||||
|
codes "google.golang.org/grpc/codes"
|
||||||
|
status "google.golang.org/grpc/status"
|
||||||
|
emptypb "google.golang.org/protobuf/types/known/emptypb"
|
||||||
|
)
|
||||||
|
|
||||||
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
|
// is compatible with the grpc package it is being compiled against.
|
||||||
|
// Requires gRPC-Go v1.32.0 or later.
|
||||||
|
const _ = grpc.SupportPackageIsVersion7
|
||||||
|
|
||||||
|
const (
|
||||||
|
Realms_ListCommunityRealm_FullMethodName = "/proto.Realms/ListCommunityRealm"
|
||||||
|
Realms_ListAvailableRealm_FullMethodName = "/proto.Realms/ListAvailableRealm"
|
||||||
|
Realms_ListOwnedRealm_FullMethodName = "/proto.Realms/ListOwnedRealm"
|
||||||
|
Realms_GetRealm_FullMethodName = "/proto.Realms/GetRealm"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RealmsClient is the client API for Realms service.
|
||||||
|
//
|
||||||
|
// 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 RealmsClient interface {
|
||||||
|
ListCommunityRealm(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*ListRealmResponse, error)
|
||||||
|
ListAvailableRealm(ctx context.Context, in *RealmLookupWithUserRequest, opts ...grpc.CallOption) (*ListRealmResponse, error)
|
||||||
|
ListOwnedRealm(ctx context.Context, in *RealmLookupWithUserRequest, opts ...grpc.CallOption) (*ListRealmResponse, error)
|
||||||
|
GetRealm(ctx context.Context, in *RealmLookupRequest, opts ...grpc.CallOption) (*RealmResponse, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type realmsClient struct {
|
||||||
|
cc grpc.ClientConnInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewRealmsClient(cc grpc.ClientConnInterface) RealmsClient {
|
||||||
|
return &realmsClient{cc}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *realmsClient) ListCommunityRealm(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*ListRealmResponse, error) {
|
||||||
|
out := new(ListRealmResponse)
|
||||||
|
err := c.cc.Invoke(ctx, Realms_ListCommunityRealm_FullMethodName, in, out, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *realmsClient) ListAvailableRealm(ctx context.Context, in *RealmLookupWithUserRequest, opts ...grpc.CallOption) (*ListRealmResponse, error) {
|
||||||
|
out := new(ListRealmResponse)
|
||||||
|
err := c.cc.Invoke(ctx, Realms_ListAvailableRealm_FullMethodName, in, out, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *realmsClient) ListOwnedRealm(ctx context.Context, in *RealmLookupWithUserRequest, opts ...grpc.CallOption) (*ListRealmResponse, error) {
|
||||||
|
out := new(ListRealmResponse)
|
||||||
|
err := c.cc.Invoke(ctx, Realms_ListOwnedRealm_FullMethodName, in, out, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *realmsClient) GetRealm(ctx context.Context, in *RealmLookupRequest, opts ...grpc.CallOption) (*RealmResponse, error) {
|
||||||
|
out := new(RealmResponse)
|
||||||
|
err := c.cc.Invoke(ctx, Realms_GetRealm_FullMethodName, in, out, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RealmsServer is the server API for Realms service.
|
||||||
|
// All implementations must embed UnimplementedRealmsServer
|
||||||
|
// for forward compatibility
|
||||||
|
type RealmsServer interface {
|
||||||
|
ListCommunityRealm(context.Context, *emptypb.Empty) (*ListRealmResponse, error)
|
||||||
|
ListAvailableRealm(context.Context, *RealmLookupWithUserRequest) (*ListRealmResponse, error)
|
||||||
|
ListOwnedRealm(context.Context, *RealmLookupWithUserRequest) (*ListRealmResponse, error)
|
||||||
|
GetRealm(context.Context, *RealmLookupRequest) (*RealmResponse, error)
|
||||||
|
mustEmbedUnimplementedRealmsServer()
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnimplementedRealmsServer must be embedded to have forward compatible implementations.
|
||||||
|
type UnimplementedRealmsServer struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (UnimplementedRealmsServer) ListCommunityRealm(context.Context, *emptypb.Empty) (*ListRealmResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method ListCommunityRealm not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedRealmsServer) ListAvailableRealm(context.Context, *RealmLookupWithUserRequest) (*ListRealmResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method ListAvailableRealm not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedRealmsServer) ListOwnedRealm(context.Context, *RealmLookupWithUserRequest) (*ListRealmResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method ListOwnedRealm not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedRealmsServer) GetRealm(context.Context, *RealmLookupRequest) (*RealmResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method GetRealm not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedRealmsServer) mustEmbedUnimplementedRealmsServer() {}
|
||||||
|
|
||||||
|
// UnsafeRealmsServer may be embedded to opt out of forward compatibility for this service.
|
||||||
|
// Use of this interface is not recommended, as added methods to RealmsServer will
|
||||||
|
// result in compilation errors.
|
||||||
|
type UnsafeRealmsServer interface {
|
||||||
|
mustEmbedUnimplementedRealmsServer()
|
||||||
|
}
|
||||||
|
|
||||||
|
func RegisterRealmsServer(s grpc.ServiceRegistrar, srv RealmsServer) {
|
||||||
|
s.RegisterService(&Realms_ServiceDesc, srv)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _Realms_ListCommunityRealm_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(emptypb.Empty)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(RealmsServer).ListCommunityRealm(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: Realms_ListCommunityRealm_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(RealmsServer).ListCommunityRealm(ctx, req.(*emptypb.Empty))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _Realms_ListAvailableRealm_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(RealmLookupWithUserRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(RealmsServer).ListAvailableRealm(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: Realms_ListAvailableRealm_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(RealmsServer).ListAvailableRealm(ctx, req.(*RealmLookupWithUserRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _Realms_ListOwnedRealm_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(RealmLookupWithUserRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(RealmsServer).ListOwnedRealm(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: Realms_ListOwnedRealm_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(RealmsServer).ListOwnedRealm(ctx, req.(*RealmLookupWithUserRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _Realms_GetRealm_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(RealmLookupRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(RealmsServer).GetRealm(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: Realms_GetRealm_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(RealmsServer).GetRealm(ctx, req.(*RealmLookupRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Realms_ServiceDesc is the grpc.ServiceDesc for Realms service.
|
||||||
|
// It's only intended for direct use with grpc.RegisterService,
|
||||||
|
// and not to be introspected or modified (even as a copy)
|
||||||
|
var Realms_ServiceDesc = grpc.ServiceDesc{
|
||||||
|
ServiceName: "proto.Realms",
|
||||||
|
HandlerType: (*RealmsServer)(nil),
|
||||||
|
Methods: []grpc.MethodDesc{
|
||||||
|
{
|
||||||
|
MethodName: "ListCommunityRealm",
|
||||||
|
Handler: _Realms_ListCommunityRealm_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "ListAvailableRealm",
|
||||||
|
Handler: _Realms_ListAvailableRealm_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "ListOwnedRealm",
|
||||||
|
Handler: _Realms_ListOwnedRealm_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "GetRealm",
|
||||||
|
Handler: _Realms_GetRealm_Handler,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Streams: []grpc.StreamDesc{},
|
||||||
|
Metadata: "realms.proto",
|
||||||
|
}
|
107
pkg/grpc/realms.go
Normal file
107
pkg/grpc/realms.go
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
package grpc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"git.solsynth.dev/hydrogen/passport/pkg/database"
|
||||||
|
"git.solsynth.dev/hydrogen/passport/pkg/grpc/proto"
|
||||||
|
"git.solsynth.dev/hydrogen/passport/pkg/models"
|
||||||
|
"git.solsynth.dev/hydrogen/passport/pkg/services"
|
||||||
|
"github.com/samber/lo"
|
||||||
|
"google.golang.org/protobuf/types/known/emptypb"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (v *Server) ListCommunityRealm(ctx context.Context, empty *emptypb.Empty) (*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.RealmResponse {
|
||||||
|
return &proto.RealmResponse{
|
||||||
|
Alias: item.Alias,
|
||||||
|
Name: item.Name,
|
||||||
|
Description: item.Description,
|
||||||
|
IsPublic: item.IsPublic,
|
||||||
|
IsCommunity: item.IsCommunity,
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *Server) ListAvailableRealm(ctx context.Context, request *proto.RealmLookupWithUserRequest) (*proto.ListRealmResponse, error) {
|
||||||
|
account, err := services.GetAccount(uint(request.GetUserId()))
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("unable to find target account: %v", err)
|
||||||
|
}
|
||||||
|
realms, err := services.ListAvailableRealm(account)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &proto.ListRealmResponse{
|
||||||
|
Data: lo.Map(realms, func(item models.Realm, index int) *proto.RealmResponse {
|
||||||
|
return &proto.RealmResponse{
|
||||||
|
Alias: item.Alias,
|
||||||
|
Name: item.Name,
|
||||||
|
Description: item.Description,
|
||||||
|
IsPublic: item.IsPublic,
|
||||||
|
IsCommunity: item.IsCommunity,
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *Server) ListOwnedRealm(ctx context.Context, request *proto.RealmLookupWithUserRequest) (*proto.ListRealmResponse, error) {
|
||||||
|
account, err := services.GetAccount(uint(request.GetUserId()))
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("unable to find target account: %v", err)
|
||||||
|
}
|
||||||
|
realms, err := services.ListOwnedRealm(account)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &proto.ListRealmResponse{
|
||||||
|
Data: lo.Map(realms, func(item models.Realm, index int) *proto.RealmResponse {
|
||||||
|
return &proto.RealmResponse{
|
||||||
|
Alias: item.Alias,
|
||||||
|
Name: item.Name,
|
||||||
|
Description: item.Description,
|
||||||
|
IsPublic: item.IsPublic,
|
||||||
|
IsCommunity: item.IsCommunity,
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *Server) GetRealm(ctx context.Context, request *proto.RealmLookupRequest) (*proto.RealmResponse, error) {
|
||||||
|
var realm models.Realm
|
||||||
|
|
||||||
|
tx := database.C.Model(&models.Realm{})
|
||||||
|
if request.Id != nil {
|
||||||
|
tx = tx.Where("id = ?", request.GetId())
|
||||||
|
}
|
||||||
|
if request.Alias != nil {
|
||||||
|
tx = tx.Where("alias = ?", request.GetAlias())
|
||||||
|
}
|
||||||
|
if request.IsPublic != nil {
|
||||||
|
tx = tx.Where("is_public = ?", request.GetIsPublic())
|
||||||
|
}
|
||||||
|
if request.IsCommunity != nil {
|
||||||
|
tx = tx.Where("is_community = ?", request.GetIsCommunity())
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := tx.First(&realm).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &proto.RealmResponse{
|
||||||
|
Alias: realm.Alias,
|
||||||
|
Name: realm.Name,
|
||||||
|
Description: realm.Description,
|
||||||
|
IsPublic: realm.IsPublic,
|
||||||
|
IsCommunity: realm.IsCommunity,
|
||||||
|
}, nil
|
||||||
|
}
|
@ -13,6 +13,7 @@ type Server struct {
|
|||||||
proto.UnimplementedAuthServer
|
proto.UnimplementedAuthServer
|
||||||
proto.UnimplementedNotifyServer
|
proto.UnimplementedNotifyServer
|
||||||
proto.UnimplementedFriendshipsServer
|
proto.UnimplementedFriendshipsServer
|
||||||
|
proto.UnimplementedRealmsServer
|
||||||
}
|
}
|
||||||
|
|
||||||
func StartGrpc() error {
|
func StartGrpc() error {
|
||||||
@ -26,6 +27,7 @@ func StartGrpc() error {
|
|||||||
proto.RegisterAuthServer(server, &Server{})
|
proto.RegisterAuthServer(server, &Server{})
|
||||||
proto.RegisterNotifyServer(server, &Server{})
|
proto.RegisterNotifyServer(server, &Server{})
|
||||||
proto.RegisterFriendshipsServer(server, &Server{})
|
proto.RegisterFriendshipsServer(server, &Server{})
|
||||||
|
proto.RegisterRealmsServer(server, &Server{})
|
||||||
|
|
||||||
reflection.Register(server)
|
reflection.Register(server)
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ func listCommunityRealm(c *fiber.Ctx) error {
|
|||||||
|
|
||||||
func listOwnedRealm(c *fiber.Ctx) error {
|
func listOwnedRealm(c *fiber.Ctx) error {
|
||||||
user := c.Locals("principal").(models.Account)
|
user := c.Locals("principal").(models.Account)
|
||||||
if realms, err := services.ListRealmWithUser(user); err != nil {
|
if realms, err := services.ListOwnedRealm(user); err != nil {
|
||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||||
} else {
|
} else {
|
||||||
return c.JSON(realms)
|
return c.JSON(realms)
|
||||||
@ -37,7 +37,7 @@ func listOwnedRealm(c *fiber.Ctx) error {
|
|||||||
|
|
||||||
func listAvailableRealm(c *fiber.Ctx) error {
|
func listAvailableRealm(c *fiber.Ctx) error {
|
||||||
user := c.Locals("principal").(models.Account)
|
user := c.Locals("principal").(models.Account)
|
||||||
if realms, err := services.ListRealmIsAvailable(user); err != nil {
|
if realms, err := services.ListAvailableRealm(user); err != nil {
|
||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||||
} else {
|
} else {
|
||||||
return c.JSON(realms)
|
return c.JSON(realms)
|
||||||
|
@ -18,7 +18,7 @@ func ListCommunityRealm() ([]models.Realm, error) {
|
|||||||
return realms, nil
|
return realms, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ListRealmWithUser(user models.Account) ([]models.Realm, error) {
|
func ListOwnedRealm(user models.Account) ([]models.Realm, error) {
|
||||||
var realms []models.Realm
|
var realms []models.Realm
|
||||||
if err := database.C.Where(&models.Realm{AccountID: user.ID}).Find(&realms).Error; err != nil {
|
if err := database.C.Where(&models.Realm{AccountID: user.ID}).Find(&realms).Error; err != nil {
|
||||||
return realms, err
|
return realms, err
|
||||||
@ -27,7 +27,7 @@ func ListRealmWithUser(user models.Account) ([]models.Realm, error) {
|
|||||||
return realms, nil
|
return realms, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ListRealmIsAvailable(user models.Account) ([]models.Realm, error) {
|
func ListAvailableRealm(user models.Account) ([]models.Realm, error) {
|
||||||
var realms []models.Realm
|
var realms []models.Realm
|
||||||
var members []models.RealmMember
|
var members []models.RealmMember
|
||||||
if err := database.C.Where(&models.RealmMember{
|
if err := database.C.Where(&models.RealmMember{
|
||||||
|
Loading…
Reference in New Issue
Block a user