From 5edff0e7bf4c8831f9e37cb6085813e38fa87a5d Mon Sep 17 00:00:00 2001 From: Gerardo Rodriguez Date: Tue, 10 Nov 2026 06:23:28 +0000 Subject: [PATCH 1/7] msgconv/from-matrix: send location description as name --- pkg/msgconv/from-matrix.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/msgconv/from-matrix.go b/pkg/msgconv/from-matrix.go index ba2adc23..8e3e13fa 100644 --- a/pkg/msgconv/from-matrix.go +++ b/pkg/msgconv/from-matrix.go @@ -165,9 +165,11 @@ func (mc *MessageConverter) ToWhatsApp( message.LocationMessage = &waE2E.LocationMessage{ DegreesLatitude: &lat, DegreesLongitude: &long, - Comment: &content.Body, ContextInfo: contextInfo, } + if content.Body != "" && content.Body != content.GeoURI { + message.LocationMessage.Name = &content.Body + } default: return nil, nil, fmt.Errorf("%w %s", bridgev2.ErrUnsupportedMessageType, content.MsgType) } From 6cb748bc9c610b95e78e136332835e2363a7ad23 Mon Sep 17 00:00:00 2001 From: Gerardo Rodriguez Date: Tue, 10 Nov 2026 06:25:54 +0000 Subject: [PATCH 2/7] msgconv/from-matrix: prefer MSC3488 description and skip generated location bodies --- pkg/msgconv/from-matrix.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/msgconv/from-matrix.go b/pkg/msgconv/from-matrix.go index 8e3e13fa..9f703b73 100644 --- a/pkg/msgconv/from-matrix.go +++ b/pkg/msgconv/from-matrix.go @@ -167,8 +167,14 @@ func (mc *MessageConverter) ToWhatsApp( DegreesLongitude: &long, ContextInfo: contextInfo, } - if content.Body != "" && content.Body != content.GeoURI { - message.LocationMessage.Name = &content.Body + name := content.Body + if msc3488, ok := evt.Content.Raw["org.matrix.msc3488.location"].(map[string]any); ok { + if description, ok := msc3488["description"].(string); ok && description != "" { + name = description + } + } + if name != "" && !strings.Contains(name, "geo:") && !strings.Contains(name, "\n") { + message.LocationMessage.Name = &name } default: return nil, nil, fmt.Errorf("%w %s", bridgev2.ErrUnsupportedMessageType, content.MsgType) From a15089b18d41c3f3692d72b10d96d8a2aa9b7432 Mon Sep 17 00:00:00 2001 From: "indent[bot]" <297468268+indent[bot]@users.noreply.github.com> Date: Tue, 10 Nov 2026 06:19:41 -0700 Subject: [PATCH 3/7] backfill: skip unparseable history messages without content (#1046) Co-authored-by: Indent --- pkg/connector/backfill.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/connector/backfill.go b/pkg/connector/backfill.go index 8f006e0b..e2c7d114 100644 --- a/pkg/connector/backfill.go +++ b/pkg/connector/backfill.go @@ -293,7 +293,10 @@ func (wa *WhatsAppClient) handleWAHistorySync( for i, rawMsg := range rawMessages { // Don't store messages that will just be skipped. msgEvt, err := wa.Client.ParseWebMessage(jid, rawMsg.GetMessage()) - if err != nil { + if err != nil && getMessageType(rawMsg.GetMessage().GetMessage()) == "ignore" { + ignoredTypes++ + continue + } else if err != nil { log.Warn().Err(err). Int("msg_index", i). Str("msg_id", rawMsg.GetMessage().GetKey().GetID()). From 08f33e20cf7089638ea32eafdda3c4f621aef7aa Mon Sep 17 00:00:00 2001 From: Gerardo Rodriguez Date: Tue, 10 Nov 2026 19:00:42 +0000 Subject: [PATCH 4/7] msgconv/from-matrix: only use the MSC3488 description as the location name --- pkg/msgconv/from-matrix.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pkg/msgconv/from-matrix.go b/pkg/msgconv/from-matrix.go index 9f703b73..47485854 100644 --- a/pkg/msgconv/from-matrix.go +++ b/pkg/msgconv/from-matrix.go @@ -165,17 +165,14 @@ func (mc *MessageConverter) ToWhatsApp( message.LocationMessage = &waE2E.LocationMessage{ DegreesLatitude: &lat, DegreesLongitude: &long, + Comment: &content.Body, ContextInfo: contextInfo, } - name := content.Body if msc3488, ok := evt.Content.Raw["org.matrix.msc3488.location"].(map[string]any); ok { if description, ok := msc3488["description"].(string); ok && description != "" { - name = description + message.LocationMessage.Name = &description } } - if name != "" && !strings.Contains(name, "geo:") && !strings.Contains(name, "\n") { - message.LocationMessage.Name = &name - } default: return nil, nil, fmt.Errorf("%w %s", bridgev2.ErrUnsupportedMessageType, content.MsgType) } From 015ad733a3ef8a8776266b0c490ef6c740fe2ed8 Mon Sep 17 00:00:00 2001 From: "indent[bot]" <297468268+indent[bot]@users.noreply.github.com> Date: Wed, 11 Nov 2026 00:53:07 +0000 Subject: [PATCH 5/7] msgconv: log size breakdown of converted parts over the cut-off limit (#1047) Co-authored-by: Indent --- pkg/msgconv/from-whatsapp.go | 1 + pkg/msgconv/wa-text.go | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/pkg/msgconv/from-whatsapp.go b/pkg/msgconv/from-whatsapp.go index db18f35a..ec273076 100644 --- a/pkg/msgconv/from-whatsapp.go +++ b/pkg/msgconv/from-whatsapp.go @@ -322,6 +322,7 @@ func (mc *MessageConverter) ToMatrix( cm.ThreadRoot = ptr.Ptr(waid.MakeMessageID(chat, pcp, commentTarget.GetID())) } mc.cutOffLongMessage(part.Content) + logOversizedPart(ctx, part) return cm } diff --git a/pkg/msgconv/wa-text.go b/pkg/msgconv/wa-text.go index 52874fd8..7afcc81f 100644 --- a/pkg/msgconv/wa-text.go +++ b/pkg/msgconv/wa-text.go @@ -18,6 +18,7 @@ package msgconv import ( "context" + "encoding/json" "fmt" "html" "regexp" @@ -25,6 +26,7 @@ import ( "strconv" "strings" + "github.com/rs/zerolog" "go.mau.fi/whatsmeow/proto/waE2E" "maunium.net/go/mautrix/bridgev2" "maunium.net/go/mautrix/event" @@ -72,6 +74,36 @@ func (mc *MessageConverter) cutOffLongMessage(content *event.MessageEventContent } } +func logOversizedPart(ctx context.Context, part *bridgev2.ConvertedMessagePart) { + if part == nil || part.Content == nil { + return + } + contentJSON, _ := json.Marshal(part.Content) + extraJSON, _ := json.Marshal(part.Extra) + if len(contentJSON)+len(extraJSON) <= 40000 { + return + } + extraKeys := make([]string, 0, len(part.Extra)) + for key := range part.Extra { + extraKeys = append(extraKeys, key) + } + var mentionCount int + if part.Content.Mentions != nil { + mentionCount = len(part.Content.Mentions.UserIDs) + } + linkPreviewJSON, _ := json.Marshal(part.Content.BeeperLinkPreviews) + zerolog.Ctx(ctx).Warn(). + Str("msg_type", string(part.Content.MsgType)). + Int("content_json_size", len(contentJSON)). + Int("extra_json_size", len(extraJSON)). + Int("body_size", len(part.Content.Body)). + Int("formatted_body_size", len(part.Content.FormattedBody)). + Int("mention_count", mentionCount). + Int("link_preview_json_size", len(linkPreviewJSON)). + Strs("extra_keys", extraKeys). + Msg("Converted message part is larger than the cut-off limit") +} + func (mc *MessageConverter) parseFormatting(content *event.MessageEventContent, allowInlineURL, forceHTML bool) { parsedHTML := parseWAFormattingToHTML(content.Body, allowInlineURL) if forceHTML || parsedHTML != event.TextToHTML(content.Body) { From 7851e95028c35f5dd9776c3bfd90ac9f4964f4f1 Mon Sep 17 00:00:00 2001 From: "indent[bot]" <297468268+indent[bot]@users.noreply.github.com> Date: Thu, 12 Nov 2026 06:06:29 -0700 Subject: [PATCH 6/7] msgconv: don't look up LID mentions without a client (#1050) Co-authored-by: Indent --- pkg/msgconv/from-whatsapp.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/msgconv/from-whatsapp.go b/pkg/msgconv/from-whatsapp.go index ec273076..e2ab92cd 100644 --- a/pkg/msgconv/from-whatsapp.go +++ b/pkg/msgconv/from-whatsapp.go @@ -76,8 +76,7 @@ func (mc *MessageConverter) getBasicUserInfo(ctx context.Context, user types.JID var pnJID types.JID if user.Server == types.DefaultUserServer { pnJID = user - } else if user.Server == types.HiddenUserServer { - cli := getClient(ctx) + } else if cli := getClient(ctx); user.Server == types.HiddenUserServer && cli != nil { if user.User == cli.Store.GetLID().User { pnJID = cli.Store.GetJID() } else { From 37055ae4fcc8d5541ab9819f8bea94095d33d862 Mon Sep 17 00:00:00 2001 From: "indent[bot]" <297468268+indent[bot]@users.noreply.github.com> Date: Thu, 12 Nov 2026 06:07:31 -0700 Subject: [PATCH 7/7] wadb: index history sync messages by chat and timestamp (#1051) Co-authored-by: Indent --- pkg/connector/wadb/upgrades/00-latest-schema.sql | 4 +++- .../wadb/upgrades/12-history-sync-message-timestamp-index.sql | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 pkg/connector/wadb/upgrades/12-history-sync-message-timestamp-index.sql diff --git a/pkg/connector/wadb/upgrades/00-latest-schema.sql b/pkg/connector/wadb/upgrades/00-latest-schema.sql index c4172d09..cd02333f 100644 --- a/pkg/connector/wadb/upgrades/00-latest-schema.sql +++ b/pkg/connector/wadb/upgrades/00-latest-schema.sql @@ -1,4 +1,4 @@ --- v0 -> v11 (compatible with v3+): Latest revision +-- v0 -> v12 (compatible with v3+): Latest revision CREATE TABLE whatsapp_poll_option_id ( bridge_id TEXT NOT NULL, @@ -50,6 +50,8 @@ CREATE TABLE whatsapp_history_sync_message ( REFERENCES whatsapp_history_sync_conversation (bridge_id, user_login_id, chat_jid) ON UPDATE CASCADE ON DELETE CASCADE ); +CREATE INDEX whatsapp_history_sync_message_chat_ts_idx ON whatsapp_history_sync_message (bridge_id, user_login_id, chat_jid, timestamp); + CREATE TABLE whatsapp_media_backfill_request ( bridge_id TEXT NOT NULL, user_login_id TEXT NOT NULL, diff --git a/pkg/connector/wadb/upgrades/12-history-sync-message-timestamp-index.sql b/pkg/connector/wadb/upgrades/12-history-sync-message-timestamp-index.sql new file mode 100644 index 00000000..0d3b910a --- /dev/null +++ b/pkg/connector/wadb/upgrades/12-history-sync-message-timestamp-index.sql @@ -0,0 +1,2 @@ +-- v12 (compatible with v3+): Add index for history sync message timestamp lookups +CREATE INDEX whatsapp_history_sync_message_chat_ts_idx ON whatsapp_history_sync_message (bridge_id, user_login_id, chat_jid, timestamp);