mirror of
https://github.com/fluxerapp/fluxer.git
synced 2026-12-04 16:13:04 -08:00
feat(api): display instance version in discovery fields (#4363)
This commit is contained in:
1 parent
156c632686
commit
f8b28c6533
6 files changed
+35
-1
No files matched your search
@@ -44,6 +44,7 @@ import {BUILT_IN_GUILD_BADGE_KINDS, type HideableBuiltInBadgeKind} from '@fluxer
|
||||
import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes';
|
||||
import {AccountIdentityLockedError} from '@fluxer/errors/src/domains/auth/AccountIdentityLockedError';
|
||||
import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError';
|
||||
import {resolveFluxerVersion} from '@fluxer/hono/src/middleware/VersionHeader';
|
||||
import {buildDiscoveryResponse, type DiscoveryStaticInput} from '@fluxer/instance_bootstrap/src/BuildDiscovery';
|
||||
import type {InstanceAppPublic} from '@fluxer/instance_bootstrap/src/Types';
|
||||
import type {AccountsConfig, AuthConfig} from '@fluxer/schema/src/domains/admin/AccountsConfigSchemas';
|
||||
@@ -354,6 +355,7 @@ export function InstanceController(app: Hono<HonoEnv>) {
|
||||
);
|
||||
const response = {
|
||||
...discovery,
|
||||
version: resolveFluxerVersion(),
|
||||
notice,
|
||||
domain_migration: toDomainMigrationDiscovery(domainMigration),
|
||||
guild_badges: badgeHead.value.badges.map(mapGuildBadge),
|
||||
|
||||
@@ -36,6 +36,29 @@ describe('discovery fields for self-hosted clients', () => {
|
||||
expect(discovery.community).toMatchObject({direct_messages_disabled: true, friends_disabled: true});
|
||||
});
|
||||
|
||||
it('reports the release version of the server', async () => {
|
||||
const previous = process.env.BUILD_VERSION;
|
||||
try {
|
||||
delete process.env.BUILD_VERSION;
|
||||
const local = await createBuilderWithoutAuth<WellKnownFluxerResponse>(harness)
|
||||
.get('/.well-known/fluxer')
|
||||
.execute();
|
||||
expect(local.version).toBe('dev');
|
||||
|
||||
process.env.BUILD_VERSION = '2026.1201.31153';
|
||||
const released = await createBuilderWithoutAuth<WellKnownFluxerResponse>(harness)
|
||||
.get('/.well-known/fluxer')
|
||||
.execute();
|
||||
expect(released.version).toBe('2026.1201.31153');
|
||||
} finally {
|
||||
if (previous === undefined) {
|
||||
delete process.env.BUILD_VERSION;
|
||||
} else {
|
||||
process.env.BUILD_VERSION = previous;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it('fills friends_disabled from the direct message flag for an older server', () => {
|
||||
const document = parseInstanceDiscoveryDocument({
|
||||
api_code_version: 1,
|
||||
|
||||
Generated
+4
@@ -40873,6 +40873,10 @@
|
||||
"maximum": 9007199254740991,
|
||||
"description": "Version of the API server code"
|
||||
},
|
||||
"version": {
|
||||
"description": "Release version of the server, such as 2026.1201.31153, or dev for a local build",
|
||||
"type": "string"
|
||||
},
|
||||
"endpoints": {"$ref": "#/components/schemas/InstanceEndpointsSchema"},
|
||||
"captcha": {"$ref": "#/components/schemas/InstanceCaptchaSchema"},
|
||||
"features": {"$ref": "#/components/schemas/InstanceFeaturesSchema"},
|
||||
|
||||
@@ -18,6 +18,7 @@ The public description of one instance.
|
||||
| --- | --- | --- |
|
||||
| codename? | string | The protocol generation the instance speaks |
|
||||
| api_code_version | integer | The API code version, which goes up when clients need to change their behaviour |
|
||||
| version? | string | The release version of the server, such as `2026.1201.31153`, or `dev` for a local build |
|
||||
| endpoints | [instance endpoints](#instance-endpoints-object) object | Public service URLs |
|
||||
| captcha | [captcha configuration](#captcha-configuration-object) object | CAPTCHA configuration |
|
||||
| features | [instance features](#instance-features-object) object | Instance-wide feature switches |
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import {Headers as HttpHeaders} from '@fluxer/constants/src/Headers';
|
||||
import type {MiddlewareHandler} from 'hono';
|
||||
|
||||
function resolveFluxerVersion(): string {
|
||||
export function resolveFluxerVersion(): string {
|
||||
const value = process.env.BUILD_VERSION?.trim();
|
||||
return value && value.length > 0 ? value : 'dev';
|
||||
}
|
||||
|
||||
@@ -543,6 +543,10 @@ export type InstanceHiddenBuiltInGuildBadges = z.infer<typeof InstanceHiddenBuil
|
||||
export const WellKnownFluxerResponse = z.object({
|
||||
codename: z.string().optional().describe('Protocol generation spoken by this instance'),
|
||||
api_code_version: z.number().int().describe('Version of the API server code'),
|
||||
version: z
|
||||
.string()
|
||||
.optional()
|
||||
.describe('Release version of the server, such as 2026.1201.31153, or dev for a local build'),
|
||||
endpoints: InstanceEndpointsSchema,
|
||||
captcha: InstanceCaptchaSchema,
|
||||
features: InstanceFeaturesSchema,
|
||||
|
||||
Reference in new issue
Block a user