api refactor

This commit is contained in:
royalcat 2025-06-02 01:47:31 +04:00
parent 8afb17177e
commit d527a8bddd
18 changed files with 495 additions and 486 deletions

2
.vscode/launch.json vendored
View file

@ -5,7 +5,7 @@
"version": "0.2.0",
"configurations": [
{
"name": "Launch file",
"name": "Launch Konfa Hub",
"type": "go",
"request": "launch",
"mode": "debug",

View file

@ -1,5 +1,5 @@
docker-build-and-push:
docker build --platform linux/arm64/v8,linux/amd64 -t git.kmsign.ru/royalcat/konfa-server:latest --push .
docker build --platform linux/arm64/v8,linux/amd64 -t git.kmsign.ru/royalcat/konfa-hub:latest --push .
proto:
buf generate

View file

@ -52,7 +52,7 @@ func main() {
},
[]string{
"/grpc.reflection.v1alpha.ServerReflection",
"/" + hubv1.HubService_ServiceDesc.ServiceName,
hubv1.HubService_ListAuthProviders_FullMethodName,
},
)
if err != nil {

View file

@ -23,5 +23,5 @@ message VoiceChannel {
string server_id = 1;
string channel_id = 2;
string name = 3;
string voice_relay_id = 4;
repeated string voice_relay_id = 4;
}

View file

@ -1,10 +1,14 @@
syntax = "proto3";
import "konfa/hub/v1/auth_provider.proto";
import "konfa/user/v1/user.proto";
package konfa.hub.v1;
service HubService {
rpc GetUser(GetUserRequest) returns (GetUserResponse) {}
rpc CurrentUser(CurrentUserRequest) returns (CurrentUserResponse) {}
rpc ListServerIDs(ListServersRequest) returns (ListServersResponse);
rpc ListVoiceRelays(ListVoiceRelaysRequest) returns (ListVoiceRelaysResponse);
rpc ListAuthProviders(ListAuthProvidersRequest)
@ -26,5 +30,10 @@ message VoiceRelay {
message ListVoiceRelaysResponse { repeated VoiceRelay voice_relays = 1; }
message ListAuthProvidersRequest {}
message ListAuthProvidersResponse { repeated AuthProvider auth_providers = 1; }
message ListAuthProvidersResponse { repeated AuthProvider auth_providers = 1; }
message GetUserRequest { string id = 1; }
message GetUserResponse { konfa.user.v1.User user = 1; }
message CurrentUserRequest {}
message CurrentUserResponse { konfa.user.v1.User user = 1; }

View file

@ -9,32 +9,16 @@ import "konfa/user/v1/user.proto";
import "konfa/channel/v1/channels.proto";
service ServerService {
rpc ListServerChannels(ListServerChannelsRequest)
returns (ListServerChannelsResponse) {}
rpc ListServerUsers(ListServerUsersRequest)
returns (ListServerUsersResponse) {}
rpc GetUser(GetUserRequest) returns (GetUserResponse) {}
rpc CurrentUser(CurrentUserRequest) returns (CurrentUserResponse) {}
rpc ListChannels(ListChannelsRequest) returns (ListChannelsResponse) {}
rpc ListUsers(ListUsersRequest) returns (ListUsersResponse) {}
rpc CreateChannel(CreateChannelRequest) returns (CreateChannelResponse) {}
}
message CurrentUserRequest {}
message ListChannelsRequest { string server_id = 1; }
message ListChannelsResponse { repeated konfa.channel.v1.Channel channels = 1; }
message CurrentUserResponse { konfa.user.v1.User user = 1; }
message ListServerChannelsRequest { string server_id = 1; }
message ListServerChannelsResponse {
repeated konfa.channel.v1.Channel channels = 1;
}
message ListServerUsersRequest { string server_id = 1; }
message ListServerUsersResponse { repeated konfa.user.v1.User users = 1; }
message GetUserRequest { string user_id = 1; }
message GetUserResponse { konfa.user.v1.User user = 1; }
message ListUsersRequest { string server_id = 1; }
message ListUsersResponse { repeated konfa.user.v1.User users = 1; }
message CreateChannelRequest {
string server_id = 1;

View file

@ -4,6 +4,7 @@ import (
"context"
"database/sql"
"errors"
"log/slog"
"github.com/konfa-chat/hub/pkg/uuid"
"github.com/konfa-chat/hub/src/store"
@ -30,6 +31,8 @@ type Authenticator struct {
provider rs.ResourceServer
db *bun.DB
logger *slog.Logger
}
func NewAuthenticator(ctx context.Context, db *bun.DB, acfg AuthenticatorConfig, skipAuthMethods []string) (*Authenticator, error) {
@ -43,6 +46,7 @@ func NewAuthenticator(ctx context.Context, db *bun.DB, acfg AuthenticatorConfig,
skipAuthMethods: skipAuthMethods,
provider: provider,
db: db,
logger: slog.With("component", "authenticator"),
}, nil
}

View file

@ -11,5 +11,9 @@ type ctxKey string
const ctxUserKey ctxKey = "user"
func CtxGetUser(ctx context.Context) *store.User {
return ctx.Value(ctxUserKey).(*store.User)
user := ctx.Value(ctxUserKey)
if user == nil {
return nil
}
return user.(*store.User)
}

View file

@ -24,16 +24,19 @@ func (a *Authenticator) UnaryAuthenticate(ctx context.Context, req any, info *gr
md, ok := metadata.FromIncomingContext(ctx)
if !ok {
a.logger.Warn("missing metadata")
return nil, errMissingMetadata
}
token := grpcExtractToken(md["authorization"])
if token == "" {
a.logger.Warn("missing token in metadata")
return nil, errInvalidToken
}
ctx, err := a.authorize(ctx, token)
if err != nil {
a.logger.Warn("failed to authorize token", "error", err)
return nil, err
}

View file

@ -2,7 +2,10 @@ package proto
import (
"context"
"fmt"
"github.com/konfa-chat/hub/pkg/uuid"
"github.com/konfa-chat/hub/src/auth"
"github.com/konfa-chat/hub/src/konfa"
hubv1 "github.com/konfa-chat/hub/src/proto/konfa/hub/v1"
)
@ -47,3 +50,32 @@ func (h *HubService) ListServerIDs(ctx context.Context, req *hubv1.ListServersRe
ServerIds: serverIds,
}, nil
}
// GetUser implements serverv1.ServerServiceServer.
func (s *HubService) GetUser(ctx context.Context, req *hubv1.GetUserRequest) (*hubv1.GetUserResponse, error) {
userID, err := uuid.FromString(req.Id)
if err != nil {
return nil, err
}
users, err := s.srv.GetUser(ctx, userID)
if err != nil {
return nil, err
}
return &hubv1.GetUserResponse{
User: mapUser(users),
}, nil
}
// CurrentUser implements serverv1.ServerServiceServer.
func (s *HubService) CurrentUser(ctx context.Context, req *hubv1.CurrentUserRequest) (*hubv1.CurrentUserResponse, error) {
user := auth.CtxGetUser(ctx)
if user == nil {
return nil, fmt.Errorf("user not found in context")
}
return &hubv1.CurrentUserResponse{
User: mapUser(*user),
}, nil
}

View file

@ -168,7 +168,7 @@ type VoiceChannel struct {
ServerId string `protobuf:"bytes,1,opt,name=server_id,json=serverId,proto3" json:"server_id,omitempty"`
ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"`
Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"`
VoiceRelayId string `protobuf:"bytes,4,opt,name=voice_relay_id,json=voiceRelayId,proto3" json:"voice_relay_id,omitempty"`
VoiceRelayId []string `protobuf:"bytes,4,rep,name=voice_relay_id,json=voiceRelayId,proto3" json:"voice_relay_id,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@ -224,11 +224,11 @@ func (x *VoiceChannel) GetName() string {
return ""
}
func (x *VoiceChannel) GetVoiceRelayId() string {
func (x *VoiceChannel) GetVoiceRelayId() []string {
if x != nil {
return x.VoiceRelayId
}
return ""
return nil
}
var File_konfa_channel_v1_channels_proto protoreflect.FileDescriptor
@ -250,7 +250,7 @@ const file_konfa_channel_v1_channels_proto_rawDesc = "" +
"\n" +
"channel_id\x18\x02 \x01(\tR\tchannelId\x12\x12\n" +
"\x04name\x18\x03 \x01(\tR\x04name\x12$\n" +
"\x0evoice_relay_id\x18\x04 \x01(\tR\fvoiceRelayIdB\xc7\x01\n" +
"\x0evoice_relay_id\x18\x04 \x03(\tR\fvoiceRelayIdB\xc7\x01\n" +
"\x14com.konfa.channel.v1B\rChannelsProtoP\x01Z>github.com/konfa-chat/hub/src/proto/konfa/channel/v1;channelv1\xa2\x02\x03KCX\xaa\x02\x10Konfa.Channel.V1\xca\x02\x10Konfa\\Channel\\V1\xe2\x02\x1cKonfa\\Channel\\V1\\GPBMetadata\xea\x02\x12Konfa::Channel::V1b\x06proto3"
var (

View file

@ -7,6 +7,7 @@
package hubv1
import (
v1 "github.com/konfa-chat/hub/src/proto/konfa/user/v1"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
@ -321,11 +322,179 @@ func (x *ListAuthProvidersResponse) GetAuthProviders() []*AuthProvider {
return nil
}
type GetUserRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *GetUserRequest) Reset() {
*x = GetUserRequest{}
mi := &file_konfa_hub_v1_service_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GetUserRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetUserRequest) ProtoMessage() {}
func (x *GetUserRequest) ProtoReflect() protoreflect.Message {
mi := &file_konfa_hub_v1_service_proto_msgTypes[7]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetUserRequest.ProtoReflect.Descriptor instead.
func (*GetUserRequest) Descriptor() ([]byte, []int) {
return file_konfa_hub_v1_service_proto_rawDescGZIP(), []int{7}
}
func (x *GetUserRequest) GetId() string {
if x != nil {
return x.Id
}
return ""
}
type GetUserResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
User *v1.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *GetUserResponse) Reset() {
*x = GetUserResponse{}
mi := &file_konfa_hub_v1_service_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GetUserResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetUserResponse) ProtoMessage() {}
func (x *GetUserResponse) ProtoReflect() protoreflect.Message {
mi := &file_konfa_hub_v1_service_proto_msgTypes[8]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetUserResponse.ProtoReflect.Descriptor instead.
func (*GetUserResponse) Descriptor() ([]byte, []int) {
return file_konfa_hub_v1_service_proto_rawDescGZIP(), []int{8}
}
func (x *GetUserResponse) GetUser() *v1.User {
if x != nil {
return x.User
}
return nil
}
type CurrentUserRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *CurrentUserRequest) Reset() {
*x = CurrentUserRequest{}
mi := &file_konfa_hub_v1_service_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CurrentUserRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CurrentUserRequest) ProtoMessage() {}
func (x *CurrentUserRequest) ProtoReflect() protoreflect.Message {
mi := &file_konfa_hub_v1_service_proto_msgTypes[9]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CurrentUserRequest.ProtoReflect.Descriptor instead.
func (*CurrentUserRequest) Descriptor() ([]byte, []int) {
return file_konfa_hub_v1_service_proto_rawDescGZIP(), []int{9}
}
type CurrentUserResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
User *v1.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *CurrentUserResponse) Reset() {
*x = CurrentUserResponse{}
mi := &file_konfa_hub_v1_service_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CurrentUserResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CurrentUserResponse) ProtoMessage() {}
func (x *CurrentUserResponse) ProtoReflect() protoreflect.Message {
mi := &file_konfa_hub_v1_service_proto_msgTypes[10]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CurrentUserResponse.ProtoReflect.Descriptor instead.
func (*CurrentUserResponse) Descriptor() ([]byte, []int) {
return file_konfa_hub_v1_service_proto_rawDescGZIP(), []int{10}
}
func (x *CurrentUserResponse) GetUser() *v1.User {
if x != nil {
return x.User
}
return nil
}
var File_konfa_hub_v1_service_proto protoreflect.FileDescriptor
const file_konfa_hub_v1_service_proto_rawDesc = "" +
"\n" +
"\x1akonfa/hub/v1/service.proto\x12\fkonfa.hub.v1\x1a konfa/hub/v1/auth_provider.proto\"\x14\n" +
"\x1akonfa/hub/v1/service.proto\x12\fkonfa.hub.v1\x1a konfa/hub/v1/auth_provider.proto\x1a\x18konfa/user/v1/user.proto\"\x14\n" +
"\x12ListServersRequest\"4\n" +
"\x13ListServersResponse\x12\x1d\n" +
"\n" +
@ -340,9 +509,18 @@ const file_konfa_hub_v1_service_proto_rawDesc = "" +
"\fvoice_relays\x18\x01 \x03(\v2\x18.konfa.hub.v1.VoiceRelayR\vvoiceRelays\"\x1a\n" +
"\x18ListAuthProvidersRequest\"^\n" +
"\x19ListAuthProvidersResponse\x12A\n" +
"\x0eauth_providers\x18\x01 \x03(\v2\x1a.konfa.hub.v1.AuthProviderR\rauthProviders2\xa8\x02\n" +
"\x0eauth_providers\x18\x01 \x03(\v2\x1a.konfa.hub.v1.AuthProviderR\rauthProviders\" \n" +
"\x0eGetUserRequest\x12\x0e\n" +
"\x02id\x18\x01 \x01(\tR\x02id\":\n" +
"\x0fGetUserResponse\x12'\n" +
"\x04user\x18\x01 \x01(\v2\x13.konfa.user.v1.UserR\x04user\"\x14\n" +
"\x12CurrentUserRequest\">\n" +
"\x13CurrentUserResponse\x12'\n" +
"\x04user\x18\x01 \x01(\v2\x13.konfa.user.v1.UserR\x04user2\xc8\x03\n" +
"\n" +
"HubService\x12T\n" +
"HubService\x12H\n" +
"\aGetUser\x12\x1c.konfa.hub.v1.GetUserRequest\x1a\x1d.konfa.hub.v1.GetUserResponse\"\x00\x12T\n" +
"\vCurrentUser\x12 .konfa.hub.v1.CurrentUserRequest\x1a!.konfa.hub.v1.CurrentUserResponse\"\x00\x12T\n" +
"\rListServerIDs\x12 .konfa.hub.v1.ListServersRequest\x1a!.konfa.hub.v1.ListServersResponse\x12^\n" +
"\x0fListVoiceRelays\x12$.konfa.hub.v1.ListVoiceRelaysRequest\x1a%.konfa.hub.v1.ListVoiceRelaysResponse\x12d\n" +
"\x11ListAuthProviders\x12&.konfa.hub.v1.ListAuthProvidersRequest\x1a'.konfa.hub.v1.ListAuthProvidersResponseB\xaa\x01\n" +
@ -360,7 +538,7 @@ func file_konfa_hub_v1_service_proto_rawDescGZIP() []byte {
return file_konfa_hub_v1_service_proto_rawDescData
}
var file_konfa_hub_v1_service_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
var file_konfa_hub_v1_service_proto_msgTypes = make([]protoimpl.MessageInfo, 11)
var file_konfa_hub_v1_service_proto_goTypes = []any{
(*ListServersRequest)(nil), // 0: konfa.hub.v1.ListServersRequest
(*ListServersResponse)(nil), // 1: konfa.hub.v1.ListServersResponse
@ -369,22 +547,33 @@ var file_konfa_hub_v1_service_proto_goTypes = []any{
(*ListVoiceRelaysResponse)(nil), // 4: konfa.hub.v1.ListVoiceRelaysResponse
(*ListAuthProvidersRequest)(nil), // 5: konfa.hub.v1.ListAuthProvidersRequest
(*ListAuthProvidersResponse)(nil), // 6: konfa.hub.v1.ListAuthProvidersResponse
(*AuthProvider)(nil), // 7: konfa.hub.v1.AuthProvider
(*GetUserRequest)(nil), // 7: konfa.hub.v1.GetUserRequest
(*GetUserResponse)(nil), // 8: konfa.hub.v1.GetUserResponse
(*CurrentUserRequest)(nil), // 9: konfa.hub.v1.CurrentUserRequest
(*CurrentUserResponse)(nil), // 10: konfa.hub.v1.CurrentUserResponse
(*AuthProvider)(nil), // 11: konfa.hub.v1.AuthProvider
(*v1.User)(nil), // 12: konfa.user.v1.User
}
var file_konfa_hub_v1_service_proto_depIdxs = []int32{
3, // 0: konfa.hub.v1.ListVoiceRelaysResponse.voice_relays:type_name -> konfa.hub.v1.VoiceRelay
7, // 1: konfa.hub.v1.ListAuthProvidersResponse.auth_providers:type_name -> konfa.hub.v1.AuthProvider
0, // 2: konfa.hub.v1.HubService.ListServerIDs:input_type -> konfa.hub.v1.ListServersRequest
2, // 3: konfa.hub.v1.HubService.ListVoiceRelays:input_type -> konfa.hub.v1.ListVoiceRelaysRequest
5, // 4: konfa.hub.v1.HubService.ListAuthProviders:input_type -> konfa.hub.v1.ListAuthProvidersRequest
1, // 5: konfa.hub.v1.HubService.ListServerIDs:output_type -> konfa.hub.v1.ListServersResponse
4, // 6: konfa.hub.v1.HubService.ListVoiceRelays:output_type -> konfa.hub.v1.ListVoiceRelaysResponse
6, // 7: konfa.hub.v1.HubService.ListAuthProviders:output_type -> konfa.hub.v1.ListAuthProvidersResponse
5, // [5:8] is the sub-list for method output_type
2, // [2:5] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
3, // 0: konfa.hub.v1.ListVoiceRelaysResponse.voice_relays:type_name -> konfa.hub.v1.VoiceRelay
11, // 1: konfa.hub.v1.ListAuthProvidersResponse.auth_providers:type_name -> konfa.hub.v1.AuthProvider
12, // 2: konfa.hub.v1.GetUserResponse.user:type_name -> konfa.user.v1.User
12, // 3: konfa.hub.v1.CurrentUserResponse.user:type_name -> konfa.user.v1.User
7, // 4: konfa.hub.v1.HubService.GetUser:input_type -> konfa.hub.v1.GetUserRequest
9, // 5: konfa.hub.v1.HubService.CurrentUser:input_type -> konfa.hub.v1.CurrentUserRequest
0, // 6: konfa.hub.v1.HubService.ListServerIDs:input_type -> konfa.hub.v1.ListServersRequest
2, // 7: konfa.hub.v1.HubService.ListVoiceRelays:input_type -> konfa.hub.v1.ListVoiceRelaysRequest
5, // 8: konfa.hub.v1.HubService.ListAuthProviders:input_type -> konfa.hub.v1.ListAuthProvidersRequest
8, // 9: konfa.hub.v1.HubService.GetUser:output_type -> konfa.hub.v1.GetUserResponse
10, // 10: konfa.hub.v1.HubService.CurrentUser:output_type -> konfa.hub.v1.CurrentUserResponse
1, // 11: konfa.hub.v1.HubService.ListServerIDs:output_type -> konfa.hub.v1.ListServersResponse
4, // 12: konfa.hub.v1.HubService.ListVoiceRelays:output_type -> konfa.hub.v1.ListVoiceRelaysResponse
6, // 13: konfa.hub.v1.HubService.ListAuthProviders:output_type -> konfa.hub.v1.ListAuthProvidersResponse
9, // [9:14] is the sub-list for method output_type
4, // [4:9] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension type_name
4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name
}
func init() { file_konfa_hub_v1_service_proto_init() }
@ -399,7 +588,7 @@ func file_konfa_hub_v1_service_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_konfa_hub_v1_service_proto_rawDesc), len(file_konfa_hub_v1_service_proto_rawDesc)),
NumEnums: 0,
NumMessages: 7,
NumMessages: 11,
NumExtensions: 0,
NumServices: 1,
},

View file

@ -19,6 +19,8 @@ import (
const _ = grpc.SupportPackageIsVersion9
const (
HubService_GetUser_FullMethodName = "/konfa.hub.v1.HubService/GetUser"
HubService_CurrentUser_FullMethodName = "/konfa.hub.v1.HubService/CurrentUser"
HubService_ListServerIDs_FullMethodName = "/konfa.hub.v1.HubService/ListServerIDs"
HubService_ListVoiceRelays_FullMethodName = "/konfa.hub.v1.HubService/ListVoiceRelays"
HubService_ListAuthProviders_FullMethodName = "/konfa.hub.v1.HubService/ListAuthProviders"
@ -28,6 +30,8 @@ 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 HubServiceClient interface {
GetUser(ctx context.Context, in *GetUserRequest, opts ...grpc.CallOption) (*GetUserResponse, error)
CurrentUser(ctx context.Context, in *CurrentUserRequest, opts ...grpc.CallOption) (*CurrentUserResponse, error)
ListServerIDs(ctx context.Context, in *ListServersRequest, opts ...grpc.CallOption) (*ListServersResponse, error)
ListVoiceRelays(ctx context.Context, in *ListVoiceRelaysRequest, opts ...grpc.CallOption) (*ListVoiceRelaysResponse, error)
ListAuthProviders(ctx context.Context, in *ListAuthProvidersRequest, opts ...grpc.CallOption) (*ListAuthProvidersResponse, error)
@ -41,6 +45,26 @@ func NewHubServiceClient(cc grpc.ClientConnInterface) HubServiceClient {
return &hubServiceClient{cc}
}
func (c *hubServiceClient) GetUser(ctx context.Context, in *GetUserRequest, opts ...grpc.CallOption) (*GetUserResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(GetUserResponse)
err := c.cc.Invoke(ctx, HubService_GetUser_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *hubServiceClient) CurrentUser(ctx context.Context, in *CurrentUserRequest, opts ...grpc.CallOption) (*CurrentUserResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(CurrentUserResponse)
err := c.cc.Invoke(ctx, HubService_CurrentUser_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *hubServiceClient) ListServerIDs(ctx context.Context, in *ListServersRequest, opts ...grpc.CallOption) (*ListServersResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ListServersResponse)
@ -75,6 +99,8 @@ func (c *hubServiceClient) ListAuthProviders(ctx context.Context, in *ListAuthPr
// All implementations should embed UnimplementedHubServiceServer
// for forward compatibility.
type HubServiceServer interface {
GetUser(context.Context, *GetUserRequest) (*GetUserResponse, error)
CurrentUser(context.Context, *CurrentUserRequest) (*CurrentUserResponse, error)
ListServerIDs(context.Context, *ListServersRequest) (*ListServersResponse, error)
ListVoiceRelays(context.Context, *ListVoiceRelaysRequest) (*ListVoiceRelaysResponse, error)
ListAuthProviders(context.Context, *ListAuthProvidersRequest) (*ListAuthProvidersResponse, error)
@ -87,6 +113,12 @@ type HubServiceServer interface {
// pointer dereference when methods are called.
type UnimplementedHubServiceServer struct{}
func (UnimplementedHubServiceServer) GetUser(context.Context, *GetUserRequest) (*GetUserResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetUser not implemented")
}
func (UnimplementedHubServiceServer) CurrentUser(context.Context, *CurrentUserRequest) (*CurrentUserResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method CurrentUser not implemented")
}
func (UnimplementedHubServiceServer) ListServerIDs(context.Context, *ListServersRequest) (*ListServersResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListServerIDs not implemented")
}
@ -116,6 +148,42 @@ func RegisterHubServiceServer(s grpc.ServiceRegistrar, srv HubServiceServer) {
s.RegisterService(&HubService_ServiceDesc, srv)
}
func _HubService_GetUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetUserRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(HubServiceServer).GetUser(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: HubService_GetUser_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(HubServiceServer).GetUser(ctx, req.(*GetUserRequest))
}
return interceptor(ctx, in, info, handler)
}
func _HubService_CurrentUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CurrentUserRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(HubServiceServer).CurrentUser(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: HubService_CurrentUser_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(HubServiceServer).CurrentUser(ctx, req.(*CurrentUserRequest))
}
return interceptor(ctx, in, info, handler)
}
func _HubService_ListServerIDs_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ListServersRequest)
if err := dec(in); err != nil {
@ -177,6 +245,14 @@ var HubService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "konfa.hub.v1.HubService",
HandlerType: (*HubServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "GetUser",
Handler: _HubService_GetUser_Handler,
},
{
MethodName: "CurrentUser",
Handler: _HubService_CurrentUser_Handler,
},
{
MethodName: "ListServerIDs",
Handler: _HubService_ListServerIDs_Handler,

View file

@ -7,8 +7,8 @@
package serverv1
import (
v11 "github.com/konfa-chat/hub/src/proto/konfa/channel/v1"
v1 "github.com/konfa-chat/hub/src/proto/konfa/user/v1"
v1 "github.com/konfa-chat/hub/src/proto/konfa/channel/v1"
v11 "github.com/konfa-chat/hub/src/proto/konfa/user/v1"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
@ -66,111 +66,31 @@ func (x CreateChannelRequest_ChannelType) Number() protoreflect.EnumNumber {
// Deprecated: Use CreateChannelRequest_ChannelType.Descriptor instead.
func (CreateChannelRequest_ChannelType) EnumDescriptor() ([]byte, []int) {
return file_konfa_server_v1_service_proto_rawDescGZIP(), []int{8, 0}
return file_konfa_server_v1_service_proto_rawDescGZIP(), []int{4, 0}
}
type CurrentUserRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *CurrentUserRequest) Reset() {
*x = CurrentUserRequest{}
mi := &file_konfa_server_v1_service_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CurrentUserRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CurrentUserRequest) ProtoMessage() {}
func (x *CurrentUserRequest) ProtoReflect() protoreflect.Message {
mi := &file_konfa_server_v1_service_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CurrentUserRequest.ProtoReflect.Descriptor instead.
func (*CurrentUserRequest) Descriptor() ([]byte, []int) {
return file_konfa_server_v1_service_proto_rawDescGZIP(), []int{0}
}
type CurrentUserResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
User *v1.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *CurrentUserResponse) Reset() {
*x = CurrentUserResponse{}
mi := &file_konfa_server_v1_service_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CurrentUserResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CurrentUserResponse) ProtoMessage() {}
func (x *CurrentUserResponse) ProtoReflect() protoreflect.Message {
mi := &file_konfa_server_v1_service_proto_msgTypes[1]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CurrentUserResponse.ProtoReflect.Descriptor instead.
func (*CurrentUserResponse) Descriptor() ([]byte, []int) {
return file_konfa_server_v1_service_proto_rawDescGZIP(), []int{1}
}
func (x *CurrentUserResponse) GetUser() *v1.User {
if x != nil {
return x.User
}
return nil
}
type ListServerChannelsRequest struct {
type ListChannelsRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
ServerId string `protobuf:"bytes,1,opt,name=server_id,json=serverId,proto3" json:"server_id,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ListServerChannelsRequest) Reset() {
*x = ListServerChannelsRequest{}
mi := &file_konfa_server_v1_service_proto_msgTypes[2]
func (x *ListChannelsRequest) Reset() {
*x = ListChannelsRequest{}
mi := &file_konfa_server_v1_service_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ListServerChannelsRequest) String() string {
func (x *ListChannelsRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListServerChannelsRequest) ProtoMessage() {}
func (*ListChannelsRequest) ProtoMessage() {}
func (x *ListServerChannelsRequest) ProtoReflect() protoreflect.Message {
mi := &file_konfa_server_v1_service_proto_msgTypes[2]
func (x *ListChannelsRequest) ProtoReflect() protoreflect.Message {
mi := &file_konfa_server_v1_service_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -181,40 +101,40 @@ func (x *ListServerChannelsRequest) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
// Deprecated: Use ListServerChannelsRequest.ProtoReflect.Descriptor instead.
func (*ListServerChannelsRequest) Descriptor() ([]byte, []int) {
return file_konfa_server_v1_service_proto_rawDescGZIP(), []int{2}
// Deprecated: Use ListChannelsRequest.ProtoReflect.Descriptor instead.
func (*ListChannelsRequest) Descriptor() ([]byte, []int) {
return file_konfa_server_v1_service_proto_rawDescGZIP(), []int{0}
}
func (x *ListServerChannelsRequest) GetServerId() string {
func (x *ListChannelsRequest) GetServerId() string {
if x != nil {
return x.ServerId
}
return ""
}
type ListServerChannelsResponse struct {
type ListChannelsResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
Channels []*v11.Channel `protobuf:"bytes,1,rep,name=channels,proto3" json:"channels,omitempty"`
Channels []*v1.Channel `protobuf:"bytes,1,rep,name=channels,proto3" json:"channels,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ListServerChannelsResponse) Reset() {
*x = ListServerChannelsResponse{}
mi := &file_konfa_server_v1_service_proto_msgTypes[3]
func (x *ListChannelsResponse) Reset() {
*x = ListChannelsResponse{}
mi := &file_konfa_server_v1_service_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ListServerChannelsResponse) String() string {
func (x *ListChannelsResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListServerChannelsResponse) ProtoMessage() {}
func (*ListChannelsResponse) ProtoMessage() {}
func (x *ListServerChannelsResponse) ProtoReflect() protoreflect.Message {
mi := &file_konfa_server_v1_service_proto_msgTypes[3]
func (x *ListChannelsResponse) ProtoReflect() protoreflect.Message {
mi := &file_konfa_server_v1_service_proto_msgTypes[1]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -225,40 +145,40 @@ func (x *ListServerChannelsResponse) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
// Deprecated: Use ListServerChannelsResponse.ProtoReflect.Descriptor instead.
func (*ListServerChannelsResponse) Descriptor() ([]byte, []int) {
return file_konfa_server_v1_service_proto_rawDescGZIP(), []int{3}
// Deprecated: Use ListChannelsResponse.ProtoReflect.Descriptor instead.
func (*ListChannelsResponse) Descriptor() ([]byte, []int) {
return file_konfa_server_v1_service_proto_rawDescGZIP(), []int{1}
}
func (x *ListServerChannelsResponse) GetChannels() []*v11.Channel {
func (x *ListChannelsResponse) GetChannels() []*v1.Channel {
if x != nil {
return x.Channels
}
return nil
}
type ListServerUsersRequest struct {
type ListUsersRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
ServerId string `protobuf:"bytes,1,opt,name=server_id,json=serverId,proto3" json:"server_id,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ListServerUsersRequest) Reset() {
*x = ListServerUsersRequest{}
mi := &file_konfa_server_v1_service_proto_msgTypes[4]
func (x *ListUsersRequest) Reset() {
*x = ListUsersRequest{}
mi := &file_konfa_server_v1_service_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ListServerUsersRequest) String() string {
func (x *ListUsersRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListServerUsersRequest) ProtoMessage() {}
func (*ListUsersRequest) ProtoMessage() {}
func (x *ListServerUsersRequest) ProtoReflect() protoreflect.Message {
mi := &file_konfa_server_v1_service_proto_msgTypes[4]
func (x *ListUsersRequest) ProtoReflect() protoreflect.Message {
mi := &file_konfa_server_v1_service_proto_msgTypes[2]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -269,40 +189,40 @@ func (x *ListServerUsersRequest) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
// Deprecated: Use ListServerUsersRequest.ProtoReflect.Descriptor instead.
func (*ListServerUsersRequest) Descriptor() ([]byte, []int) {
return file_konfa_server_v1_service_proto_rawDescGZIP(), []int{4}
// Deprecated: Use ListUsersRequest.ProtoReflect.Descriptor instead.
func (*ListUsersRequest) Descriptor() ([]byte, []int) {
return file_konfa_server_v1_service_proto_rawDescGZIP(), []int{2}
}
func (x *ListServerUsersRequest) GetServerId() string {
func (x *ListUsersRequest) GetServerId() string {
if x != nil {
return x.ServerId
}
return ""
}
type ListServerUsersResponse struct {
type ListUsersResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
Users []*v1.User `protobuf:"bytes,1,rep,name=users,proto3" json:"users,omitempty"`
Users []*v11.User `protobuf:"bytes,1,rep,name=users,proto3" json:"users,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ListServerUsersResponse) Reset() {
*x = ListServerUsersResponse{}
mi := &file_konfa_server_v1_service_proto_msgTypes[5]
func (x *ListUsersResponse) Reset() {
*x = ListUsersResponse{}
mi := &file_konfa_server_v1_service_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ListServerUsersResponse) String() string {
func (x *ListUsersResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListServerUsersResponse) ProtoMessage() {}
func (*ListUsersResponse) ProtoMessage() {}
func (x *ListServerUsersResponse) ProtoReflect() protoreflect.Message {
mi := &file_konfa_server_v1_service_proto_msgTypes[5]
func (x *ListUsersResponse) ProtoReflect() protoreflect.Message {
mi := &file_konfa_server_v1_service_proto_msgTypes[3]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -313,106 +233,18 @@ func (x *ListServerUsersResponse) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
// Deprecated: Use ListServerUsersResponse.ProtoReflect.Descriptor instead.
func (*ListServerUsersResponse) Descriptor() ([]byte, []int) {
return file_konfa_server_v1_service_proto_rawDescGZIP(), []int{5}
// Deprecated: Use ListUsersResponse.ProtoReflect.Descriptor instead.
func (*ListUsersResponse) Descriptor() ([]byte, []int) {
return file_konfa_server_v1_service_proto_rawDescGZIP(), []int{3}
}
func (x *ListServerUsersResponse) GetUsers() []*v1.User {
func (x *ListUsersResponse) GetUsers() []*v11.User {
if x != nil {
return x.Users
}
return nil
}
type GetUserRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *GetUserRequest) Reset() {
*x = GetUserRequest{}
mi := &file_konfa_server_v1_service_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GetUserRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetUserRequest) ProtoMessage() {}
func (x *GetUserRequest) ProtoReflect() protoreflect.Message {
mi := &file_konfa_server_v1_service_proto_msgTypes[6]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetUserRequest.ProtoReflect.Descriptor instead.
func (*GetUserRequest) Descriptor() ([]byte, []int) {
return file_konfa_server_v1_service_proto_rawDescGZIP(), []int{6}
}
func (x *GetUserRequest) GetUserId() string {
if x != nil {
return x.UserId
}
return ""
}
type GetUserResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
User *v1.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *GetUserResponse) Reset() {
*x = GetUserResponse{}
mi := &file_konfa_server_v1_service_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GetUserResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetUserResponse) ProtoMessage() {}
func (x *GetUserResponse) ProtoReflect() protoreflect.Message {
mi := &file_konfa_server_v1_service_proto_msgTypes[7]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetUserResponse.ProtoReflect.Descriptor instead.
func (*GetUserResponse) Descriptor() ([]byte, []int) {
return file_konfa_server_v1_service_proto_rawDescGZIP(), []int{7}
}
func (x *GetUserResponse) GetUser() *v1.User {
if x != nil {
return x.User
}
return nil
}
type CreateChannelRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
ServerId string `protobuf:"bytes,1,opt,name=server_id,json=serverId,proto3" json:"server_id,omitempty"`
@ -424,7 +256,7 @@ type CreateChannelRequest struct {
func (x *CreateChannelRequest) Reset() {
*x = CreateChannelRequest{}
mi := &file_konfa_server_v1_service_proto_msgTypes[8]
mi := &file_konfa_server_v1_service_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -436,7 +268,7 @@ func (x *CreateChannelRequest) String() string {
func (*CreateChannelRequest) ProtoMessage() {}
func (x *CreateChannelRequest) ProtoReflect() protoreflect.Message {
mi := &file_konfa_server_v1_service_proto_msgTypes[8]
mi := &file_konfa_server_v1_service_proto_msgTypes[4]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -449,7 +281,7 @@ func (x *CreateChannelRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use CreateChannelRequest.ProtoReflect.Descriptor instead.
func (*CreateChannelRequest) Descriptor() ([]byte, []int) {
return file_konfa_server_v1_service_proto_rawDescGZIP(), []int{8}
return file_konfa_server_v1_service_proto_rawDescGZIP(), []int{4}
}
func (x *CreateChannelRequest) GetServerId() string {
@ -475,14 +307,14 @@ func (x *CreateChannelRequest) GetType() CreateChannelRequest_ChannelType {
type CreateChannelResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
Channel *v11.Channel `protobuf:"bytes,1,opt,name=channel,proto3" json:"channel,omitempty"`
Channel *v1.Channel `protobuf:"bytes,1,opt,name=channel,proto3" json:"channel,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *CreateChannelResponse) Reset() {
*x = CreateChannelResponse{}
mi := &file_konfa_server_v1_service_proto_msgTypes[9]
mi := &file_konfa_server_v1_service_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -494,7 +326,7 @@ func (x *CreateChannelResponse) String() string {
func (*CreateChannelResponse) ProtoMessage() {}
func (x *CreateChannelResponse) ProtoReflect() protoreflect.Message {
mi := &file_konfa_server_v1_service_proto_msgTypes[9]
mi := &file_konfa_server_v1_service_proto_msgTypes[5]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -507,10 +339,10 @@ func (x *CreateChannelResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use CreateChannelResponse.ProtoReflect.Descriptor instead.
func (*CreateChannelResponse) Descriptor() ([]byte, []int) {
return file_konfa_server_v1_service_proto_rawDescGZIP(), []int{9}
return file_konfa_server_v1_service_proto_rawDescGZIP(), []int{5}
}
func (x *CreateChannelResponse) GetChannel() *v11.Channel {
func (x *CreateChannelResponse) GetChannel() *v1.Channel {
if x != nil {
return x.Channel
}
@ -521,22 +353,15 @@ var File_konfa_server_v1_service_proto protoreflect.FileDescriptor
const file_konfa_server_v1_service_proto_rawDesc = "" +
"\n" +
"\x1dkonfa/server/v1/service.proto\x12\x0fkonfa.server.v1\x1a\x18konfa/user/v1/user.proto\x1a\x1fkonfa/channel/v1/channels.proto\"\x14\n" +
"\x12CurrentUserRequest\">\n" +
"\x13CurrentUserResponse\x12'\n" +
"\x04user\x18\x01 \x01(\v2\x13.konfa.user.v1.UserR\x04user\"8\n" +
"\x19ListServerChannelsRequest\x12\x1b\n" +
"\tserver_id\x18\x01 \x01(\tR\bserverId\"S\n" +
"\x1aListServerChannelsResponse\x125\n" +
"\bchannels\x18\x01 \x03(\v2\x19.konfa.channel.v1.ChannelR\bchannels\"5\n" +
"\x16ListServerUsersRequest\x12\x1b\n" +
"\tserver_id\x18\x01 \x01(\tR\bserverId\"D\n" +
"\x17ListServerUsersResponse\x12)\n" +
"\x05users\x18\x01 \x03(\v2\x13.konfa.user.v1.UserR\x05users\")\n" +
"\x0eGetUserRequest\x12\x17\n" +
"\auser_id\x18\x01 \x01(\tR\x06userId\":\n" +
"\x0fGetUserResponse\x12'\n" +
"\x04user\x18\x01 \x01(\v2\x13.konfa.user.v1.UserR\x04user\"\xb2\x01\n" +
"\x1dkonfa/server/v1/service.proto\x12\x0fkonfa.server.v1\x1a\x18konfa/user/v1/user.proto\x1a\x1fkonfa/channel/v1/channels.proto\"2\n" +
"\x13ListChannelsRequest\x12\x1b\n" +
"\tserver_id\x18\x01 \x01(\tR\bserverId\"M\n" +
"\x14ListChannelsResponse\x125\n" +
"\bchannels\x18\x01 \x03(\v2\x19.konfa.channel.v1.ChannelR\bchannels\"/\n" +
"\x10ListUsersRequest\x12\x1b\n" +
"\tserver_id\x18\x01 \x01(\tR\bserverId\">\n" +
"\x11ListUsersResponse\x12)\n" +
"\x05users\x18\x01 \x03(\v2\x13.konfa.user.v1.UserR\x05users\"\xb2\x01\n" +
"\x14CreateChannelRequest\x12\x1b\n" +
"\tserver_id\x18\x01 \x01(\tR\bserverId\x12\x12\n" +
"\x04name\x18\x02 \x01(\tR\x04name\x12E\n" +
@ -545,12 +370,10 @@ const file_konfa_server_v1_service_proto_rawDesc = "" +
"\x04TEXT\x10\x00\x12\t\n" +
"\x05VOICE\x10\x01\"L\n" +
"\x15CreateChannelResponse\x123\n" +
"\achannel\x18\x01 \x01(\v2\x19.konfa.channel.v1.ChannelR\achannel2\xf6\x03\n" +
"\rServerService\x12o\n" +
"\x12ListServerChannels\x12*.konfa.server.v1.ListServerChannelsRequest\x1a+.konfa.server.v1.ListServerChannelsResponse\"\x00\x12f\n" +
"\x0fListServerUsers\x12'.konfa.server.v1.ListServerUsersRequest\x1a(.konfa.server.v1.ListServerUsersResponse\"\x00\x12N\n" +
"\aGetUser\x12\x1f.konfa.server.v1.GetUserRequest\x1a .konfa.server.v1.GetUserResponse\"\x00\x12Z\n" +
"\vCurrentUser\x12#.konfa.server.v1.CurrentUserRequest\x1a$.konfa.server.v1.CurrentUserResponse\"\x00\x12`\n" +
"\achannel\x18\x01 \x01(\v2\x19.konfa.channel.v1.ChannelR\achannel2\xa6\x02\n" +
"\rServerService\x12]\n" +
"\fListChannels\x12$.konfa.server.v1.ListChannelsRequest\x1a%.konfa.server.v1.ListChannelsResponse\"\x00\x12T\n" +
"\tListUsers\x12!.konfa.server.v1.ListUsersRequest\x1a\".konfa.server.v1.ListUsersResponse\"\x00\x12`\n" +
"\rCreateChannel\x12%.konfa.server.v1.CreateChannelRequest\x1a&.konfa.server.v1.CreateChannelResponse\"\x00B\xbf\x01\n" +
"\x13com.konfa.server.v1B\fServiceProtoP\x01Z<github.com/konfa-chat/hub/src/proto/konfa/server/v1;serverv1\xa2\x02\x03KSX\xaa\x02\x0fKonfa.Server.V1\xca\x02\x0fKonfa\\Server\\V1\xe2\x02\x1bKonfa\\Server\\V1\\GPBMetadata\xea\x02\x11Konfa::Server::V1b\x06proto3"
@ -567,44 +390,34 @@ func file_konfa_server_v1_service_proto_rawDescGZIP() []byte {
}
var file_konfa_server_v1_service_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_konfa_server_v1_service_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
var file_konfa_server_v1_service_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_konfa_server_v1_service_proto_goTypes = []any{
(CreateChannelRequest_ChannelType)(0), // 0: konfa.server.v1.CreateChannelRequest.ChannelType
(*CurrentUserRequest)(nil), // 1: konfa.server.v1.CurrentUserRequest
(*CurrentUserResponse)(nil), // 2: konfa.server.v1.CurrentUserResponse
(*ListServerChannelsRequest)(nil), // 3: konfa.server.v1.ListServerChannelsRequest
(*ListServerChannelsResponse)(nil), // 4: konfa.server.v1.ListServerChannelsResponse
(*ListServerUsersRequest)(nil), // 5: konfa.server.v1.ListServerUsersRequest
(*ListServerUsersResponse)(nil), // 6: konfa.server.v1.ListServerUsersResponse
(*GetUserRequest)(nil), // 7: konfa.server.v1.GetUserRequest
(*GetUserResponse)(nil), // 8: konfa.server.v1.GetUserResponse
(*CreateChannelRequest)(nil), // 9: konfa.server.v1.CreateChannelRequest
(*CreateChannelResponse)(nil), // 10: konfa.server.v1.CreateChannelResponse
(*v1.User)(nil), // 11: konfa.user.v1.User
(*v11.Channel)(nil), // 12: konfa.channel.v1.Channel
(*ListChannelsRequest)(nil), // 1: konfa.server.v1.ListChannelsRequest
(*ListChannelsResponse)(nil), // 2: konfa.server.v1.ListChannelsResponse
(*ListUsersRequest)(nil), // 3: konfa.server.v1.ListUsersRequest
(*ListUsersResponse)(nil), // 4: konfa.server.v1.ListUsersResponse
(*CreateChannelRequest)(nil), // 5: konfa.server.v1.CreateChannelRequest
(*CreateChannelResponse)(nil), // 6: konfa.server.v1.CreateChannelResponse
(*v1.Channel)(nil), // 7: konfa.channel.v1.Channel
(*v11.User)(nil), // 8: konfa.user.v1.User
}
var file_konfa_server_v1_service_proto_depIdxs = []int32{
11, // 0: konfa.server.v1.CurrentUserResponse.user:type_name -> konfa.user.v1.User
12, // 1: konfa.server.v1.ListServerChannelsResponse.channels:type_name -> konfa.channel.v1.Channel
11, // 2: konfa.server.v1.ListServerUsersResponse.users:type_name -> konfa.user.v1.User
11, // 3: konfa.server.v1.GetUserResponse.user:type_name -> konfa.user.v1.User
0, // 4: konfa.server.v1.CreateChannelRequest.type:type_name -> konfa.server.v1.CreateChannelRequest.ChannelType
12, // 5: konfa.server.v1.CreateChannelResponse.channel:type_name -> konfa.channel.v1.Channel
3, // 6: konfa.server.v1.ServerService.ListServerChannels:input_type -> konfa.server.v1.ListServerChannelsRequest
5, // 7: konfa.server.v1.ServerService.ListServerUsers:input_type -> konfa.server.v1.ListServerUsersRequest
7, // 8: konfa.server.v1.ServerService.GetUser:input_type -> konfa.server.v1.GetUserRequest
1, // 9: konfa.server.v1.ServerService.CurrentUser:input_type -> konfa.server.v1.CurrentUserRequest
9, // 10: konfa.server.v1.ServerService.CreateChannel:input_type -> konfa.server.v1.CreateChannelRequest
4, // 11: konfa.server.v1.ServerService.ListServerChannels:output_type -> konfa.server.v1.ListServerChannelsResponse
6, // 12: konfa.server.v1.ServerService.ListServerUsers:output_type -> konfa.server.v1.ListServerUsersResponse
8, // 13: konfa.server.v1.ServerService.GetUser:output_type -> konfa.server.v1.GetUserResponse
2, // 14: konfa.server.v1.ServerService.CurrentUser:output_type -> konfa.server.v1.CurrentUserResponse
10, // 15: konfa.server.v1.ServerService.CreateChannel:output_type -> konfa.server.v1.CreateChannelResponse
11, // [11:16] is the sub-list for method output_type
6, // [6:11] is the sub-list for method input_type
6, // [6:6] is the sub-list for extension type_name
6, // [6:6] is the sub-list for extension extendee
0, // [0:6] is the sub-list for field type_name
7, // 0: konfa.server.v1.ListChannelsResponse.channels:type_name -> konfa.channel.v1.Channel
8, // 1: konfa.server.v1.ListUsersResponse.users:type_name -> konfa.user.v1.User
0, // 2: konfa.server.v1.CreateChannelRequest.type:type_name -> konfa.server.v1.CreateChannelRequest.ChannelType
7, // 3: konfa.server.v1.CreateChannelResponse.channel:type_name -> konfa.channel.v1.Channel
1, // 4: konfa.server.v1.ServerService.ListChannels:input_type -> konfa.server.v1.ListChannelsRequest
3, // 5: konfa.server.v1.ServerService.ListUsers:input_type -> konfa.server.v1.ListUsersRequest
5, // 6: konfa.server.v1.ServerService.CreateChannel:input_type -> konfa.server.v1.CreateChannelRequest
2, // 7: konfa.server.v1.ServerService.ListChannels:output_type -> konfa.server.v1.ListChannelsResponse
4, // 8: konfa.server.v1.ServerService.ListUsers:output_type -> konfa.server.v1.ListUsersResponse
6, // 9: konfa.server.v1.ServerService.CreateChannel:output_type -> konfa.server.v1.CreateChannelResponse
7, // [7:10] is the sub-list for method output_type
4, // [4:7] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension type_name
4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name
}
func init() { file_konfa_server_v1_service_proto_init() }
@ -618,7 +431,7 @@ func file_konfa_server_v1_service_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_konfa_server_v1_service_proto_rawDesc), len(file_konfa_server_v1_service_proto_rawDesc)),
NumEnums: 1,
NumMessages: 10,
NumMessages: 6,
NumExtensions: 0,
NumServices: 1,
},

View file

@ -19,21 +19,17 @@ import (
const _ = grpc.SupportPackageIsVersion9
const (
ServerService_ListServerChannels_FullMethodName = "/konfa.server.v1.ServerService/ListServerChannels"
ServerService_ListServerUsers_FullMethodName = "/konfa.server.v1.ServerService/ListServerUsers"
ServerService_GetUser_FullMethodName = "/konfa.server.v1.ServerService/GetUser"
ServerService_CurrentUser_FullMethodName = "/konfa.server.v1.ServerService/CurrentUser"
ServerService_CreateChannel_FullMethodName = "/konfa.server.v1.ServerService/CreateChannel"
ServerService_ListChannels_FullMethodName = "/konfa.server.v1.ServerService/ListChannels"
ServerService_ListUsers_FullMethodName = "/konfa.server.v1.ServerService/ListUsers"
ServerService_CreateChannel_FullMethodName = "/konfa.server.v1.ServerService/CreateChannel"
)
// ServerServiceClient is the client API for ServerService 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 ServerServiceClient interface {
ListServerChannels(ctx context.Context, in *ListServerChannelsRequest, opts ...grpc.CallOption) (*ListServerChannelsResponse, error)
ListServerUsers(ctx context.Context, in *ListServerUsersRequest, opts ...grpc.CallOption) (*ListServerUsersResponse, error)
GetUser(ctx context.Context, in *GetUserRequest, opts ...grpc.CallOption) (*GetUserResponse, error)
CurrentUser(ctx context.Context, in *CurrentUserRequest, opts ...grpc.CallOption) (*CurrentUserResponse, error)
ListChannels(ctx context.Context, in *ListChannelsRequest, opts ...grpc.CallOption) (*ListChannelsResponse, error)
ListUsers(ctx context.Context, in *ListUsersRequest, opts ...grpc.CallOption) (*ListUsersResponse, error)
CreateChannel(ctx context.Context, in *CreateChannelRequest, opts ...grpc.CallOption) (*CreateChannelResponse, error)
}
@ -45,40 +41,20 @@ func NewServerServiceClient(cc grpc.ClientConnInterface) ServerServiceClient {
return &serverServiceClient{cc}
}
func (c *serverServiceClient) ListServerChannels(ctx context.Context, in *ListServerChannelsRequest, opts ...grpc.CallOption) (*ListServerChannelsResponse, error) {
func (c *serverServiceClient) ListChannels(ctx context.Context, in *ListChannelsRequest, opts ...grpc.CallOption) (*ListChannelsResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ListServerChannelsResponse)
err := c.cc.Invoke(ctx, ServerService_ListServerChannels_FullMethodName, in, out, cOpts...)
out := new(ListChannelsResponse)
err := c.cc.Invoke(ctx, ServerService_ListChannels_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *serverServiceClient) ListServerUsers(ctx context.Context, in *ListServerUsersRequest, opts ...grpc.CallOption) (*ListServerUsersResponse, error) {
func (c *serverServiceClient) ListUsers(ctx context.Context, in *ListUsersRequest, opts ...grpc.CallOption) (*ListUsersResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ListServerUsersResponse)
err := c.cc.Invoke(ctx, ServerService_ListServerUsers_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *serverServiceClient) GetUser(ctx context.Context, in *GetUserRequest, opts ...grpc.CallOption) (*GetUserResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(GetUserResponse)
err := c.cc.Invoke(ctx, ServerService_GetUser_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *serverServiceClient) CurrentUser(ctx context.Context, in *CurrentUserRequest, opts ...grpc.CallOption) (*CurrentUserResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(CurrentUserResponse)
err := c.cc.Invoke(ctx, ServerService_CurrentUser_FullMethodName, in, out, cOpts...)
out := new(ListUsersResponse)
err := c.cc.Invoke(ctx, ServerService_ListUsers_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@ -99,10 +75,8 @@ func (c *serverServiceClient) CreateChannel(ctx context.Context, in *CreateChann
// All implementations should embed UnimplementedServerServiceServer
// for forward compatibility.
type ServerServiceServer interface {
ListServerChannels(context.Context, *ListServerChannelsRequest) (*ListServerChannelsResponse, error)
ListServerUsers(context.Context, *ListServerUsersRequest) (*ListServerUsersResponse, error)
GetUser(context.Context, *GetUserRequest) (*GetUserResponse, error)
CurrentUser(context.Context, *CurrentUserRequest) (*CurrentUserResponse, error)
ListChannels(context.Context, *ListChannelsRequest) (*ListChannelsResponse, error)
ListUsers(context.Context, *ListUsersRequest) (*ListUsersResponse, error)
CreateChannel(context.Context, *CreateChannelRequest) (*CreateChannelResponse, error)
}
@ -113,17 +87,11 @@ type ServerServiceServer interface {
// pointer dereference when methods are called.
type UnimplementedServerServiceServer struct{}
func (UnimplementedServerServiceServer) ListServerChannels(context.Context, *ListServerChannelsRequest) (*ListServerChannelsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListServerChannels not implemented")
func (UnimplementedServerServiceServer) ListChannels(context.Context, *ListChannelsRequest) (*ListChannelsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListChannels not implemented")
}
func (UnimplementedServerServiceServer) ListServerUsers(context.Context, *ListServerUsersRequest) (*ListServerUsersResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListServerUsers not implemented")
}
func (UnimplementedServerServiceServer) GetUser(context.Context, *GetUserRequest) (*GetUserResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetUser not implemented")
}
func (UnimplementedServerServiceServer) CurrentUser(context.Context, *CurrentUserRequest) (*CurrentUserResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method CurrentUser not implemented")
func (UnimplementedServerServiceServer) ListUsers(context.Context, *ListUsersRequest) (*ListUsersResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListUsers not implemented")
}
func (UnimplementedServerServiceServer) CreateChannel(context.Context, *CreateChannelRequest) (*CreateChannelResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method CreateChannel not implemented")
@ -148,74 +116,38 @@ func RegisterServerServiceServer(s grpc.ServiceRegistrar, srv ServerServiceServe
s.RegisterService(&ServerService_ServiceDesc, srv)
}
func _ServerService_ListServerChannels_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ListServerChannelsRequest)
func _ServerService_ListChannels_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ListChannelsRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ServerServiceServer).ListServerChannels(ctx, in)
return srv.(ServerServiceServer).ListChannels(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: ServerService_ListServerChannels_FullMethodName,
FullMethod: ServerService_ListChannels_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ServerServiceServer).ListServerChannels(ctx, req.(*ListServerChannelsRequest))
return srv.(ServerServiceServer).ListChannels(ctx, req.(*ListChannelsRequest))
}
return interceptor(ctx, in, info, handler)
}
func _ServerService_ListServerUsers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ListServerUsersRequest)
func _ServerService_ListUsers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ListUsersRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ServerServiceServer).ListServerUsers(ctx, in)
return srv.(ServerServiceServer).ListUsers(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: ServerService_ListServerUsers_FullMethodName,
FullMethod: ServerService_ListUsers_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ServerServiceServer).ListServerUsers(ctx, req.(*ListServerUsersRequest))
}
return interceptor(ctx, in, info, handler)
}
func _ServerService_GetUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetUserRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ServerServiceServer).GetUser(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: ServerService_GetUser_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ServerServiceServer).GetUser(ctx, req.(*GetUserRequest))
}
return interceptor(ctx, in, info, handler)
}
func _ServerService_CurrentUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CurrentUserRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ServerServiceServer).CurrentUser(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: ServerService_CurrentUser_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ServerServiceServer).CurrentUser(ctx, req.(*CurrentUserRequest))
return srv.(ServerServiceServer).ListUsers(ctx, req.(*ListUsersRequest))
}
return interceptor(ctx, in, info, handler)
}
@ -246,20 +178,12 @@ var ServerService_ServiceDesc = grpc.ServiceDesc{
HandlerType: (*ServerServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "ListServerChannels",
Handler: _ServerService_ListServerChannels_Handler,
MethodName: "ListChannels",
Handler: _ServerService_ListChannels_Handler,
},
{
MethodName: "ListServerUsers",
Handler: _ServerService_ListServerUsers_Handler,
},
{
MethodName: "GetUser",
Handler: _ServerService_GetUser_Handler,
},
{
MethodName: "CurrentUser",
Handler: _ServerService_CurrentUser_Handler,
MethodName: "ListUsers",
Handler: _ServerService_ListUsers_Handler,
},
{
MethodName: "CreateChannel",

View file

@ -43,9 +43,10 @@ func mapTextChannel(c store.TextChannel) *channelv1.TextChannel {
func mapVoiceChannel(c store.VoiceChannel) *channelv1.VoiceChannel {
return &channelv1.VoiceChannel{
ServerId: c.ServerID.String(),
ChannelId: c.ID.String(),
Name: c.Name,
ServerId: c.ServerID.String(),
ChannelId: c.ID.String(),
Name: c.Name,
VoiceRelayId: []string{c.RelayID},
}
}

View file

@ -5,7 +5,6 @@ import (
"fmt"
"github.com/konfa-chat/hub/pkg/uuid"
"github.com/konfa-chat/hub/src/auth"
"github.com/konfa-chat/hub/src/konfa"
channelv1 "github.com/konfa-chat/hub/src/proto/konfa/channel/v1"
serverv1 "github.com/konfa-chat/hub/src/proto/konfa/server/v1"
@ -22,8 +21,8 @@ type ServerService struct {
var _ serverv1.ServerServiceServer = (*ServerService)(nil)
// ListServerChannels implements serverv1.ServerServiceServer.
func (s *ServerService) ListServerChannels(ctx context.Context, req *serverv1.ListServerChannelsRequest) (*serverv1.ListServerChannelsResponse, error) {
// ListChannels implements serverv1.ServerServiceServer.
func (s *ServerService) ListChannels(ctx context.Context, req *serverv1.ListChannelsRequest) (*serverv1.ListChannelsResponse, error) {
serverID, err := uuid.FromString(req.ServerId)
if err != nil {
return nil, err
@ -38,19 +37,20 @@ func (s *ServerService) ListServerChannels(ctx context.Context, req *serverv1.Li
ID: serverID,
ServerID: serverID,
Name: "general",
RelayID: s.srv.Config.VoiceRelays[0].ID,
}}
channels := make([]*channelv1.Channel, 0, len(textChannels)+len(voiceChannels))
channels = append(channels, apply(textChannels, mapTextChannelToChannel)...)
channels = append(channels, apply(voiceChannels, mapVoiceChannelToChannel)...)
return &serverv1.ListServerChannelsResponse{
return &serverv1.ListChannelsResponse{
Channels: channels,
}, nil
}
// ListServerUsers implements serverv1.ServerServiceServer.
func (s *ServerService) ListServerUsers(ctx context.Context, req *serverv1.ListServerUsersRequest) (*serverv1.ListServerUsersResponse, error) {
// ListUsers implements serverv1.ServerServiceServer.
func (s *ServerService) ListUsers(ctx context.Context, req *serverv1.ListUsersRequest) (*serverv1.ListUsersResponse, error) {
serverID, err := uuid.FromString(req.ServerId)
if err != nil {
return nil, err
@ -61,40 +61,11 @@ func (s *ServerService) ListServerUsers(ctx context.Context, req *serverv1.ListS
return nil, err
}
return &serverv1.ListServerUsersResponse{
return &serverv1.ListUsersResponse{
Users: apply(users, mapUser),
}, nil
}
// GetUser implements serverv1.ServerServiceServer.
func (s *ServerService) GetUser(ctx context.Context, req *serverv1.GetUserRequest) (*serverv1.GetUserResponse, error) {
userID, err := uuid.FromString(req.UserId)
if err != nil {
return nil, err
}
users, err := s.srv.GetUser(ctx, userID)
if err != nil {
return nil, err
}
return &serverv1.GetUserResponse{
User: mapUser(users),
}, nil
}
// CurrentUser implements serverv1.ServerServiceServer.
func (s *ServerService) CurrentUser(ctx context.Context, req *serverv1.CurrentUserRequest) (*serverv1.CurrentUserResponse, error) {
user := auth.CtxGetUser(ctx)
if user == nil {
return nil, fmt.Errorf("user not found in context")
}
return &serverv1.CurrentUserResponse{
User: mapUser(*user),
}, nil
}
// CreateChannel implements serverv1.ServerServiceServer.
func (s *ServerService) CreateChannel(ctx context.Context, req *serverv1.CreateChannelRequest) (*serverv1.CreateChannelResponse, error) {
serverID, err := uuid.FromString(req.ServerId)
@ -114,7 +85,6 @@ func (s *ServerService) CreateChannel(ctx context.Context, req *serverv1.CreateC
return nil, fmt.Errorf("failed to create text channel: %w", err)
}
// Create the response with a text channel
channel = &channelv1.Channel{
Channel: &channelv1.Channel_TextChannel{
TextChannel: &channelv1.TextChannel{
@ -132,14 +102,13 @@ func (s *ServerService) CreateChannel(ctx context.Context, req *serverv1.CreateC
return nil, fmt.Errorf("failed to create voice channel: %w", err)
}
// Create the response with a voice channel
channel = &channelv1.Channel{
Channel: &channelv1.Channel_VoiceChannel{
VoiceChannel: &channelv1.VoiceChannel{
ServerId: serverID.String(),
ChannelId: channelID.String(),
Name: req.Name,
VoiceRelayId: "", // Empty for now
VoiceRelayId: []string{s.srv.Config.VoiceRelays[0].ID},
},
},
}

View file

@ -39,4 +39,5 @@ type VoiceChannel struct {
ID uuid.UUID `bun:"id,pk"`
ServerID uuid.UUID `bun:"server_id"`
Name string `bun:"name"`
RelayID string `bun:"relay_id"`
}