mirror of
https://github.com/tulir/mautrix-whatsapp
synced 2025-03-05 00:40:18 +01:00
link previews: only include in Matrix event when there's an actual link
This commit is contained in:
parent
bc6b9266a9
commit
b6352c4991
2 changed files with 5 additions and 7 deletions
|
@ -1510,9 +1510,7 @@ func (portal *Portal) convertTextMessage(intent *appservice.IntentAPI, source *U
|
|||
}
|
||||
expiresIn = contextInfo.GetExpiration()
|
||||
|
||||
extraAttrs["com.beeper.linkpreviews"] = []*BeeperLinkPreview{
|
||||
portal.convertURLPreviewToBeeper(intent, source, msg.GetExtendedTextMessage()),
|
||||
}
|
||||
extraAttrs["com.beeper.linkpreviews"] = portal.convertURLPreviewToBeeper(intent, source, msg.GetExtendedTextMessage())
|
||||
}
|
||||
|
||||
return &ConvertedMessage{
|
||||
|
|
|
@ -52,12 +52,12 @@ type BeeperLinkPreview struct {
|
|||
ImageType string `json:"og:image:type,omitempty"`
|
||||
}
|
||||
|
||||
func (portal *Portal) convertURLPreviewToBeeper(intent *appservice.IntentAPI, source *User, msg *waProto.ExtendedTextMessage) (output *BeeperLinkPreview) {
|
||||
func (portal *Portal) convertURLPreviewToBeeper(intent *appservice.IntentAPI, source *User, msg *waProto.ExtendedTextMessage) []*BeeperLinkPreview {
|
||||
if msg.GetMatchedText() == "" {
|
||||
return
|
||||
return []*BeeperLinkPreview{}
|
||||
}
|
||||
|
||||
output = &BeeperLinkPreview{
|
||||
output := &BeeperLinkPreview{
|
||||
MatchedURL: msg.GetMatchedText(),
|
||||
CanonicalURL: msg.GetCanonicalUrl(),
|
||||
Title: msg.GetTitle(),
|
||||
|
@ -111,7 +111,7 @@ func (portal *Portal) convertURLPreviewToBeeper(intent *appservice.IntentAPI, so
|
|||
output.Type = "video.other"
|
||||
}
|
||||
|
||||
return
|
||||
return []*BeeperLinkPreview{output}
|
||||
}
|
||||
|
||||
func (portal *Portal) convertURLPreviewToWhatsApp(sender *User, evt *event.Event, dest *waProto.ExtendedTextMessage) {
|
||||
|
|
Loading…
Add table
Reference in a new issue