Make receipt json creation "easier" to read

This commit is contained in:
Till Faelligen 2020-10-15 13:26:34 +02:00
parent 5f9ac44062
commit dda8095f81

View file

@ -582,9 +582,13 @@ func (d *Database) addReceiptDeltaToResponse(
return err
}
ev := gomatrixserverlib.ClientEvent{
Type: "m.receipt",
RoomID: roomID,
}
content := map[string]interface{}{}
for _, receipt := range receipts {
data := map[string]interface{}{
receipt.EventID: map[string]interface{}{
content[receipt.EventID] = map[string]interface{}{
"m.read": map[string]interface{}{
receipt.UserID: struct {
gomatrixserverlib.Timestamp `json:"ts"`
@ -592,14 +596,9 @@ func (d *Database) addReceiptDeltaToResponse(
receipt.Timestamp,
},
},
},
}
ev := gomatrixserverlib.ClientEvent{
Type: "m.receipt",
RoomID: roomID,
}
ev.Content, err = json.Marshal(data)
ev.Content, err = json.Marshal(content)
if err != nil {
return err
}