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:
parent
c58e65000d
commit
a2f49bb08c
5 changed files with 167 additions and 46 deletions
39
bskyweb/cmd/bskyweb/formatting_test.go
Normal file
39
bskyweb/cmd/bskyweb/formatting_test.go
Normal 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()
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue