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,24 +582,23 @@ 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{}{
"m.read": map[string]interface{}{
receipt.UserID: struct {
gomatrixserverlib.Timestamp `json:"ts"`
}{
receipt.Timestamp,
},
content[receipt.EventID] = map[string]interface{}{
"m.read": map[string]interface{}{
receipt.UserID: struct {
gomatrixserverlib.Timestamp `json:"ts"`
}{
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
}