mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-25 15:53:09 -06:00
- Fix a bug when creating client receipts
- Use concrete types instead of interface{}
This commit is contained in:
parent
247da6d862
commit
1a10566f28
|
|
@ -66,3 +66,22 @@ type OutputReceiptEvent struct {
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
Timestamp gomatrixserverlib.Timestamp `json:"timestamp"`
|
Timestamp gomatrixserverlib.Timestamp `json:"timestamp"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Helper structs for receipts json creation
|
||||||
|
type ReceiptMRead struct {
|
||||||
|
User map[string]ReceiptTS `json:"m.read"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ReceiptTS struct {
|
||||||
|
TS gomatrixserverlib.Timestamp `json:"ts"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// FederationSender output
|
||||||
|
type FederationReceiptMRead struct {
|
||||||
|
User map[string]FederationReceiptData `json:"m.read"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type FederationReceiptData struct {
|
||||||
|
Data ReceiptTS `json:"data"`
|
||||||
|
EventIDs []string `json:"event_ids"`
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -228,15 +228,14 @@ func (t *OutputEDUConsumer) onReceiptEvent(msg *sarama.ConsumerMessage) error {
|
||||||
names[i] = joined[i].ServerName
|
names[i] = joined[i].ServerName
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: easier/nicer creation of receipt EDUs
|
content := map[string]api.FederationReceiptMRead{}
|
||||||
content := map[string]interface{}{}
|
content[receipt.RoomID] = api.FederationReceiptMRead{
|
||||||
content[receipt.RoomID] = map[string]interface{}{
|
User: map[string]api.FederationReceiptData{
|
||||||
"m.read": map[string]interface{}{
|
receipt.UserID: {
|
||||||
receipt.UserID: userData{
|
Data: api.ReceiptTS{
|
||||||
Data: struct {
|
TS: receipt.Timestamp,
|
||||||
Ts gomatrixserverlib.Timestamp `json:"ts"`
|
},
|
||||||
}{receipt.Timestamp},
|
EventIDs: []string{receipt.EventID},
|
||||||
EventIds: []string{receipt.EventID},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -599,17 +599,13 @@ func (d *Database) addReceiptDeltaToResponse(
|
||||||
Type: gomatrixserverlib.MReceipt,
|
Type: gomatrixserverlib.MReceipt,
|
||||||
RoomID: roomID,
|
RoomID: roomID,
|
||||||
}
|
}
|
||||||
content := map[string]interface{}{}
|
content := make(map[string]eduAPI.ReceiptMRead)
|
||||||
|
read := eduAPI.ReceiptMRead{
|
||||||
|
User: make(map[string]eduAPI.ReceiptTS),
|
||||||
|
}
|
||||||
for _, receipt := range receipts {
|
for _, receipt := range receipts {
|
||||||
content[receipt.EventID] = map[string]interface{}{
|
read.User[receipt.UserID] = eduAPI.ReceiptTS{receipt.Timestamp}
|
||||||
"m.read": map[string]interface{}{
|
content[receipt.EventID] = read
|
||||||
receipt.UserID: struct {
|
|
||||||
gomatrixserverlib.Timestamp `json:"ts"`
|
|
||||||
}{
|
|
||||||
receipt.Timestamp,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ev.Content, err = json.Marshal(content)
|
ev.Content, err = json.Marshal(content)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue