commit
530c24b019
35 changed files with 3601 additions and 0 deletions
src/proto
49
src/proto/mappers.go
Normal file
49
src/proto/mappers.go
Normal file
|
@ -0,0 +1,49 @@
|
|||
package proto
|
||||
|
||||
import (
|
||||
channelv1 "github.com/royalcat/konfa-server/src/proto/konfa/channel/v1"
|
||||
chatv1 "github.com/royalcat/konfa-server/src/proto/konfa/chat/v1"
|
||||
"github.com/royalcat/konfa-server/src/store"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
|
||||
func mapMessage(msg store.Message) *chatv1.Message {
|
||||
return &chatv1.Message{
|
||||
MessageId: msg.ID.String(),
|
||||
SenderId: msg.SenderID.String(),
|
||||
Content: msg.Content,
|
||||
Timestamp: timestamppb.New(msg.Timestamp),
|
||||
}
|
||||
}
|
||||
|
||||
func mapTextChannelToChannel(c store.TextChannel) *channelv1.Channel {
|
||||
return &channelv1.Channel{
|
||||
Channel: &channelv1.Channel_TextChannel{
|
||||
TextChannel: mapTextChannel(c),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func mapVoiceChannelToChannel(c store.VoiceChannel) *channelv1.Channel {
|
||||
return &channelv1.Channel{
|
||||
Channel: &channelv1.Channel_VoiceChannel{
|
||||
VoiceChannel: mapVoiceChannel(c),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func mapTextChannel(c store.TextChannel) *channelv1.TextChannel {
|
||||
return &channelv1.TextChannel{
|
||||
ServerId: c.ServerID.String(),
|
||||
ChannelId: c.ID.String(),
|
||||
Name: c.Name,
|
||||
}
|
||||
}
|
||||
|
||||
func mapVoiceChannel(c store.VoiceChannel) *channelv1.VoiceChannel {
|
||||
return &channelv1.VoiceChannel{
|
||||
ServerId: c.ServerID.String(),
|
||||
ChannelId: c.ID.String(),
|
||||
Name: c.Name,
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue