Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp

feat(admin): add notes to voice servers (#3665)

Hampusa4993420a935
diff --git a/fluxer_admin/openapi-admin.json b/fluxer_admin/openapi-admin.json
index a32423c90..64c86c3f3 100644
--- a/fluxer_admin/openapi-admin.json
+++ b/fluxer_admin/openapi-admin.json
@@ -12718,6 +12718,12 @@
"minimum": 1,
"maximum": 2147483647
},
+ "notes": {
+ "description": "Free-form admin notes about this server, or null to clear them",
+ "nullable": true,
+ "type": "string",
+ "maxLength": 2000
+ },
"vip_only": {"description": "Whether this server is restricted to VIP users", "type": "boolean"},
"required_guild_features": {
"description": "Guild features required to use this server",
@@ -12792,6 +12798,12 @@
"minimum": 1,
"maximum": 2147483647
},
+ "notes": {
+ "description": "Free-form admin notes about this server",
+ "nullable": true,
+ "type": "string",
+ "maxLength": 2000
+ },
"vip_only": {
"default": false,
"description": "Whether this server is restricted to VIP users",
@@ -23899,10 +23911,17 @@
},
"pass_count": {
"nullable": true,
- "description": "Passes held after a count change",
+ "description": "The displayed count after a change. Older events recorded held passes.",
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
+ },
+ "first_pass_at": {
+ "description": "The earliest qualifying delivery for this count. Older events do not include this date.",
+ "nullable": true,
+ "type": "string",
+ "format": "date-time",
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
}
},
"required": [
@@ -24209,6 +24228,12 @@
"maximum": 9007199254740991,
"description": "How many passes the account holds now"
},
+ "recognition_count": {
+ "description": "The public count of valid held passes and purchases passed on. It is zero without active benefits.",
+ "type": "integer",
+ "minimum": 0,
+ "maximum": 9007199254740991
+ },
"wall_chosen": {
"type": "boolean",
"description": "Whether the account already chose to be listed or not listed on the Operators' wall. When false, checkout and accepting an offer ask for the choice"
@@ -24331,7 +24356,7 @@
"Staff made a technical adjustment to how the name is shown",
"The name was published in a The Operators of list",
"Staff erased the name from a published list",
- "The number of passes held changed, which moves the place on the wall, see pass_count"
+ "The displayed wall count changed, see pass_count"
],
"enum": [
"delivered",
@@ -24671,6 +24696,11 @@
"minimum": 1,
"maximum": 2147483647
},
+ "notes": {
+ "nullable": true,
+ "description": "Free-form admin notes about this server, or null when there are none",
+ "type": "string"
+ },
"vip_only": {"type": "boolean", "description": "Whether this server is restricted to VIP users"},
"required_guild_features": {
"maxItems": 100,
@@ -24709,6 +24739,7 @@
"longitude",
"is_active",
"soft_connection_limit",
+ "notes",
"vip_only",
"required_guild_features",
"allowed_guild_ids",
diff --git a/fluxer_admin/src/api/types/voice.rs b/fluxer_admin/src/api/types/voice.rs
index 64fe95884..a51c44401 100644
--- a/fluxer_admin/src/api/types/voice.rs
+++ b/fluxer_admin/src/api/types/voice.rs
@@ -29,6 +29,7 @@ pub struct VoiceServer {
pub longitude: Option<f64>,
pub is_active: Option<bool>,
pub soft_connection_limit: Option<i64>,
+ pub notes: Option<String>,
pub vip_only: Option<bool>,
#[serde(default)]
pub required_guild_features: Vec<String>,
diff --git a/fluxer_admin/src/routes/voice_actions.rs b/fluxer_admin/src/routes/voice_actions.rs
index c26abcd50..b1e0a9e73 100644
--- a/fluxer_admin/src/routes/voice_actions.rs
+++ b/fluxer_admin/src/routes/voice_actions.rs
@@ -93,6 +93,17 @@ pub(crate) fn build_server_body(form: &MultiValueForm) -> serde_json::Value {
body.insert("soft_connection_limit".into(), limit.into());
}
}
+ if let Some(raw) = form.first("notes") {
+ let trimmed = raw.trim();
+ body.insert(
+ "notes".into(),
+ if trimmed.is_empty() {
+ serde_json::Value::Null
+ } else {
+ trimmed.into()
+ },
+ );
+ }
body.insert("vip_only".into(), form.bool_value("vip_only").into());
insert_submitted_list(&mut body, form, "required_guild_features");
insert_submitted_list(&mut body, form, "allowed_guild_ids");
diff --git a/fluxer_admin/src/templates/pages/voice_servers.rs b/fluxer_admin/src/templates/pages/voice_servers.rs
index 880f0be0b..ce2d2a1cd 100644
--- a/fluxer_admin/src/templates/pages/voice_servers.rs
+++ b/fluxer_admin/src/templates/pages/voice_servers.rs
@@ -195,6 +195,12 @@ fn server_card(
(data_field_text("Soft connection limit", &soft_limit_str))
(data_field_text("Live connections", &connections_str))
}
+ @if let Some(notes) = server.notes.as_deref() {
+ div class="mb-4" {
+ p class="mb-1 font-medium text-neutral-500 text-xs uppercase tracking-wide" { "Notes" }
+ p class="whitespace-pre-wrap break-words text-neutral-900 text-sm" { (notes) }
+ }
+ }
(voice_features_list(&server.required_guild_features))
(voice_guild_ids_list(&server.allowed_guild_ids))
div class="flex flex-wrap gap-2 mt-4" {
diff --git a/fluxer_admin/src/templates/pages/voice_servers_forms.rs b/fluxer_admin/src/templates/pages/voice_servers_forms.rs
index 92f580bd9..846eb9ae4 100644
--- a/fluxer_admin/src/templates/pages/voice_servers_forms.rs
+++ b/fluxer_admin/src/templates/pages/voice_servers_forms.rs
@@ -31,6 +31,7 @@ pub fn edit_server_form(
let soft_limit_val = server
.soft_connection_limit
.map_or_else(String::new, |v| v.to_string());
+ let notes = server.notes.as_deref().unwrap_or("");
let vip_only = server.vip_only.unwrap_or(false);
let features_csv = server.required_guild_features.join(", ");
let guild_ids_csv = server.allowed_guild_ids.join(", ");
@@ -71,6 +72,7 @@ pub fn edit_server_form(
"Leave empty for no limit",
"Placement prefers another server once this server holds this many connections",
))
+ (notes_field(&format!("{id_prefix}-notes"), notes))
(form_field_with_helper(
"API Key",
&format!("{id_prefix}-api-key"),
@@ -135,6 +137,7 @@ pub fn create_server_form(config: &AdminConfig, region_id: &str, csrf_token: &st
"Placement prefers another server once this server holds this many connections",
))
}
+ (notes_field("new-server-notes", ""))
div class="space-y-3" {
(Checkbox {
name: "is_active",
@@ -181,3 +184,22 @@ fn form_field_with_helper(
}
}
}
+
+fn notes_field(id: &str, value: &str) -> Markup {
+ html! {
+ div class="space-y-1" {
+ label for=(id) class="block text-sm font-medium text-neutral-700" {
+ "Notes (optional)"
+ }
+ textarea id=(id) name="notes" rows="3" maxlength="2000"
+ placeholder="Anything worth remembering about this server"
+ class="block w-full rounded-md border border-neutral-300 \
+ px-3 py-2 text-sm shadow-sm \
+ focus:border-brand-primary focus:outline-none \
+ focus:ring-1 focus:ring-brand-primary" {
+ (value)
+ }
+ p class="text-xs text-neutral-500" { "Only admins see this" }
+ }
+ }
+}
diff --git a/fluxer_api/src/api/admin/services/AdminVoiceService.ts b/fluxer_api/src/api/admin/services/AdminVoiceService.ts
index cc5e9016a..bcd51a13f 100644
--- a/fluxer_api/src/api/admin/services/AdminVoiceService.ts
+++ b/fluxer_api/src/api/admin/services/AdminVoiceService.ts
@@ -231,6 +231,7 @@ export class AdminVoiceService {
endpoint: data.endpoint,
isActive: data.is_active ?? true,
softConnectionLimit: data.soft_connection_limit ?? null,
+ notes: data.notes ?? null,
apiKey: data.api_key ?? null,
apiSecret: data.api_secret ?? null,
latitude: data.latitude ?? null,
@@ -269,6 +270,7 @@ export class AdminVoiceService {
if (data.longitude !== undefined) updates.longitude = data.longitude;
if (data.is_active !== undefined) updates.isActive = data.is_active;
if (data.soft_connection_limit !== undefined) updates.softConnectionLimit = data.soft_connection_limit;
+ if (data.notes !== undefined) updates.notes = data.notes;
updates.restrictions = patchVoiceRestrictions(existing.restrictions, data);
updates.updatedAt = new Date();
await voiceRepository.upsertServer(updates);
@@ -340,6 +342,7 @@ export class AdminVoiceService {
longitude: server.longitude ?? null,
is_active: server.isActive,
soft_connection_limit: server.softConnectionLimit ?? null,
+ notes: server.notes,
vip_only: server.restrictions.vipOnly,
required_guild_features: Array.from(server.restrictions.requiredGuildFeatures),
allowed_guild_ids: allowedGuildIds,
diff --git a/fluxer_api/src/api/admin/tests/VoiceAdminController.test.ts b/fluxer_api/src/api/admin/tests/VoiceAdminController.test.ts
index fadedcc74..9de0fdc49 100644
--- a/fluxer_api/src/api/admin/tests/VoiceAdminController.test.ts
+++ b/fluxer_api/src/api/admin/tests/VoiceAdminController.test.ts
@@ -133,4 +133,39 @@ describe('VoiceAdminController', () => {
expect(persisted?.apiKey).toBe(fixture.initialApiKey);
expect(persisted?.apiSecret).toBe(fixture.initialApiSecret);
});
+ test('stores, keeps and clears free-form server notes', async () => {
+ const admin = await createAdminWithAcls(harness, [
+ AdminACLs.VOICE_REGION_CREATE,
+ AdminACLs.VOICE_SERVER_CREATE,
+ AdminACLs.VOICE_SERVER_UPDATE,
+ ]);
+ const fixture = await createVoiceFixture(harness, admin, {
+ regionId: 'voice-region-notes',
+ serverId: 'voice-server-notes',
+ endpoint: 'https://voice-notes.example.com/socket',
+ apiKey: 'notes-api-key',
+ apiSecret: 'notes-api-secret',
+ });
+ expect((await voiceRepository.getServer(fixture.regionId, fixture.serverId))?.notes).toBeNull();
+ const updated = await createBuilder<UpdateVoiceServerResponse>(harness, `${admin.token}`)
+ .patch(`/admin/voice/regions/${fixture.regionId}/servers/${fixture.serverId}`)
+ .body({notes: ' Hetzner box, renew in March '})
+ .expect(HTTP_STATUS.OK)
+ .execute();
+ expect(updated.server.notes).toBe('Hetzner box, renew in March');
+ await createBuilder<UpdateVoiceServerResponse>(harness, `${admin.token}`)
+ .patch(`/admin/voice/regions/${fixture.regionId}/servers/${fixture.serverId}`)
+ .body({is_active: false})
+ .expect(HTTP_STATUS.OK)
+ .execute();
+ expect((await voiceRepository.getServer(fixture.regionId, fixture.serverId))?.notes).toBe(
+ 'Hetzner box, renew in March',
+ );
+ await createBuilder<UpdateVoiceServerResponse>(harness, `${admin.token}`)
+ .patch(`/admin/voice/regions/${fixture.regionId}/servers/${fixture.serverId}`)
+ .body({notes: ' '})
+ .expect(HTTP_STATUS.OK)
+ .execute();
+ expect((await voiceRepository.getServer(fixture.regionId, fixture.serverId))?.notes).toBeNull();
+ });
});
diff --git a/fluxer_api/src/api/database/types/VoiceTypes.ts b/fluxer_api/src/api/database/types/VoiceTypes.ts
index 9fdee5cd0..721fc6108 100644
--- a/fluxer_api/src/api/database/types/VoiceTypes.ts
+++ b/fluxer_api/src/api/database/types/VoiceTypes.ts
@@ -42,6 +42,7 @@ export interface VoiceServerRow {
longitude: number | null;
is_active: boolean | null;
soft_connection_limit: number | null;
+ notes: string | null;
vip_only: boolean | null;
required_guild_features: Set<string> | null;
allowed_guild_ids: Set<bigint> | null;
@@ -60,6 +61,7 @@ export const VOICE_SERVER_COLUMNS = [
'longitude',
'is_active',
'soft_connection_limit',
+ 'notes',
'vip_only',
'required_guild_features',
'allowed_guild_ids',
diff --git a/fluxer_api/src/api/openapi/openapi.json b/fluxer_api/src/api/openapi/openapi.json
index f60ad88e9..55642a352 100644
--- a/fluxer_api/src/api/openapi/openapi.json
+++ b/fluxer_api/src/api/openapi/openapi.json
@@ -32340,6 +32340,12 @@
"maximum": 9007199254740991,
"description": "How many passes the account holds now"
},
+ "recognition_count": {
+ "description": "The public count of valid held passes and purchases passed on. It is zero without active benefits.",
+ "type": "integer",
+ "minimum": 0,
+ "maximum": 9007199254740991
+ },
"passes": {
"type": "array",
"items": {"$ref": "#/components/schemas/OperatorPassUnitResponse"},
@@ -32575,7 +32581,7 @@
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991,
- "description": "How many passes the account holds now, shown to the holder in every case"
+ "description": "Public count of valid held passes and purchases passed on, shown to the holder even when hidden publicly"
}
},
"required": [
@@ -42300,6 +42306,12 @@
"maximum": 9007199254740991,
"description": "How many passes the account holds now"
},
+ "recognition_count": {
+ "description": "The public count of valid held passes and purchases passed on. It is zero without active benefits.",
+ "type": "integer",
+ "minimum": 0,
+ "maximum": 9007199254740991
+ },
"wall_chosen": {
"type": "boolean",
"description": "Whether the account already chose to be listed or not listed on the Operators' wall. When false, checkout and accepting an offer ask for the choice"
diff --git a/fluxer_api/src/api/voice/VoiceDataInitializer.ts b/fluxer_api/src/api/voice/VoiceDataInitializer.ts
index b5a3630b7..9af7c7d60 100644
--- a/fluxer_api/src/api/voice/VoiceDataInitializer.ts
+++ b/fluxer_api/src/api/voice/VoiceDataInitializer.ts
@@ -57,6 +57,7 @@ export class VoiceDataInitializer {
longitude: null,
isActive: true,
softConnectionLimit: null,
+ notes: null,
restrictions: {
vipOnly: false,
requiredGuildFeatures: new Set(),
diff --git a/fluxer_api/src/api/voice/VoiceModel.ts b/fluxer_api/src/api/voice/VoiceModel.ts
index 052398856..08e59aaf5 100644
--- a/fluxer_api/src/api/voice/VoiceModel.ts
+++ b/fluxer_api/src/api/voice/VoiceModel.ts
@@ -31,6 +31,7 @@ export interface VoiceServerRecord {
longitude: number | null;
isActive: boolean;
softConnectionLimit: number | null;
+ notes: string | null;
restrictions: VoiceRestriction;
createdAt: Date | null;
updatedAt: Date | null;
diff --git a/fluxer_api/src/api/voice/VoiceRepository.ts b/fluxer_api/src/api/voice/VoiceRepository.ts
index 22d86e612..7f17b6fcd 100644
--- a/fluxer_api/src/api/voice/VoiceRepository.ts
+++ b/fluxer_api/src/api/voice/VoiceRepository.ts
@@ -147,6 +147,7 @@ export class VoiceRepository {
longitude: server.longitude ?? null,
is_active: server.isActive,
soft_connection_limit: server.softConnectionLimit ?? null,
+ notes: server.notes,
vip_only: server.restrictions.vipOnly,
required_guild_features: new Set(server.restrictions.requiredGuildFeatures),
allowed_guild_ids: new Set(Array.from(server.restrictions.allowedGuildIds).map((id) => BigInt(id))),
@@ -191,6 +192,7 @@ export class VoiceRepository {
longitude: row.longitude ?? null,
isActive: row.is_active ?? true,
softConnectionLimit: row.soft_connection_limit ?? null,
+ notes: row.notes ?? null,
restrictions: {
vipOnly: row.vip_only ?? false,
requiredGuildFeatures: new Set(toIterable<string>(row.required_guild_features)),
diff --git a/fluxer_api/src/api/voice/tests/VoiceAvailabilityService.test.ts b/fluxer_api/src/api/voice/tests/VoiceAvailabilityService.test.ts
index 4de154630..551aa6ea5 100644
--- a/fluxer_api/src/api/voice/tests/VoiceAvailabilityService.test.ts
+++ b/fluxer_api/src/api/voice/tests/VoiceAvailabilityService.test.ts
@@ -46,6 +46,7 @@ function createServer(overrides: Partial<VoiceServerRecord> = {}): VoiceServerRe
longitude: null,
isActive: true,
softConnectionLimit: null,
+ notes: null,
restrictions: {
vipOnly: false,
requiredGuildFeatures: new Set(),
diff --git a/fluxer_api/src/api/voice/tests/VoiceRegionSelection.test.ts b/fluxer_api/src/api/voice/tests/VoiceRegionSelection.test.ts
index fb390e69b..8cb8844ed 100644
--- a/fluxer_api/src/api/voice/tests/VoiceRegionSelection.test.ts
+++ b/fluxer_api/src/api/voice/tests/VoiceRegionSelection.test.ts
@@ -64,6 +64,7 @@ function createVoiceServer({
longitude,
isActive: true,
softConnectionLimit,
+ notes: null,
restrictions: {
vipOnly: false,
requiredGuildFeatures: new Set(),
diff --git a/packages/schema/src/domains/admin/AdminVoiceSchemas.ts b/packages/schema/src/domains/admin/AdminVoiceSchemas.ts
index e03e279f9..05230ed05 100644
--- a/packages/schema/src/domains/admin/AdminVoiceSchemas.ts
+++ b/packages/schema/src/domains/admin/AdminVoiceSchemas.ts
@@ -23,6 +23,13 @@ function areServerCoordinatesPaired(
const SoftConnectionLimitType = z.number().int().min(1).max(2147483647).nullable();
+const VoiceServerNotesType = z
+ .string()
+ .trim()
+ .max(2000)
+ .nullable()
+ .transform((value) => value || null);
+
export const VoiceRegionAdminResponse = z.object({
id: z.string().describe('Unique identifier for the voice region'),
name: z.string().describe('Display name of the voice region'),
@@ -50,6 +57,7 @@ export const VoiceServerAdminResponse = z.object({
soft_connection_limit: SoftConnectionLimitType.describe(
'Connection count above which placement prefers another server, or null when the server has no limit',
),
+ notes: z.string().nullable().describe('Free-form admin notes about this server, or null when there are none'),
vip_only: z.boolean().describe('Whether this server is restricted to VIP users'),
required_guild_features: z.array(z.string()).max(100).describe('Guild features required to use this server'),
allowed_guild_ids: z.array(SnowflakeStringType).max(1000).describe('Guild IDs explicitly allowed to use this server'),
@@ -137,6 +145,7 @@ export const CreateVoiceServerRequestBody = z
soft_connection_limit: SoftConnectionLimitType.optional()
.default(null)
.describe('Connection count above which placement prefers another server, or null for no limit'),
+ notes: VoiceServerNotesType.optional().default(null).describe('Free-form admin notes about this server'),
vip_only: z.boolean().optional().default(false).describe('Whether this server is restricted to VIP users'),
required_guild_features: z
.array(createStringType(1, 64))
@@ -179,6 +188,7 @@ export const UpdateVoiceServerRequestBody = z
soft_connection_limit: SoftConnectionLimitType.optional().describe(
'Connection count above which placement prefers another server, or null for no limit',
),
+ notes: VoiceServerNotesType.optional().describe('Free-form admin notes about this server, or null to clear them'),
vip_only: z.boolean().optional().describe('Whether this server is restricted to VIP users'),
required_guild_features: z
.array(createStringType(1, 64))
diff --git a/tools/dev/cassandra_target_schema.json b/tools/dev/cassandra_target_schema.json
index 9ac0e07d7..36528d31b 100644
--- a/tools/dev/cassandra_target_schema.json
+++ b/tools/dev/cassandra_target_schema.json
@@ -10414,6 +10414,10 @@
{
"name": "soft_connection_limit",
"type": "int"
+ },
+ {
+ "name": "notes",
+ "type": "text"
}
],
"primary_key": "((region_id), server_id)",