Force beeper linkpreviews field in replies
This commit is contained in:
parent
1a541a16f2
commit
bdd4c2b149
|
|
@ -3,6 +3,7 @@ package matrixbot
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"html"
|
"html"
|
||||||
|
|
@ -214,7 +215,17 @@ func (b *Bot) sendReply(ctx context.Context, evt *event.Event, response string)
|
||||||
content.SetReply(evt)
|
content.SetReply(evt)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := b.client.SendMessageEvent(ctx, evt.RoomID, event.EventMessage, content)
|
payload, err := json.Marshal(content)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
var contentMap map[string]any
|
||||||
|
if err := json.Unmarshal(payload, &contentMap); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
contentMap["com.beeper.linkpreviews"] = []any{}
|
||||||
|
|
||||||
|
_, err = b.client.SendMessageEvent(ctx, evt.RoomID, event.EventMessage, contentMap)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -416,8 +427,7 @@ func splitLinkLine(line string) (string, string, bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func obfuscateURL(url string) string {
|
func obfuscateURL(url string) string {
|
||||||
// Break client-side link preview parsers while preserving readability.
|
return url
|
||||||
return strings.Replace(url, "://", ":\u2060//", 1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func isEncryptedInvite(evt *event.Event) bool {
|
func isEncryptedInvite(evt *event.Event) bool {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue