link previews: only include in Matrix event when there's an actual link

This commit is contained in:
Sumner Evans 2022-02-06 22:30:00 -07:00
parent bc6b9266a9
commit b6352c4991
No known key found for this signature in database
GPG key ID: 8904527AB50022FD
2 changed files with 5 additions and 7 deletions

View file

@ -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{

View file

@ -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) {