From a58cae16cdecadece41f2d1a9e2ca777116c62fc Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sat, 16 Apr 2022 23:16:05 +0300 Subject: [PATCH] Backport fixing custom fields leaking in history sync --- historysync.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/historysync.go b/historysync.go index 5fece97..f92e499 100644 --- a/historysync.go +++ b/historysync.go @@ -478,6 +478,13 @@ func (portal *Portal) wrapBatchEvent(info *types.MessageInfo, intent *appservice if err != nil { return nil, err } + if newEventType == event.EventEncrypted { + // Clear other custom keys if the event was encrypted, but keep the double puppet identifier + wrappedContent.Raw = map[string]interface{}{backfillIDField: info.ID} + if intent.IsCustomPuppet { + wrappedContent.Raw[doublePuppetKey] = doublePuppetValue + } + } return &event.Event{ Sender: intent.UserID, Type: newEventType,