From dda8095f81caa080726bf01ab4a56d24a0e09497 Mon Sep 17 00:00:00 2001 From: Till Faelligen Date: Thu, 15 Oct 2020 13:26:34 +0200 Subject: [PATCH] Make receipt json creation "easier" to read --- syncapi/storage/shared/syncserver.go | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/syncapi/storage/shared/syncserver.go b/syncapi/storage/shared/syncserver.go index 804a097a1..f2ea86c38 100644 --- a/syncapi/storage/shared/syncserver.go +++ b/syncapi/storage/shared/syncserver.go @@ -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 }