From 32af06fff8cc2fdf45bc01381a39b54138698699 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Wed, 22 Feb 2017 15:45:42 +0000 Subject: [PATCH] More comments --- src/github.com/matrix-org/dendrite/roomserver/api/input.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/github.com/matrix-org/dendrite/roomserver/api/input.go b/src/github.com/matrix-org/dendrite/roomserver/api/input.go index 71d0b0e59..5dcd5aaf4 100644 --- a/src/github.com/matrix-org/dendrite/roomserver/api/input.go +++ b/src/github.com/matrix-org/dendrite/roomserver/api/input.go @@ -45,6 +45,8 @@ type InputRoomEvent struct { HasState bool // Optional list of state event IDs forming the state before this event. // These state events must have already been persisted. + // These are only used if HasState is true. + // The list can be empty, for example when storing a m.room.create event. StateEventIDs []string } @@ -52,6 +54,8 @@ type InputRoomEvent struct { func (ire *InputRoomEvent) UnmarshalJSON(data []byte) error { // Create a struct rather than unmarshalling directly into the InputRoomEvent // so that we can use json.RawMessage. + // We use json.RawMessage so that the event JSON is sent as JSON rather than + // being base64 encoded which is the default for []byte. var content struct { Kind int Event *json.RawMessage @@ -76,6 +80,8 @@ func (ire *InputRoomEvent) UnmarshalJSON(data []byte) error { func (ire InputRoomEvent) MarshalJSON() ([]byte, error) { // Create a struct rather than marshalling directly from the InputRoomEvent // so that we can use json.RawMessage. + // We use json.RawMessage so that the event JSON is sent as JSON rather than + // being base64 encoded which is the default for []byte. event := json.RawMessage(ire.Event) content := struct { Kind int