mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-22 03:31:41 +00:00
Hopefully fix read receipts timestamps (#2557)
This should avoid coercions between signed and unsigned ints which might fix problems like `sql: converting argument $5 type: uint64 values with high bit set are not supported`.
This commit is contained in:
parent
c0f824d437
commit
460dccf93d
@ -17,6 +17,7 @@ package producers
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -83,7 +84,7 @@ func (p *SyncAPIProducer) SendReceipt(
|
|||||||
m.Header.Set(jetstream.RoomID, roomID)
|
m.Header.Set(jetstream.RoomID, roomID)
|
||||||
m.Header.Set(jetstream.EventID, eventID)
|
m.Header.Set(jetstream.EventID, eventID)
|
||||||
m.Header.Set("type", receiptType)
|
m.Header.Set("type", receiptType)
|
||||||
m.Header.Set("timestamp", strconv.Itoa(int(timestamp)))
|
m.Header.Set("timestamp", fmt.Sprintf("%d", timestamp))
|
||||||
|
|
||||||
log.WithFields(log.Fields{}).Tracef("Producing to topic '%s'", p.TopicReceiptEvent)
|
log.WithFields(log.Fields{}).Tracef("Producing to topic '%s'", p.TopicReceiptEvent)
|
||||||
_, err := p.JetStream.PublishMsg(m, nats.Context(ctx))
|
_, err := p.JetStream.PublishMsg(m, nats.Context(ctx))
|
||||||
|
@ -90,7 +90,7 @@ func (t *OutputReceiptConsumer) onMessage(ctx context.Context, msg *nats.Msg) bo
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
timestamp, err := strconv.Atoi(msg.Header.Get("timestamp"))
|
timestamp, err := strconv.ParseUint(msg.Header.Get("timestamp"), 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// If the message was invalid, log it and move on to the next message in the stream
|
// If the message was invalid, log it and move on to the next message in the stream
|
||||||
log.WithError(err).Errorf("EDU output log: message parse failure")
|
log.WithError(err).Errorf("EDU output log: message parse failure")
|
||||||
|
@ -53,7 +53,7 @@ func (p *SyncAPIProducer) SendReceipt(
|
|||||||
m.Header.Set(jetstream.RoomID, roomID)
|
m.Header.Set(jetstream.RoomID, roomID)
|
||||||
m.Header.Set(jetstream.EventID, eventID)
|
m.Header.Set(jetstream.EventID, eventID)
|
||||||
m.Header.Set("type", receiptType)
|
m.Header.Set("type", receiptType)
|
||||||
m.Header.Set("timestamp", strconv.Itoa(int(timestamp)))
|
m.Header.Set("timestamp", fmt.Sprintf("%d", timestamp))
|
||||||
|
|
||||||
log.WithFields(log.Fields{}).Tracef("Producing to topic '%s'", p.TopicReceiptEvent)
|
log.WithFields(log.Fields{}).Tracef("Producing to topic '%s'", p.TopicReceiptEvent)
|
||||||
_, err := p.JetStream.PublishMsg(m, nats.Context(ctx))
|
_, err := p.JetStream.PublishMsg(m, nats.Context(ctx))
|
||||||
|
@ -87,7 +87,7 @@ func (s *OutputReceiptEventConsumer) onMessage(ctx context.Context, msg *nats.Ms
|
|||||||
Type: msg.Header.Get("type"),
|
Type: msg.Header.Get("type"),
|
||||||
}
|
}
|
||||||
|
|
||||||
timestamp, err := strconv.Atoi(msg.Header.Get("timestamp"))
|
timestamp, err := strconv.ParseUint(msg.Header.Get("timestamp"), 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// If the message was invalid, log it and move on to the next message in the stream
|
// If the message was invalid, log it and move on to the next message in the stream
|
||||||
log.WithError(err).Errorf("output log: message parse failure")
|
log.WithError(err).Errorf("output log: message parse failure")
|
||||||
|
Loading…
Reference in New Issue
Block a user