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 return err
} }
ev := gomatrixserverlib.ClientEvent{
Type: "m.receipt",
RoomID: roomID,
}
content := map[string]interface{}{}
for _, receipt := range receipts { for _, receipt := range receipts {
data := map[string]interface{}{ content[receipt.EventID] = map[string]interface{}{
receipt.EventID: map[string]interface{}{ "m.read": map[string]interface{}{
"m.read": map[string]interface{}{ receipt.UserID: struct {
receipt.UserID: struct { gomatrixserverlib.Timestamp `json:"ts"`
gomatrixserverlib.Timestamp `json:"ts"` }{
}{ receipt.Timestamp,
receipt.Timestamp,
},
}, },
}, },
} }
ev := gomatrixserverlib.ClientEvent{ ev.Content, err = json.Marshal(content)
Type: "m.receipt",
RoomID: roomID,
}
ev.Content, err = json.Marshal(data)
if err != nil { if err != nil {
return err return err
} }