A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.
fix(api): keep the API code version at 1 (#3731)
Hampusbe4ab49a4b10
diff --git a/fluxer_api/src/api/instance/tests/DiscoverySelfHostFields.test.ts b/fluxer_api/src/api/instance/tests/DiscoverySelfHostFields.test.tsindex fc72da02f..e8ee44802 100644--- a/fluxer_api/src/api/instance/tests/DiscoverySelfHostFields.test.ts+++ b/fluxer_api/src/api/instance/tests/DiscoverySelfHostFields.test.ts@@ -32,6 +32,7 @@ describe('discovery fields for self-hosted clients', () => {const discovery = await createBuilderWithoutAuth<WellKnownFluxerResponse>(harness).get('/.well-known/fluxer').execute();+ expect(discovery.api_code_version).toBe(1);expect(discovery.community).toMatchObject({direct_messages_disabled: true, friends_disabled: true});});diff --git a/fluxer_api/src/api/openapi/openapi.json b/fluxer_api/src/api/openapi/openapi.jsonindex d4ab86910..09f161521 100644--- a/fluxer_api/src/api/openapi/openapi.json+++ b/fluxer_api/src/api/openapi/openapi.json@@ -27381,6 +27381,11 @@"items": {"$ref": "#/components/schemas/VoiceTurnServer"},"description": "TURN servers of the instance, for the LiveKit configuration of the voice server"},+ "features": {+ "type": "array",+ "items": {"type": "string"},+ "description": "What this API supports for voice servers. server_addresses means it accepts public_ipv4 and public_ipv6 in updates"+ },"health": {"description": "Health of the server as this API node last saw it","$ref": "#/components/schemas/VoiceServerHealthResponse"@@ -27398,6 +27403,7 @@"public_ipv4","public_ipv6","turn_servers",+ "features","health"],"additionalProperties": falsediff --git a/fluxer_api/src/api/voice/VoiceNodeService.ts b/fluxer_api/src/api/voice/VoiceNodeService.tsindex 364d9d0a0..60a474c34 100644--- a/fluxer_api/src/api/voice/VoiceNodeService.ts+++ b/fluxer_api/src/api/voice/VoiceNodeService.ts@@ -365,6 +365,7 @@ export class VoiceNodeService {public_ipv4: server.publicIpv4,public_ipv6: server.publicIpv6,turn_servers: turnServers(),+ features: ['server_addresses'],health: toHealthResponse(healthOf(this.deps.health, server)),};}diff --git a/fluxer_docs/src/content/docs/admin-api/voice.mdx b/fluxer_docs/src/content/docs/admin-api/voice.mdxindex e12185397..ab75a83a7 100644--- a/fluxer_docs/src/content/docs/admin-api/voice.mdx+++ b/fluxer_docs/src/content/docs/admin-api/voice.mdx@@ -594,7 +594,7 @@ Fluxer refuses tokens with a `video` grant. LiveKit participant tokens and webho<RouteHeader method="GET" path="/v1/voice/node" unauthenticated />-Returns the server's `region_id`, `server_id`, `endpoint`, `latitude`, `longitude`, `is_active`, `draining`, `soft_connection_limit`, `public_ipv4`, `public_ipv6`, `turn_servers` and `health`.+Returns the server's `region_id`, `server_id`, `endpoint`, `latitude`, `longitude`, `is_active`, `draining`, `soft_connection_limit`, `public_ipv4`, `public_ipv6`, `turn_servers`, `features` and `health`. `features` lists what the API supports for voice servers. `server_addresses` means `PATCH` takes `public_ipv4` and `public_ipv6`.<RouteHeader method="PATCH" path="/v1/voice/node" unauthenticated />diff --git a/fluxer_rexctl/cmd/voice_lifecycle.go b/fluxer_rexctl/cmd/voice_lifecycle.goindex b1ff3637b..abb74dfb2 100644--- a/fluxer_rexctl/cmd/voice_lifecycle.go+++ b/fluxer_rexctl/cmd/voice_lifecycle.go@@ -11,6 +11,7 @@ import ("os""path/filepath""runtime"+ "slices""sync""time"@@ -319,10 +320,6 @@ func refreshJoinedServers(ctx context.Context, app *App, inst *instance.Instancereturn}client := &voice.Client{HTTP: &http.Client{Timeout: 30 * time.Second}}- code := 0- if d, err := client.Discover(ctx, inst.State.Voice[0].Instance); err == nil {- code = d.APICodeVersion- }for i := range inst.State.Voice {srv := &inst.State.Voice[i]if srv.NodeURL == "" {@@ -336,7 +333,7 @@ func refreshJoinedServers(ctx context.Context, app *App, inst *instance.Instanceif node.Turn != nil {srv.Turn = settings.TurnServersValue(*node.Turn)}- if !report || code < voice.AddressesCodeVersion || stringOf(node.PublicIPv4) == srv.NodeIP && stringOf(node.PublicIPv6) == srv.NodeIPv6 {+ if !report || !slices.Contains(node.Features, voice.FeatureServerAddresses) || stringOf(node.PublicIPv4) == srv.NodeIP && stringOf(node.PublicIPv6) == srv.NodeIPv6 {continue}v4, v6 := srv.NodeIP, srv.NodeIPv6diff --git a/fluxer_rexctl/internal/voice/node.go b/fluxer_rexctl/internal/voice/node.goindex d4d86937d..194203729 100644--- a/fluxer_rexctl/internal/voice/node.go+++ b/fluxer_rexctl/internal/voice/node.go@@ -27,7 +27,7 @@ const (NodePath = "/voice/node"nodeTokenLife = 2 * time.Minute- AddressesCodeVersion = 2+ FeatureServerAddresses = "server_addresses")const (@@ -246,6 +246,7 @@ type Node struct {Turn *[]settings.TurnServer `json:"turn_servers"`PublicIPv4 *string `json:"public_ipv4"`PublicIPv6 *string `json:"public_ipv6"`+ Features []string `json:"features"`Health struct {Status string `json:"status"`CheckedAt *string `json:"checked_at"`diff --git a/packages/constants/src/AppConstants.ts b/packages/constants/src/AppConstants.tsindex 03f96e852..46a1fb5fa 100644--- a/packages/constants/src/AppConstants.ts+++ b/packages/constants/src/AppConstants.ts@@ -1,6 +1,6 @@// SPDX-License-Identifier: AGPL-3.0-or-later-export const API_CODE_VERSION = 2;+export const API_CODE_VERSION = 1;export const DEFAULT_API_VERSION = 1;export const FLUXERBOT_ID = '0';export const ME = '@me';diff --git a/packages/schema/src/domains/voice/VoiceNodeSchemas.ts b/packages/schema/src/domains/voice/VoiceNodeSchemas.tsindex 35d6396ed..05af2a4b5 100644--- a/packages/schema/src/domains/voice/VoiceNodeSchemas.ts+++ b/packages/schema/src/domains/voice/VoiceNodeSchemas.ts@@ -114,6 +114,11 @@ export const VoiceNodeResponse = z.object({public_ipv4: z.string().nullable().describe('Public IPv4 address the server last reported, or null'),public_ipv6: z.string().nullable().describe('Public IPv6 address the server last reported, or null'),turn_servers: TurnServersType,+ features: z+ .array(z.string())+ .describe(+ 'What this API supports for voice servers. server_addresses means it accepts public_ipv4 and public_ipv6 in updates',+ ),health: VoiceServerHealthResponse.describe('Health of the server as this API node last saw it'),});