nandi/gleanpublic⑂ Fork 0
⑂ a3d0d15
Commits
⬇ Clone ▾
git clone https://git.rickub.com/nandi/glean.git
git clone ssh://git@rickub.com/nandi/glean.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Include read state in list of liked articlesUnverified

Julien Robert committed 2026-04-21T14:21:20+02:00 Browse files
a3d0d15 parent: da7fae0
modified internal/db/social.go +5 -3
@@ -308,14 +308,16 @@ func (db *DB) ListLikedArticles(ctx context.Context, userDID string, limit, offs
308308 rows, err := db.QueryContext(ctx, `
309309 SELECT DISTINCT a.id, a.feed_url, a.guid, a.title, a.url, a.author, a.summary, a.content,
310310 a.published, a.updated, a.fetched_at,
311- COALESCE(f.title, '')
311+ COALESCE(f.title, ''),
312+ COALESCE(r.is_read, 0)
312313 FROM likes l
313314 JOIN articles a ON a.url = l.article_url AND a.feed_url = l.feed_url
314315 LEFT JOIN feeds f ON f.feed_url = a.feed_url
316+ LEFT JOIN read_state r ON r.user_did = ? AND r.article_id = a.id
315317 WHERE l.author_did = ?
316318 ORDER BY l.created_at DESC
317319 LIMIT ? OFFSET ?
318- `, userDID, limit, offset)
320+ `, userDID, userDID, limit, offset)
319321 if err != nil {
320322 return nil, err
321323 }
@@ -326,7 +328,7 @@ func (db *DB) ListLikedArticles(ctx context.Context, userDID string, limit, offs
326328 a := &Article{}
327329 if err := rows.Scan(&a.ID, &a.FeedURL, &a.GUID, &a.Title, &a.URL, &a.Author,
328330 &a.Summary, &a.Content, &a.Published, &a.Updated, &a.FetchedAt,
329- &a.FeedTitle); err != nil {
331+ &a.FeedTitle, &a.IsRead); err != nil {
330332 return nil, err
331333 }
332334 articles = append(articles, a)
@@ -308,14 +308,16 @@ func (db *DB) ListLikedArticles(ctx context.Context, userDID string, limit, offs
308 rows, err := db.QueryContext(ctx, `308 rows, err := db.QueryContext(ctx, `
309 SELECT DISTINCT a.id, a.feed_url, a.guid, a.title, a.url, a.author, a.summary, a.content,309 SELECT DISTINCT a.id, a.feed_url, a.guid, a.title, a.url, a.author, a.summary, a.content,
310 a.published, a.updated, a.fetched_at,310 a.published, a.updated, a.fetched_at,
311- COALESCE(f.title, '')311+ COALESCE(f.title, ''),
312+ COALESCE(r.is_read, 0)
312 FROM likes l313 FROM likes l
313 JOIN articles a ON a.url = l.article_url AND a.feed_url = l.feed_url314 JOIN articles a ON a.url = l.article_url AND a.feed_url = l.feed_url
314 LEFT JOIN feeds f ON f.feed_url = a.feed_url315 LEFT JOIN feeds f ON f.feed_url = a.feed_url
316+ LEFT JOIN read_state r ON r.user_did = ? AND r.article_id = a.id
315 WHERE l.author_did = ?317 WHERE l.author_did = ?
316 ORDER BY l.created_at DESC318 ORDER BY l.created_at DESC
317 LIMIT ? OFFSET ?319 LIMIT ? OFFSET ?
318- `, userDID, limit, offset)320+ `, userDID, userDID, limit, offset)
319 if err != nil {321 if err != nil {
320 return nil, err322 return nil, err
321 }323 }
@@ -326,7 +328,7 @@ func (db *DB) ListLikedArticles(ctx context.Context, userDID string, limit, offs
326 a := &Article{}328 a := &Article{}
327 if err := rows.Scan(&a.ID, &a.FeedURL, &a.GUID, &a.Title, &a.URL, &a.Author,329 if err := rows.Scan(&a.ID, &a.FeedURL, &a.GUID, &a.Title, &a.URL, &a.Author,
328 &a.Summary, &a.Content, &a.Published, &a.Updated, &a.FetchedAt,330 &a.Summary, &a.Content, &a.Published, &a.Updated, &a.FetchedAt,
329- &a.FeedTitle); err != nil {331+ &a.FeedTitle, &a.IsRead); err != nil {
330 return nil, err332 return nil, err
331 }333 }
332 articles = append(articles, a)334 articles = append(articles, a)