From 9ed2b60c02bdcec0af9c496865b7ac9785900898 Mon Sep 17 00:00:00 2001 From: mkljczk Date: Thu, 20 Mar 2025 12:22:31 +0100 Subject: [PATCH] pl-api: Add software definition for snac2 Signed-off-by: mkljczk --- packages/pl-api/lib/entities/instance.ts | 7 +++++++ packages/pl-api/lib/features.ts | 11 ++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/pl-api/lib/entities/instance.ts b/packages/pl-api/lib/entities/instance.ts index 9a4ef8e07..6e02014eb 100644 --- a/packages/pl-api/lib/entities/instance.ts +++ b/packages/pl-api/lib/entities/instance.ts @@ -5,6 +5,7 @@ import { accountSchema } from './account'; import { ruleSchema } from './rule'; import { coerceObject, filteredArray, mimeSchema } from './utils'; +const SNAC_REGEX = /^([0-9.]*) \(not true; really snac\/([\w.]*)\)/; const WORDPRESS_REGEX = /^WordPress\/[\w+.-]*, EMA\/([\w+.-]*)/; const getApiVersions = (instance: any): Record => ({ @@ -107,6 +108,12 @@ const fixVersion = (version: string) => { return `0.0.0 (compatible; WordPress ${wordPressMatch[1]})`; } + const snacMatch = SNAC_REGEX.exec(version); + + if (snacMatch) { + return `${snacMatch[1]} (compatible; snac ${snacMatch[2]})`; + } + return version; }; diff --git a/packages/pl-api/lib/features.ts b/packages/pl-api/lib/features.ts index d65873949..57750f63f 100644 --- a/packages/pl-api/lib/features.ts +++ b/packages/pl-api/lib/features.ts @@ -87,6 +87,14 @@ const PIXELFED = 'Pixelfed'; */ const PLEROMA = 'Pleroma'; +/** + * snac, a simple, minimalistic ActivityPub instance written in portable C + * + * @category Software + * @see {@link https://codeberg.org/grunfink/snac2/} + */ +const SNAC = 'snac'; + /** * Takahē, backend with support for serving multiple domains. * @@ -1550,6 +1558,7 @@ const parseVersion = (version: string): Backend => { }; export { + AKKOMA, DITTO, FIREFISH, FRIENDICA, @@ -1560,10 +1569,10 @@ export { MITRA, PIXELFED, PLEROMA, + SNAC, TAKAHE, TOKI, WORDPRESS, - AKKOMA, GLITCH, HOMETOWN, PL,