mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-09 22:42:58 +00:00
gb vendor update github.com/matrix-org/gomatrixserverlib
This commit is contained in:
parent
ce311ce0fe
commit
a904380e1b
2
vendor/manifest
vendored
2
vendor/manifest
vendored
@ -98,7 +98,7 @@
|
||||
{
|
||||
"importpath": "github.com/matrix-org/gomatrixserverlib",
|
||||
"repository": "https://github.com/matrix-org/gomatrixserverlib",
|
||||
"revision": "30652b26ec2e83b97c941eb1c293bf7d67340f74",
|
||||
"revision": "768a8767051a4aca7f5e41f912954ae04d5f1efb",
|
||||
"branch": "master"
|
||||
},
|
||||
{
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user