Monorepo for Tangled
0

Configure Feed

Select the types of activity you want to include in your feed.

appview/home: correctly attribute reposts in homepage

in the homepage, we have a list of bsky posts from the tangled-org
account. some of these posts are reposts. reposts need to be attributed
to the original authors and links now point back to the original
authors' post (instead of being broken).

Signed-off-by: oppiliappan <me@oppi.li>

authored by

oppiliappan and committed by
Seongmin Lee
(Jun 30, 2026, 12:26 AM +0900) 6a2ac027 f9451de1

+28 -10
+7 -4
appview/db/bsky.go
··· 14 14 } 15 15 16 16 stmt, err := e.Prepare(` 17 - insert or replace into bluesky_posts (rkey, text, created_at, langs, facets, embed, like_count, reply_count, repost_count, quote_count) 18 - values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) 17 + insert or replace into bluesky_posts (rkey, text, created_at, langs, facets, embed, like_count, reply_count, repost_count, quote_count, author_did) 18 + values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) 19 19 `) 20 20 if err != nil { 21 21 return err ··· 46 46 post.ReplyCount, 47 47 post.RepostCount, 48 48 post.QuoteCount, 49 + post.AuthorDid, 49 50 ) 50 51 if err != nil { 51 52 return err ··· 64 65 65 66 func GetBlueskyPosts(e Execer, limit int) ([]models.BskyPost, error) { 66 67 query := ` 67 - select rkey, text, created_at, langs, facets, embed, like_count, reply_count, repost_count, quote_count 68 + select rkey, text, created_at, langs, facets, embed, like_count, reply_count, repost_count, quote_count, author_did 68 69 from bluesky_posts 69 70 order by created_at desc 70 71 limit ? ··· 81 82 var rkey, text, createdAt string 82 83 var langs, facets, embed sql.Null[string] 83 84 var likeCount, replyCount, repostCount, quoteCount int64 85 + var authorDid string 84 86 85 - err := rows.Scan(&rkey, &text, &createdAt, &langs, &facets, &embed, &likeCount, &replyCount, &repostCount, &quoteCount) 87 + err := rows.Scan(&rkey, &text, &createdAt, &langs, &facets, &embed, &likeCount, &replyCount, &repostCount, &quoteCount, &authorDid) 86 88 if err != nil { 87 89 return nil, err 88 90 } ··· 94 96 ReplyCount: replyCount, 95 97 RepostCount: repostCount, 96 98 QuoteCount: quoteCount, 99 + AuthorDid: authorDid, 97 100 } 98 101 99 102 if t, err := time.Parse(time.RFC3339, createdAt); err == nil {
+7
appview/db/db.go
··· 2365 2365 return nil 2366 2366 }) 2367 2367 2368 + orm.RunMigration(conn, logger, "add-author-to-bluesky-posts", func(tx *sql.Tx) error { 2369 + _, err := tx.Exec(` 2370 + alter table bluesky_posts add column author_did text not null default ''; 2371 + `) 2372 + return err 2373 + }) 2374 + 2368 2375 return &DB{ 2369 2376 db, 2370 2377 logger,
+9 -2
appview/models/bsky.go
··· 8 8 ) 9 9 10 10 type BskyPost struct { 11 + AuthorDid string 11 12 Rkey string 12 13 Text string 13 14 CreatedAt time.Time ··· 54 55 quoteCount = *postView.QuoteCount 55 56 } 56 57 57 - return &BskyPost{ 58 + post := &BskyPost{ 58 59 Rkey: atUri.RecordKey().String(), 59 60 Text: feedPost.Text, 60 61 CreatedAt: createdAt, ··· 68 69 ReplyCount: replyCount, 69 70 RepostCount: repostCount, 70 71 QuoteCount: quoteCount, 71 - }, nil 72 + } 73 + 74 + if author := postView.Author; author != nil { 75 + post.AuthorDid = author.Did 76 + } 77 + 78 + return post, nil 72 79 }
+5 -4
appview/pages/templates/timeline/home.html
··· 446 446 {{ end }} 447 447 448 448 {{ define "post" }} 449 + {{ $author := or .AuthorDid "tangled.org" }} 449 450 <div class="bg-white dark:bg-gray-800 rounded shadow-sm border border-gray-200 dark:border-gray-700 px-6 py-4 flex flex-col gap-2 break-inside-avoid mb-6"> 450 451 <div class="flex items-center justify-between text-sm text-gray-500 dark:text-gray-400"> 451 - <span class="flex items-center gap-2"> 452 - {{ template "user/fragments/picHandle" "tangled.org" }} 453 - </span> 452 + <a href="https://bsky.app/profile/{{ $author }}" target="_blank" rel="noopener noreferrer" class="flex items-center gap-2 no-underline hover:no-underline"> 453 + {{ template "user/fragments/picHandle" $author }} 454 + </a> 454 455 <span>{{ template "repo/fragments/shortTimeAgo" .CreatedAt }}</span> 455 456 </div> 456 457 <p class="text-gray-900 dark:text-gray-100 text-base leading-relaxed whitespace-pre-wrap">{{ .Text }}</p> ··· 480 481 {{ end }} 481 482 {{ end }} 482 483 483 - <a href="https://bsky.app/profile/tangled.org/post/{{ .Rkey }}" 484 + <a href="https://bsky.app/profile/{{ $author }}/post/{{ .Rkey }}" 484 485 target="_blank" 485 486 rel="noopener noreferrer" 486 487 class="flex items-center justify-between gap-4 text-sm text-gray-500 dark:text-gray-400 pt-2 no-underline hover:no-underline">