server: reduce message output, only show channel ID instead of full channel object

This commit is contained in:
2026-06-02 03:01:21 +00:00
parent 0f0f2062a3
commit 2efe08b247
3 changed files with 13 additions and 13 deletions
+3 -3
View File
@@ -241,7 +241,7 @@ func DBAddFile(file *File) error { return dbAddFile(file) }
func DBAddMessage(msg *Message) error {
query := `INSERT INTO messages (id, channel, created, content, audio) VALUES ($1, $2, $3, $4, $5)`
_, err := db.Pool.Exec(context.Background(), query, msg.ID, msg.Channel.ID, msg.Created, msg.Content, msg.Audio.ID)
_, err := db.Pool.Exec(context.Background(), query, msg.ID, msg.ChannelID, msg.Created, msg.Content, msg.Audio.ID)
if err != nil {
slog.Error("db: failed to add message", "error", err, "messageid", msg.ID)
return fmt.Errorf("failed to add message")
@@ -274,7 +274,7 @@ func dbGetMessage(id string) (*Message, error) {
return nil, fmt.Errorf("failed to fetch audio for message")
}
msg.Channel = *channel
msg.ChannelID = channel.ID
msg.Audio = *audio
slog.Debug("db: message found", "messageid", msg.ID)
return &msg, nil
@@ -336,7 +336,7 @@ func dbGetMessagesByChannel(channelID string, from, to *time.Time) ([]*Message,
slog.Error("db: failed to fetch audio for message", "messageid", mr.msg.ID, "audioid", mr.audioID, "error", err)
return nil, fmt.Errorf("failed to fetch audio for message")
}
mr.msg.Channel = *channel
mr.msg.ChannelID = channel.ID
mr.msg.Audio = *audio
messages = append(messages, &mr.msg)
}
+5 -5
View File
@@ -13,11 +13,11 @@ import (
)
type Message struct {
ID uuid.UUID
Channel Channel
Created time.Time
Content string
Audio File
ID uuid.UUID
ChannelID uuid.UUID
Created time.Time
Content string
Audio File
}
type MessagePayload struct {
+5 -5
View File
@@ -49,11 +49,11 @@ func (s *MessageServer) SendMessage(ctx context.Context, req *pb.SendMessageRequ
}
msg := &api.Message{
ID: uuid.New(),
Channel: *channel,
Created: time.Now(),
Content: req.Content,
Audio: *audio,
ID: uuid.New(),
ChannelID: channel.ID,
Created: time.Now(),
Content: req.Content,
Audio: *audio,
}
if err := api.DBAddMessage(msg); err != nil {