Changeset 0688b5f in Klonkt for test


Ignore:
Timestamp:
07/01/2026 07:06:45 PM (2 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
1c2dcba
Parents:
d18c60e
Message:

feat(fediverse): post language → AS2 contentMap

A post can now carry a language; it federates as an AS2 contentMap (a BCP-47-keyed
copy of the content, alongside plain content) so Mastodon's timeline language filter
and translate button work. Editor gets a language picker (defaults to the author's
UI language).

  • src/config/database.js — posts.language column.
  • src/services/ActivityPubService.js — buildNote emits contentMap { <lang>: content } when the post has a valid BCP-47 language.
  • src/routes/posts.js — capture/validate/store language on create/save (default = the author's current language) and pass it to the federation hooks.
  • src/services/Scheduler.js — carry language when a scheduled post goes live.
  • src/views/pages/post-edit.ejs — language <select> (18 common languages).
  • src/services/i18n.js — pedit.f_language + pedit.language_hint (nl/en/de).
  • test/activitypub-as2.test.js — allow contentMap/nameMap/summaryMap; don't treat a language-map's keys as vocab terms; kitchen-sink post now sets a language.
  • test/post-language.test.js — contentMap shape, no-language, invalid-code = ignored.
  • CHANGELOG(.nl/.de).md — "Set a post's language" under Unreleased.

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

Location:
test
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • test/activitypub-as2.test.js

    rd18c60e r0688b5f  
    2727  'published', 'updated', 'attributedTo', 'inReplyTo', 'replies',
    2828  'attachment', 'tag', 'icon', 'image', 'duration',
     29  'contentMap', 'nameMap', 'summaryMap', // AS2 @language-map counterparts of content/name/summary
    2930  'totalItems', 'orderedItems', 'items', 'first', 'last', 'partOf', 'next', 'prev',
    3031  'preferredUsername', 'inbox', 'outbox', 'followers', 'following', 'endpoints', 'sharedInbox',
     
    4748      keys.add(k);
    4849      if (k === 'type' && typeof v === 'string') keys.add(v);
     50      if (/Map$/.test(k)) continue; // a @language map (contentMap/…): its keys are BCP-47 tags, not vocab terms
    4951      collect(v, keys);
    5052    }
     
    7072  id: 'p1', slug: 'hello', title: 'Hi', content: '<p>hello #music</p>',
    7173  nsfw: 1, content_warning: 'cw', tags: JSON.stringify(['mood']),
    72   cover_image_url: '/media/c.webp',
     74  cover_image_url: '/media/c.webp', cover_alt: 'A cover', language: 'en',
    7375  published_at: '2026-01-01T00:00:00Z', created_at: '2026-01-01T00:00:00Z',
    7476};
Note: See TracChangeset for help on using the changeset viewer.