Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ Version 0.9.22

To be released.

- Fixed the language of remote posts not being stored when they were
received from Mastodon, Hollo, or any other software that sends `content`
together with `contentMap`. [[#647], [#659]]

- Upgraded Fedify to 2.2.16, which normalizes BCP 47 extended language
subtags before parsing language tags. Language-tagged strings with tags
like `zh-YUE`, which Mastodon uses for Cantonese, were previously dropped
because `Intl.Locale` rejects them; they are now kept with the canonical
tag (e.g., `yue`). [[#647], [fedify-dev/fedify#1229], [#659]]

[fedify-dev/fedify#1229]: https://github.com/fedify-dev/fedify/issues/1229
[#647]: https://github.com/fedify-dev/hollo/issues/647
[#659]: https://github.com/fedify-dev/hollo/pull/659


Version 0.9.21
--------------
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
},
"dependencies": {
"@aws-sdk/credential-providers": "^3.1037.0",
"@fedify/debugger": "~2.2.15",
"@fedify/fedify": "~2.2.15",
"@fedify/hono": "~2.2.15",
"@fedify/debugger": "~2.2.16",
"@fedify/fedify": "~2.2.16",
"@fedify/hono": "~2.2.16",
"@fedify/markdown-it-hashtag": "~0.3.0",
"@fedify/markdown-it-mention": "~0.3.0",
"@fedify/postgres": "~2.2.15",
"@fedify/vocab": "~2.2.15",
"@fedify/webfinger": "~2.2.15",
"@fedify/postgres": "~2.2.16",
"@fedify/vocab": "~2.2.16",
"@fedify/webfinger": "~2.2.16",
"@hexagon/base64": "^2.0.4",
"@hono/node-server": "^1.19.13",
"@hono/zod-validator": "^0.7.6",
Expand Down Expand Up @@ -88,7 +88,7 @@
},
"devDependencies": {
"@dotenvx/dotenvx": "^1.52.0",
"@fedify/lint": "~2.2.15",
"@fedify/lint": "~2.2.16",
"@iconify-json/lucide": "^1.2.104",
"@reporters/github": "^1.13.1",
"@types/fluent-ffmpeg": "^2.1.28",
Expand Down
112 changes: 56 additions & 56 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

93 changes: 93 additions & 0 deletions src/federation/post.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,99 @@ describe("persistPost", () => {
{ accountId: mentioned.id, postId: result.id },
]);
});

it("stores the language when content is accompanied by contentMap", async () => {
expect.assertions(2);
const author = await seedRemoteAccount("author");
const object = await Note.fromJsonLd({
"@context": "https://www.w3.org/ns/activitystreams",
type: "Note",
id: "https://remote.test/@author/posts/content-map",
content: "<p>こんにちは</p>",
contentMap: { ja: "<p>こんにちは</p>" },
to: PUBLIC_COLLECTION.href,
});

const result = await persistPost(
db,
object.clone({ attribution: createPerson(author) }),
"https://hollo.test",
{ account: author },
);

expect(result?.contentHtml).toBe("<p>こんにちは</p>");
expect(result?.language).toBe("ja");
});

it("stores the language from summaryMap when content has none", async () => {
expect.assertions(1);
const author = await seedRemoteAccount("author");
const object = await Note.fromJsonLd({
"@context": "https://www.w3.org/ns/activitystreams",
type: "Note",
id: "https://remote.test/@author/posts/summary-map",
summary: "CW",
summaryMap: { "zh-TW": "CW" },
content: "<p>內容</p>",
to: PUBLIC_COLLECTION.href,
});

const result = await persistPost(
db,
object.clone({ attribution: createPerson(author) }),
"https://hollo.test",
{ account: author },
);

expect(result?.language).toBe("zh-TW");
});

it("normalizes extended language tags such as zh-YUE", async () => {
expect.assertions(1);
const author = await seedRemoteAccount("author");
const object = await Note.fromJsonLd({
"@context": "https://www.w3.org/ns/activitystreams",
type: "Note",
id: "https://remote.test/@author/posts/extlang",
content: "<p>你好</p>",
contentMap: { "zh-YUE": "<p>你好</p>" },
to: PUBLIC_COLLECTION.href,
});

const result = await persistPost(
db,
object.clone({ attribution: createPerson(author) }),
"https://hollo.test",
{ account: author },
);

expect(result?.language).toBe("yue");
});

it("ignores undetermined languages from a default @language", async () => {
expect.assertions(1);
const author = await seedRemoteAccount("author");
const object = await Note.fromJsonLd({
"@context": [
"https://www.w3.org/ns/activitystreams",
{ "@language": "und" },
],
type: "Note",
id: "https://remote.test/@author/posts/default-language",
content: "<p>こんにちは</p>",
contentMap: { ja: "<p>こんにちは</p>" },
to: PUBLIC_COLLECTION.href,
});

const result = await persistPost(
db,
object.clone({ attribution: createPerson(author) }),
"https://hollo.test",
{ account: author },
);

expect(result?.language).toBe("ja");
});
});

describe("toObject", () => {
Expand Down
Loading
Loading