pl-api: Support Enable Mastodon Apps for WordPress
Signed-off-by: mkljczk <git@mkljczk.pl>
This commit is contained in:
@ -757,6 +757,8 @@ class PlApiClient {
|
||||
/**
|
||||
* Lookup account ID from Webfinger address
|
||||
* Quickly lookup a username to see if it is available, skipping WebFinger resolution.
|
||||
|
||||
* Requires features{@link Features['accountLookup']}.
|
||||
* @see {@link https://docs.joinmastodon.org/methods/accounts/#lookup}
|
||||
*/
|
||||
lookupAccount: async (acct: string, meta?: RequestMeta) => {
|
||||
|
||||
@ -5,6 +5,8 @@ import { accountSchema } from './account';
|
||||
import { ruleSchema } from './rule';
|
||||
import { coerceObject, filteredArray, mimeSchema } from './utils';
|
||||
|
||||
const WORDPRESS_REGEX = /^WordPress\/[\w+.-]*, EMA\/([\w+.-]*)/;
|
||||
|
||||
const getApiVersions = (instance: any): Record<string, number> => ({
|
||||
...Object.fromEntries(instance.pleroma?.metadata?.features?.map((feature: string) => {
|
||||
let string = `${feature}.pleroma.pl-api`;
|
||||
@ -91,17 +93,23 @@ const instanceV1ToV2 = (data: any) => {
|
||||
const fixVersion = (version: string) => {
|
||||
// Handle Mastodon release candidates
|
||||
if (new RegExp(/[0-9.]+rc[0-9]+/g).test(version)) {
|
||||
version = version.split('rc').join('-rc');
|
||||
return version.split('rc').join('-rc');
|
||||
}
|
||||
|
||||
// Rename Akkoma to Pleroma+akkoma
|
||||
if (version.includes('Akkoma')) {
|
||||
version = '2.7.2 (compatible; Pleroma 2.4.50+akkoma)';
|
||||
return '2.7.2 (compatible; Pleroma 2.4.50+akkoma)';
|
||||
}
|
||||
|
||||
// Set Takahē version to a Pleroma-like string
|
||||
if (version.startsWith('takahe/')) {
|
||||
version = `0.0.0 (compatible; Takahe ${version.slice(7)})`;
|
||||
return `0.0.0 (compatible; Takahe ${version.slice(7)})`;
|
||||
}
|
||||
|
||||
const wordPressMatch = WORDPRESS_REGEX.exec(version);
|
||||
|
||||
if (wordPressMatch) {
|
||||
return `0.0.0 (compatible; WordPress ${wordPressMatch[1]})`;
|
||||
}
|
||||
|
||||
return version;
|
||||
|
||||
@ -103,6 +103,15 @@ const TAKAHE = 'Takahe';
|
||||
*/
|
||||
const TOKI = 'Toki';
|
||||
|
||||
/**
|
||||
* WordPress, through the Enable Mastodon App plugin.
|
||||
* I am not affiliated with WP Engine in any way, finanically or otherwise. ~mkljczk
|
||||
*
|
||||
* @category Software
|
||||
* @see {@link https://github.com/akirk/enable-mastodon-apps}
|
||||
*/
|
||||
const WORDPRESS = 'WordPress';
|
||||
|
||||
/**
|
||||
* Akkoma, a Pleroma fork.
|
||||
*
|
||||
@ -225,6 +234,7 @@ const getFeatures = (instance: Instance) => {
|
||||
v.software === PLEROMA && gte(v.version, '2.5.0'),
|
||||
v.software === TAKAHE && gte(v.version, '0.6.1'),
|
||||
v.software === TOKI,
|
||||
v.software === WORDPRESS,
|
||||
]),
|
||||
|
||||
/**
|
||||
@ -882,6 +892,7 @@ const getFeatures = (instance: Instance) => {
|
||||
v.software === PLEROMA,
|
||||
v.software === TAKAHE,
|
||||
v.software === TOKI,
|
||||
v.software === WORDPRESS,
|
||||
]),
|
||||
|
||||
/**
|
||||
@ -1105,6 +1116,7 @@ const getFeatures = (instance: Instance) => {
|
||||
v.software === PLEROMA,
|
||||
v.software === TAKAHE,
|
||||
v.software === TOKI,
|
||||
v.software === WORDPRESS,
|
||||
]),
|
||||
|
||||
/**
|
||||
@ -1398,10 +1410,12 @@ export {
|
||||
PLEROMA,
|
||||
TAKAHE,
|
||||
TOKI,
|
||||
WORDPRESS,
|
||||
AKKOMA,
|
||||
GLITCH,
|
||||
REBASED,
|
||||
HOMETOWN,
|
||||
PL,
|
||||
REBASED,
|
||||
UNRELEASED,
|
||||
type Features,
|
||||
type Backend as BackendVersion,
|
||||
|
||||
Reference in New Issue
Block a user