Changeset 221a209 in Klonkt for src/services/CircleService.js


Ignore:
Timestamp:
06/16/2026 08:52:32 PM (3 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
2248cd2
Parents:
fb02cc0
Message:

Circle: carry over + display tags from the original post

Publisher puts tags as AS Hashtag array in the outbox (href pointing to the
source tag page). Consumer parses + caches them (remote_posts.tags). Feed
cards display them (post-card), and the reader shows tag chips that link to
the /tag page of the source.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/services/CircleService.js

    rfb02cc0 r221a209  
    2929function baseOf(remoteUrl) {
    3030  return String(remoteUrl).replace(/\/+$/, '');
     31}
     32
     33// AS Hashtag-array -> comma-separated tagnamen (zonder #), gesanitized.
     34function extractTags(tag) {
     35  if (!Array.isArray(tag)) return null;
     36  const names = tag
     37    .map((t) => String((t && t.name) || '').replace(/^#/, '').trim())
     38    .filter(Boolean)
     39    .slice(0, 12);
     40  return names.length ? names.join(', ') : null;
    3141}
    3242
     
    8393    `),
    8494    upsertPost: db.prepare(`
    85       INSERT INTO remote_posts (id, actor_id, published, title, summary, url, media_json, raw_json, fetched_at)
    86       VALUES (@id, @actor_id, @published, @title, @summary, @url, @media_json, @raw_json, CURRENT_TIMESTAMP)
     95      INSERT INTO remote_posts (id, actor_id, published, title, summary, url, media_json, tags, raw_json, fetched_at)
     96      VALUES (@id, @actor_id, @published, @title, @summary, @url, @media_json, @tags, @raw_json, CURRENT_TIMESTAMP)
    8797      ON CONFLICT(id) DO UPDATE SET
    8898        published=excluded.published, title=excluded.title, summary=excluded.summary,
    89         url=excluded.url, media_json=excluded.media_json, raw_json=excluded.raw_json, fetched_at=CURRENT_TIMESTAMP
     99        url=excluded.url, media_json=excluded.media_json, tags=excluded.tags,
     100        raw_json=excluded.raw_json, fetched_at=CURRENT_TIMESTAMP
    90101    `),
    91102  };
     
    169180      url: obj.url || obj.id,
    170181      media_json: media.length ? JSON.stringify(media) : null,
     182      tags: extractTags(obj.tag),
    171183      raw_json: JSON.stringify(obj).slice(0, 20000),
    172184    });
Note: See TracChangeset for help on using the changeset viewer.