make instant view happen when there is video or image and the note is big enough.

This commit is contained in:
fiatjaf
2023-09-13 21:41:22 -03:00
parent 700d12eb27
commit 769e06554b
2 changed files with 12 additions and 3 deletions

View File

@@ -224,11 +224,14 @@ func render(w http.ResponseWriter, r *http.Request) {
}
useTextImage := (event.Kind == 1 || event.Kind == 30023) &&
image == "" && video == "" && len(event.Content) > 120
image == "" && video == "" && len(event.Content) > 133
if style == "telegram" {
if event.Kind == 30023 ||
(event.Kind == 1 && len(event.Content) > 650) {
// do telegram instant preview (only works on telegram mobile apps, not desktop)
if event.Kind == 30023 || // do it for longform articles
(event.Kind == 1 && len(event.Content) > 650) || // or very long notes
// or shorter notes that should be using text-to-image stuff but are not because they have video or images
(event.Kind == 1 && len(event.Content) > 133 && !useTextImage) {
typ = "telegram_instant_view"
useTextImage = false
}

View File

@@ -14,6 +14,12 @@
{{ if .image }}
<meta property="og:image" content="{{.image | escapeString}}" />
{{ end }}
<!---->
{{ if .video }}
<meta property="og:video" content="{{.video | escapeString}}" />
<meta property="og:video:secure_url" content="{{.video | escapeString}}" />
<meta property="og:video:type" content="video/{{.videoType | escapeString}}" />
{{ end }}
<!-- stuff that affects the content inside the preview window -->
<meta name="author" content="{{.metadata.Name}}" />