diff --git a/pkg/msgconv/from-whatsapp.go b/pkg/msgconv/from-whatsapp.go index 998a3544..af5697f1 100644 --- a/pkg/msgconv/from-whatsapp.go +++ b/pkg/msgconv/from-whatsapp.go @@ -157,6 +157,8 @@ func (mc *MessageConverter) ToMatrix( part, contextInfo = mc.convertContactMessage(ctx, waMsg.ContactMessage) case waMsg.ContactsArrayMessage != nil: part, contextInfo = mc.convertContactsArrayMessage(ctx, waMsg.ContactsArrayMessage) + case waMsg.PlaceholderMessage != nil: + part, contextInfo = mc.convertPlaceholderMessage(ctx, waMsg) case waMsg.GroupInviteMessage != nil: part, contextInfo = mc.convertGroupInviteMessage(ctx, info, waMsg.GroupInviteMessage) case waMsg.ProtocolMessage != nil && waMsg.ProtocolMessage.GetType() == waE2E.ProtocolMessage_EPHEMERAL_SETTING: diff --git a/pkg/msgconv/wa-misc.go b/pkg/msgconv/wa-misc.go index 6d6b2fe3..fad51b92 100644 --- a/pkg/msgconv/wa-misc.go +++ b/pkg/msgconv/wa-misc.go @@ -26,6 +26,7 @@ import ( "github.com/rs/zerolog" "go.mau.fi/util/exerrors" + "go.mau.fi/util/ptr" "go.mau.fi/whatsmeow/proto/waE2E" "go.mau.fi/whatsmeow/types" "google.golang.org/protobuf/proto" @@ -54,6 +55,23 @@ func (mc *MessageConverter) convertUnknownMessage(ctx context.Context, msg *waE2 }, nil } +var otpContent = format.RenderMarkdown("You received a one-time passcode. For added security, you can only see it on your primary device for WhatsApp. [Learn more](https://faq.whatsapp.com/372839278914311)", true, false) + +func init() { + otpContent.MsgType = event.MsgNotice +} + +func (mc *MessageConverter) convertPlaceholderMessage(ctx context.Context, rawMsg *waE2E.Message) (*bridgev2.ConvertedMessagePart, *waE2E.ContextInfo) { + if rawMsg.GetPlaceholderMessage().GetType() == waE2E.PlaceholderMessage_MASK_LINKED_DEVICES { + return &bridgev2.ConvertedMessagePart{ + Type: event.EventMessage, + Content: ptr.Clone(&otpContent), + }, nil + } else { + return mc.convertUnknownMessage(ctx, rawMsg) + } +} + const inviteMsg = `%s
%s accept
to accept the invite.`
const inviteMsgBroken = `%s