Add link previews
This commit is contained in:
@@ -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,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user