From 769e06554b5f537e8b2de53d2fb878c2ca650075 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Wed, 13 Sep 2023 21:41:22 -0300 Subject: [PATCH] make instant view happen when there is video or image and the note is big enough. --- render.go | 9 ++++++--- templates/telegram_instant_view.html | 6 ++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/render.go b/render.go index b4c0a66..ccfc783 100644 --- a/render.go +++ b/render.go @@ -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 } diff --git a/templates/telegram_instant_view.html b/templates/telegram_instant_view.html index 0ed0e1d..d80f27b 100644 --- a/templates/telegram_instant_view.html +++ b/templates/telegram_instant_view.html @@ -14,6 +14,12 @@ {{ if .image }} {{ end }} + +{{ if .video }} + + + +{{ end }}