Add link previews

This commit is contained in:
2026-09-18 20:56:41 +02:00
parent 601053c51d
commit f152f84139
7 changed files with 188 additions and 13 deletions
+29
View File
@@ -0,0 +1,29 @@
package server
import (
"strings"
"uncensored-send/internal/config"
"uncensored-send/internal/store"
)
type preview struct {
Description string
Author string
URL string
}
func objectPreview(m *store.Meta, url string) *preview {
facts := []string{config.FormatBytes(m.Size)}
if m.Owner != "" {
facts = append(facts, "uploaded by "+m.Owner)
}
if m.Expires != nil {
facts = append(facts, "expires "+absolute(m.Expires))
}
return &preview{
Description: strings.Join(facts, ", ") + ". Open the page to download it.",
Author: m.Owner,
URL: url,
}
}