From 0c3d3686e42af140ab90c06e7c0cc08746dc16e8 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sun, 23 Feb 2025 21:06:53 +0200 Subject: [PATCH] hicli/sync: fill prev_content with cached event if it's missing --- pkg/hicli/sync.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/hicli/sync.go b/pkg/hicli/sync.go index 464ba0f..3821776 100644 --- a/pkg/hicli/sync.go +++ b/pkg/hicli/sync.go @@ -613,6 +613,14 @@ func (h *HiClient) processEvent( return dbEvt, nil } } + if evt.StateKey != nil && evt.Unsigned.PrevContent == nil && evt.Unsigned.ReplacesState != "" { + replacesState, err := h.DB.Event.GetByID(ctx, evt.Unsigned.ReplacesState) + if err != nil { + return nil, fmt.Errorf("failed to get prev content for %s from %s: %w", evt.ID, evt.Unsigned.ReplacesState, err) + } else if replacesState != nil { + evt.Unsigned.PrevContent = &event.Content{VeryRaw: replacesState.Content} + } + } dbEvt := database.MautrixToEvent(evt) contentWithoutFallback := removeReplyFallback(evt) if contentWithoutFallback != nil {