aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2020-04-19 16:23:32 +0300
committerTulir Asokan <tulir@maunium.net>2020-04-19 16:23:32 +0300
commit6a907354e21469a83c51f50bc4dd520ffe8915d6 (patch)
tree7ec238adbf0a561c7a2e89aa4cdc5957d52e88ee
parentf668faa8940ba02e796e016ff27f2e4620b49a29 (diff)
Strip event content Raw fields before storing
-rw-r--r--matrix/history.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/matrix/history.go b/matrix/history.go
index 8a80569..07a6c90 100644
--- a/matrix/history.go
+++ b/matrix/history.go
@@ -265,9 +265,18 @@ func btoi(b []byte) uint64 {
return binary.BigEndian.Uint64(b)
}
+func stripRaw(evt *muksevt.Event) {
+ evtCopy := *evt.Event
+ evtCopy.Content = event.Content{
+ Parsed: evt.Content.Parsed,
+ }
+ evt.Event = &evtCopy
+}
+
func marshalEvent(evt *muksevt.Event) ([]byte, error) {
+ stripRaw(evt)
var buf bytes.Buffer
- enc := gzip.NewWriter(&buf)
+ enc, _ := gzip.NewWriterLevel(&buf, gzip.BestSpeed)
if err := gob.NewEncoder(enc).Encode(evt); err != nil {
_ = enc.Close()
return nil, err