From a904380e1bb685af03d49ad00a3ab80e728dc7f0 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Mon, 24 Jul 2017 13:42:55 +0100 Subject: [PATCH] gb vendor update github.com/matrix-org/gomatrixserverlib --- vendor/manifest | 2 +- .../matrix-org/gomatrixserverlib/event.go | 33 ++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/vendor/manifest b/vendor/manifest index 95c4b6f8b..425cc8f1f 100644 --- a/vendor/manifest +++ b/vendor/manifest @@ -98,7 +98,7 @@ { "importpath": "github.com/matrix-org/gomatrixserverlib", "repository": "https://github.com/matrix-org/gomatrixserverlib", - "revision": "30652b26ec2e83b97c941eb1c293bf7d67340f74", + "revision": "768a8767051a4aca7f5e41f912954ae04d5f1efb", "branch": "master" }, { diff --git a/vendor/src/github.com/matrix-org/gomatrixserverlib/event.go b/vendor/src/github.com/matrix-org/gomatrixserverlib/event.go index 94de35189..e8c2de0f1 100644 --- a/vendor/src/github.com/matrix-org/gomatrixserverlib/event.go +++ b/vendor/src/github.com/matrix-org/gomatrixserverlib/event.go @@ -252,10 +252,41 @@ func (e Event) Redact() Event { // This is unreachable for events created with EventBuilder.Build or NewEventFromUntrustedJSON panic(fmt.Errorf("gomatrixserverlib: invalid event %v", err)) } - return Event{ + result := Event{ redacted: true, eventJSON: eventJSON, } + if err = json.Unmarshal(eventJSON, &result.fields); err != nil { + // This is unreachable for events created with EventBuilder.Build or NewEventFromUntrustedJSON + panic(fmt.Errorf("gomatrixserverlib: invalid event %v", err)) + } + return result +} + +// SetUnsigned sets the unsigned key of the event. +// Returns a copy of the event with the "unsigned" key set. +func (e Event) SetUnsigned(unsigned interface{}) (Event, error) { + var eventAsMap map[string]rawJSON + var err error + if err = json.Unmarshal(e.eventJSON, &eventAsMap); err != nil { + return Event{}, err + } + unsignedJSON, err := json.Marshal(unsigned) + if err != nil { + return Event{}, err + } + eventAsMap["unsigned"] = unsignedJSON + eventJSON, err := json.Marshal(eventAsMap) + if err != nil { + return Event{}, err + } + if eventJSON, err = CanonicalJSON(eventJSON); err != nil { + return Event{}, err + } + result := e + result.eventJSON = eventJSON + result.fields.Unsigned = unsignedJSON + return result, nil } // EventReference returns an EventReference for the event.