more social card tweaks, and include in RSS as well (#2599)

* move link expander to new file, add test, refactor a bit

* text formatting: include indication if a quote post exists

* rss: include expanded links
This commit is contained in:
bnewbold 2024-01-23 13:16:32 -08:00 committed by GitHub
parent c58e65000d
commit a2f49bb08c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 167 additions and 46 deletions

View file

@ -0,0 +1,39 @@
package main
import (
"encoding/json"
"io"
"os"
"strings"
"testing"
appbsky "github.com/bluesky-social/indigo/api/bsky"
)
func loadPost(t *testing.T, p string) appbsky.FeedPost {
f, err := os.Open(p)
if err != nil {
t.Fatal(err)
}
defer func() { _ = f.Close() }()
postBytes, err := io.ReadAll(f)
if err != nil {
t.Fatal(err)
}
var post appbsky.FeedPost
if err := json.Unmarshal(postBytes, &post); err != nil {
t.Fatal(err)
}
return post
}
func TestExpandPostText(t *testing.T) {
post := loadPost(t, "testdata/atproto_embed_post.json")
text := ExpandPostText(&post)
if !strings.Contains(text, "https://github.com/snarfed/bridgy-fed") {
t.Fail()
}
}