Skip to content

Commit

Permalink
[FIX] History: Payload had to be []bytes
Browse files Browse the repository at this point in the history
...not a string. Also renaming Topic to Channel.
[BREAKING CHANGE]
  • Loading branch information
Florimond committed Sep 29, 2024
1 parent 74e6649 commit fa64881
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions internal/service/history/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/emitter-io/emitter/internal/provider/logging"
"github.com/emitter-io/emitter/internal/security"
"github.com/emitter-io/emitter/internal/service"
"github.com/kelindar/binary"
)

// Request represents a historical messages request.
Expand All @@ -33,8 +34,8 @@ type Request struct {

type Message struct {
ID message.ID `json:"id"`
Topic string `json:"topic"` // The channel of the message
Payload string `json:"payload"` // The payload of the message
Channel string `json:"channel"` // The channel of the message
Payload []byte `json:"payload"` // The payload of the message
}
type Response struct {
Request uint16 `json:"req,omitempty"` // The corresponding request ID.
Expand Down Expand Up @@ -87,8 +88,8 @@ func (s *Service) OnRequest(c service.Conn, payload []byte) (service.Response, b
msg := m
resp.Messages = append(resp.Messages, Message{
ID: msg.ID,
Topic: string(msg.Channel), // The channel for this message.
Payload: string(msg.Payload), // The payload for this message.
Channel: binary.ToString(&msg.Channel),
Payload: msg.Payload,
})
}
return resp, true
Expand Down

0 comments on commit fa64881

Please sign in to comment.