Changeset 837fc9c in Klonkt for src/services


Ignore:
Timestamp:
06/27/2026 07:51:44 AM (3 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
92f6976
Parents:
aa45208
Message:

feat(posts): NSFW / sensitive content

Mark a post NSFW (checkbox in the editor, available to all). On-site the cover blurs in
feed/grid and the whole post blurs behind a 'Gevoelige inhoud' banner until clicked. In the
fediverse the Note gets sensitive:true + a content-warning summary (Mastodon CW). i18n NL/EN/DE.

Location:
src/services
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/services/ActivityPubService.js

    raa45208 r837fc9c  
    246246    tag: Array.isArray(post.tags) ? post.tags.map((t) => ({ type: 'Hashtag', name: '#' + String(t).replace(/\s+/g, '') })) : [],
    247247    replies: `${id}/replies`,
     248    // NSFW → Mastodon-style content warning: sensitive (blurs media) + a summary/spoiler
     249    // (hides the whole post behind a "Gevoelige inhoud" button until the reader opens it).
     250    sensitive: !!post.nsfw,
    248251  };
     252  if (post.nsfw) note.summary = 'Gevoelige inhoud';
    249253  if (attachment.length) note.attachment = attachment;
    250254  // Playable-audio posts suppress the cover attachment (player card). Still expose
     
    771775  if (!site) return;
    772776  const recent = db.prepare(
    773     `SELECT id, slug, title, content, cover_image_url, published_at, created_at
     777    `SELECT id, slug, title, content, cover_image_url, nsfw, published_at, created_at
    774778     FROM posts WHERE site_id = ? AND status = 'published' AND (fan_only IS NULL OR fan_only = 0)
    775779     ORDER BY COALESCE(published_at, created_at) DESC LIMIT 20`
  • src/services/Scheduler.js

    raa45208 r837fc9c  
    1515  try {
    1616    const due = db.prepare(`
    17       SELECT p.id, p.site_id, p.slug, p.title, p.content, p.cover_image_url, p.fan_only,
     17      SELECT p.id, p.site_id, p.slug, p.title, p.content, p.cover_image_url, p.fan_only, p.nsfw,
    1818             p.published_at, p.publish_at, p.created_at, u.username
    1919      FROM posts p JOIN users u ON u.id = p.author_id
     
    3939            id: p.id, slug: p.slug, title: p.title || p.slug,
    4040            content: p.content, cover_image_url: p.cover_image_url || null,
    41             published_at: p.published_at || p.publish_at, created_at: p.created_at, fan_only: p.fan_only,
     41            published_at: p.published_at || p.publish_at, created_at: p.created_at, fan_only: p.fan_only, nsfw: p.nsfw,
    4242          }).catch(() => { /* best-effort */ });
    4343        }
  • src/services/i18n.js

    raa45208 r837fc9c  
    771771    'pedit.pin_top': 'bovenaan',
    772772    'pedit.pin_nth_suffix': 'e van boven',
    773     'pedit.noindex_label': 'noindex (verberg voor zoekmachines)',
     773    'pedit.noindex_label': 'noindex (verberg voor zoekmachines)', 'pedit.nsfw_label': 'NSFW / gevoelige inhoud', 'post.nsfw_warning': 'Gevoelige inhoud', 'post.nsfw_show': 'Tonen',
    774774    'pedit.fan_only_label': 'Alleen voor ingelogde fans',
    775775    'pedit.schedule_label': 'Publicatie inplannen',
     
    17821782    'pedit.pin_top': 'at the top',
    17831783    'pedit.pin_nth_suffix': 'th from top',
    1784     'pedit.noindex_label': 'noindex (hide from search engines)',
     1784    'pedit.noindex_label': 'noindex (hide from search engines)', 'pedit.nsfw_label': 'NSFW / sensitive content', 'post.nsfw_warning': 'Sensitive content', 'post.nsfw_show': 'Show',
    17851785    'pedit.fan_only_label': 'Logged-in fans only',
    17861786    'pedit.schedule_label': 'Schedule publication',
     
    27932793    'pedit.pin_top': 'ganz oben',
    27942794    'pedit.pin_nth_suffix': '. von oben',
    2795     'pedit.noindex_label': 'noindex (vor Suchmaschinen verbergen)',
     2795    'pedit.noindex_label': 'noindex (vor Suchmaschinen verbergen)', 'pedit.nsfw_label': 'NSFW / sensibler Inhalt', 'post.nsfw_warning': 'Sensibler Inhalt', 'post.nsfw_show': 'Anzeigen',
    27962796    'pedit.fan_only_label': 'Nur für angemeldete Fans',
    27972797    'pedit.schedule_label': 'Veröffentlichung planen',
Note: See TracChangeset for help on using the changeset viewer.