Changeset 2c22bb5 in Klonkt for src/services


Ignore:
Timestamp:
06/26/2026 08:53:42 AM (2 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
46f3dd6
Parents:
49b1b39
Message:

feat(cirkel): rebuild the Cirkel feed on ActivityPub (featured/auto-boosted artists)

Phase 2 of the Cirkels-on-AP rework. /cirkel now shows posts from the accounts a
site auto-boosts ("feature an artist"), sourced from ap_timeline ⋈ ap_following
(auto_boost=1); cards link to the source post. The Solo|Cirkel switcher shows
whenever the site has a cirkel (new hasCirkel local) instead of only on
circle-tenancy. Legacy circle-tenancy remote_posts are merged in until the old
pull-protocol is removed (Phase 4). New: autoBoostCount / getCirkelPosts /
getCirkelMembers.

Co-Authored-By: Claude <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/services/ActivityPubService.js

    r49b1b39 r2c22bb5  
    10321032export function getTimeline(slug, limit) { return tlStmts().list.all(slug, limit || 50); }
    10331033
     1034// ── Cirkel = posts from the accounts you auto-boost ("feature an artist") ──
     1035let _abCount, _cirkelPosts, _cirkelMembers;
     1036export function autoBoostCount(slug) {
     1037  try { if (!_abCount) _abCount = db.prepare('SELECT COUNT(*) AS n FROM ap_following WHERE slug = ? AND auto_boost = 1'); return _abCount.get(slug).n; } catch { return 0; }
     1038}
     1039export function getCirkelPosts(slug, limit) {
     1040  try {
     1041    if (!_cirkelPosts) _cirkelPosts = db.prepare(`
     1042      SELECT t.id, t.author_uri, t.author_name, t.author_handle, t.author_icon, t.author_url,
     1043             t.content, t.url, t.published, t.media_json
     1044      FROM ap_timeline t
     1045      JOIN ap_following f ON f.slug = t.slug AND f.actor_uri = t.author_uri AND f.auto_boost = 1
     1046      WHERE t.slug = ?
     1047      ORDER BY COALESCE(t.published, t.created_at) DESC, t.rowid DESC
     1048      LIMIT ?`);
     1049    return _cirkelPosts.all(slug, limit || 60);
     1050  } catch { return []; }
     1051}
     1052export function getCirkelMembers(slug) {
     1053  try { if (!_cirkelMembers) _cirkelMembers = db.prepare('SELECT name, url, icon FROM ap_following WHERE slug = ? AND auto_boost = 1 ORDER BY name'); return _cirkelMembers.all(slug); } catch { return []; }
     1054}
     1055
    10341056// Follow a fediverse account by @handle (WebFinger → actor → signed Follow).
    10351057export async function followActor(site, handle, autoBoost = false) {
     
    11901212  listOutbox, deliverOutboxDelete,
    11911213  webfingerResolve, followActor, resolveRemoteActor, unfollowActor, listFollowing, setAutoBoost, getTimeline, sendInteraction,
     1214  autoBoostCount, getCirkelPosts, getCirkelMembers,
    11921215  getNotifications, listBlocks, isBlockedAny, blockTarget, unblock,
    11931216  deliverWithRetry, enqueueDelivery, processDeliveryQueue, startDeliveryWorker,
Note: See TracChangeset for help on using the changeset viewer.