| [eb36688] | 1 | // FEP-e232: Klonkt keeps inbound object-link (quote/ref) tags and serves them on the C2S inbox read.
|
|---|
| 2 | import { test } from 'node:test';
|
|---|
| 3 | import assert from 'node:assert/strict';
|
|---|
| 4 | process.env.DATABASE_PATH = ':memory:';
|
|---|
| 5 | process.env.PUBLIC_BASE_URL = 'https://test.example';
|
|---|
| 6 | const dbMod = await import('../src/config/database.js');
|
|---|
| 7 | dbMod.initializeDatabase();
|
|---|
| 8 | const { extractObjectLinkTags, timelineObjectLinks } = await import('../src/services/ActivityPubService.js');
|
|---|
| 9 | const AP = { extractObjectLinkTags, timelineObjectLinks };
|
|---|
| 10 |
|
|---|
| 11 | test('extractObjectLinkTags keeps AS2-profiled ld+json and activity+json Links; drops plain links and mentions', () => {
|
|---|
| 12 | const tag = [
|
|---|
| 13 | { type: 'Link', mediaType: 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"', href: 'https://s/objects/1', name: '#1374' },
|
|---|
| 14 | { type: 'Link', mediaType: 'application/activity+json', href: 'https://s/objects/2', rel: ['https://misskey-hub.net/ns#_misskey_quote'] },
|
|---|
| 15 | { type: 'Link', mediaType: 'text/html', href: 'https://plain.example/page' }, // plain hyperlink → dropped
|
|---|
| 16 | { type: 'Mention', href: 'https://s/u/x' },
|
|---|
| 17 | ];
|
|---|
| 18 | const json = AP.extractObjectLinkTags(tag);
|
|---|
| 19 | assert.ok(json);
|
|---|
| 20 | const back = AP.timelineObjectLinks(json);
|
|---|
| 21 | assert.equal(back.length, 2);
|
|---|
| 22 | assert.equal(back[0].href, 'https://s/objects/1');
|
|---|
| 23 | assert.equal(back[0].name, '#1374');
|
|---|
| 24 | assert.equal(back[1].mediaType, 'application/activity+json');
|
|---|
| 25 | });
|
|---|
| 26 |
|
|---|
| 27 | test('no object links → null / undefined (nothing served)', () => {
|
|---|
| 28 | assert.equal(AP.extractObjectLinkTags([{ type: 'Link', mediaType: 'text/html', href: 'https://x' }]), null);
|
|---|
| 29 | assert.equal(AP.extractObjectLinkTags([{ type: 'Hashtag', name: '#hi' }]), null);
|
|---|
| 30 | assert.equal(AP.timelineObjectLinks(null), undefined);
|
|---|
| 31 | assert.equal(AP.timelineObjectLinks('not json'), undefined);
|
|---|
| 32 | });
|
|---|