mirror of
https://github.com/mautrix/whatsapp.git
synced 2026-11-12 09:09:17 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b0e566e863 | ||
|
|
bf68fcfe56 | ||
|
|
97f2ee1d83 | ||
|
|
3cad353823 |
7 changed files with 15 additions and 46 deletions
|
|
@ -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()).
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ func (wa *WhatsAppConnector) GetCapabilities() *bridgev2.NetworkGeneralCapabilit
|
|||
}
|
||||
|
||||
func (wa *WhatsAppConnector) GetBridgeInfoVersion() (info, caps int) {
|
||||
return 1, 10
|
||||
return 1, 11
|
||||
}
|
||||
|
||||
const WAMaxFileSize = 2000 * 1024 * 1024
|
||||
|
|
@ -67,7 +67,7 @@ func supportedIfFFmpeg() event.CapabilitySupportLevel {
|
|||
}
|
||||
|
||||
func capID() string {
|
||||
base := "fi.mau.whatsapp.capabilities.2026_10_01"
|
||||
base := "fi.mau.whatsapp.capabilities.2026_11_10"
|
||||
if ffmpeg.Supported() {
|
||||
return base + "+ffmpeg"
|
||||
}
|
||||
|
|
@ -119,6 +119,7 @@ var whatsappCaps = &event.RoomFeatures{
|
|||
MimeTypes: map[string]event.CapabilitySupportLevel{
|
||||
"audio/ogg; codecs=opus": event.CapLevelFullySupported,
|
||||
"audio/ogg": event.CapLevelUnsupported,
|
||||
"audio/webm": supportedIfFFmpeg(),
|
||||
},
|
||||
Caption: event.CapLevelDropped,
|
||||
MaxSize: WAMaxFileSize,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
-- v0 -> v12 (compatible with v3+): Latest revision
|
||||
-- v0 -> v11 (compatible with v3+): Latest revision
|
||||
|
||||
CREATE TABLE whatsapp_poll_option_id (
|
||||
bridge_id TEXT NOT NULL,
|
||||
|
|
@ -50,8 +50,6 @@ 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,
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
-- 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);
|
||||
|
|
@ -700,7 +700,14 @@ func (mc *MessageConverter) reuploadFileToWhatsApp(
|
|||
// Hopefully it's opus already
|
||||
mime = "audio/ogg; codecs=opus"
|
||||
default:
|
||||
return nil, nil, mime, fmt.Errorf("%w %s in audio message", bridgev2.ErrUnsupportedMediaType, mime)
|
||||
if content.MSC3245Voice == nil || !ffmpeg.Supported() {
|
||||
return nil, nil, mime, fmt.Errorf("%w %s in audio message", bridgev2.ErrUnsupportedMediaType, mime)
|
||||
}
|
||||
data, err = ffmpeg.ConvertBytes(ctx, data, ".ogg", []string{}, []string{"-vn", "-c:a", "libopus"}, mime)
|
||||
if err != nil {
|
||||
return nil, nil, mime, fmt.Errorf("%w (voice to ogg): %w", bridgev2.ErrMediaConvertFailed, err)
|
||||
}
|
||||
mime = "audio/ogg; codecs=opus"
|
||||
}
|
||||
mediaType = whatsmeow.MediaAudio
|
||||
case event.MsgFile:
|
||||
|
|
|
|||
|
|
@ -76,7 +76,8 @@ func (mc *MessageConverter) getBasicUserInfo(ctx context.Context, user types.JID
|
|||
var pnJID types.JID
|
||||
if user.Server == types.DefaultUserServer {
|
||||
pnJID = user
|
||||
} else if cli := getClient(ctx); user.Server == types.HiddenUserServer && cli != nil {
|
||||
} else if user.Server == types.HiddenUserServer {
|
||||
cli := getClient(ctx)
|
||||
if user.User == cli.Store.GetLID().User {
|
||||
pnJID = cli.Store.GetJID()
|
||||
} else {
|
||||
|
|
@ -321,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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue