diff --git a/pkg/connector/backfill.go b/pkg/connector/backfill.go index e2c7d114..8f006e0b 100644 --- a/pkg/connector/backfill.go +++ b/pkg/connector/backfill.go @@ -293,10 +293,7 @@ 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 && getMessageType(rawMsg.GetMessage().GetMessage()) == "ignore" { - ignoredTypes++ - continue - } else if err != nil { + if err != nil { log.Warn().Err(err). Int("msg_index", i). Str("msg_id", rawMsg.GetMessage().GetKey().GetID()). diff --git a/pkg/msgconv/from-matrix.go b/pkg/msgconv/from-matrix.go index ba2adc23..47485854 100644 --- a/pkg/msgconv/from-matrix.go +++ b/pkg/msgconv/from-matrix.go @@ -168,6 +168,11 @@ func (mc *MessageConverter) ToWhatsApp( Comment: &content.Body, ContextInfo: contextInfo, } + if msc3488, ok := evt.Content.Raw["org.matrix.msc3488.location"].(map[string]any); ok { + if description, ok := msc3488["description"].(string); ok && description != "" { + message.LocationMessage.Name = &description + } + } default: return nil, nil, fmt.Errorf("%w %s", bridgev2.ErrUnsupportedMessageType, content.MsgType) } diff --git a/pkg/msgconv/from-whatsapp.go b/pkg/msgconv/from-whatsapp.go index ec273076..db18f35a 100644 --- a/pkg/msgconv/from-whatsapp.go +++ b/pkg/msgconv/from-whatsapp.go @@ -322,7 +322,6 @@ 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 7afcc81f..52874fd8 100644 --- a/pkg/msgconv/wa-text.go +++ b/pkg/msgconv/wa-text.go @@ -18,7 +18,6 @@ package msgconv import ( "context" - "encoding/json" "fmt" "html" "regexp" @@ -26,7 +25,6 @@ import ( "strconv" "strings" - "github.com/rs/zerolog" "go.mau.fi/whatsmeow/proto/waE2E" "maunium.net/go/mautrix/bridgev2" "maunium.net/go/mautrix/event" @@ -74,36 +72,6 @@ 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) {