diff --git a/appview/db/bsky.go b/appview/db/bsky.go --- a/appview/db/bsky.go +++ b/appview/db/bsky.go @@ -14,8 +14,8 @@ return nil } stmt, err := e.Prepare(` - insert or replace into bluesky_posts (rkey, text, created_at, langs, facets, embed, like_count, reply_count, repost_count, quote_count) - values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) + insert or replace into bluesky_posts (rkey, text, created_at, langs, facets, embed, like_count, reply_count, repost_count, quote_count, author_did) + values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) `) if err != nil { return err @@ -46,6 +46,7 @@ post.LikeCount, post.ReplyCount, post.RepostCount, post.QuoteCount, + post.AuthorDid, ) if err != nil { return err @@ -64,7 +65,7 @@ } func GetBlueskyPosts(e Execer, limit int) ([]models.BskyPost, error) { query := ` - select rkey, text, created_at, langs, facets, embed, like_count, reply_count, repost_count, quote_count + select rkey, text, created_at, langs, facets, embed, like_count, reply_count, repost_count, quote_count, author_did from bluesky_posts order by created_at desc limit ? @@ -81,8 +82,9 @@ for rows.Next() { var rkey, text, createdAt string var langs, facets, embed sql.Null[string] var likeCount, replyCount, repostCount, quoteCount int64 + var authorDid string - err := rows.Scan(&rkey, &text, &createdAt, &langs, &facets, &embed, &likeCount, &replyCount, &repostCount, "eCount) + err := rows.Scan(&rkey, &text, &createdAt, &langs, &facets, &embed, &likeCount, &replyCount, &repostCount, "eCount, &authorDid) if err != nil { return nil, err } @@ -94,6 +96,7 @@ LikeCount: likeCount, ReplyCount: replyCount, RepostCount: repostCount, QuoteCount: quoteCount, + AuthorDid: authorDid, } if t, err := time.Parse(time.RFC3339, createdAt); err == nil { diff --git a/appview/db/db.go b/appview/db/db.go --- a/appview/db/db.go +++ b/appview/db/db.go @@ -2365,6 +2365,13 @@ return nil }) + orm.RunMigration(conn, logger, "add-author-to-bluesky-posts", func(tx *sql.Tx) error { + _, err := tx.Exec(` + alter table bluesky_posts add column author_did text not null default ''; + `) + return err + }) + return &DB{ db, logger, diff --git a/appview/models/bsky.go b/appview/models/bsky.go --- a/appview/models/bsky.go +++ b/appview/models/bsky.go @@ -8,6 +8,7 @@ "github.com/bluesky-social/indigo/atproto/syntax" ) type BskyPost struct { + AuthorDid string Rkey string Text string CreatedAt time.Time @@ -54,7 +55,7 @@ if postView.QuoteCount != nil { quoteCount = *postView.QuoteCount } - return &BskyPost{ + post := &BskyPost{ Rkey: atUri.RecordKey().String(), Text: feedPost.Text, CreatedAt: createdAt, @@ -68,5 +69,11 @@ LikeCount: likeCount, ReplyCount: replyCount, RepostCount: repostCount, QuoteCount: quoteCount, - }, nil + } + + if author := postView.Author; author != nil { + post.AuthorDid = author.Did + } + + return post, nil } diff --git a/appview/pages/templates/timeline/home.html b/appview/pages/templates/timeline/home.html --- a/appview/pages/templates/timeline/home.html +++ b/appview/pages/templates/timeline/home.html @@ -446,11 +446,12 @@ {{ end }} {{ define "post" }} + {{ $author := or .AuthorDid "tangled.org" }}
- - {{ template "user/fragments/picHandle" "tangled.org" }} - + + {{ template "user/fragments/picHandle" $author }} + {{ template "repo/fragments/shortTimeAgo" .CreatedAt }}

{{ .Text }}

@@ -480,7 +481,7 @@
{{ end }} {{ end }} -