Skip to content

A platform for community discussion. Free, open, simple.

FEATURE: Add support for hosted LiveKit recordings via S3 (#43485)

Penar Musarajfd884e105d27
diff --git a/plugins/voice/README.md b/plugins/voice/README.md
index 4083ba195bd..bc921bd3961 100644
--- a/plugins/voice/README.md
+++ b/plugins/voice/README.md
@@ -1,6 +1,6 @@
# Voice
-Voice is a Discourse plugin that adds Discord-style voice rooms powered by WebRTC. Rooms appear in the sidebar; users join or leave with a single click and talk peer-to-peer — no media goes through the Discourse server. Sites that need bigger calls can optionally route rooms through a self-hosted [LiveKit](https://livekit.io) media server.
+Voice is a Discourse plugin that adds Discord-style voice rooms powered by WebRTC. Rooms appear in the sidebar; users join or leave with a single click and talk peer-to-peer — no media goes through the Discourse server. Sites that need bigger calls can optionally route rooms through a hosted or self-hosted [LiveKit](https://livekit.io) media server.
> **Status:** early alpha — test with small groups before opening to a full community.
diff --git a/plugins/voice/admin/assets/javascripts/admin/components/voice-recording-list.gjs b/plugins/voice/admin/assets/javascripts/admin/components/voice-recording-list.gjs
index dab5815619d..718a0b49e39 100644
--- a/plugins/voice/admin/assets/javascripts/admin/components/voice-recording-list.gjs
+++ b/plugins/voice/admin/assets/javascripts/admin/components/voice-recording-list.gjs
@@ -5,6 +5,7 @@ import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
import DButton from "discourse/ui-kit/d-button";
import DConditionalLoadingSpinner from "discourse/ui-kit/d-conditional-loading-spinner";
+import DFlashMessage from "discourse/ui-kit/d-flash-message";
import DPageSubheader from "discourse/ui-kit/d-page-subheader";
import dAvatar from "discourse/ui-kit/helpers/d-avatar";
import dFormatDate from "discourse/ui-kit/helpers/d-format-date";
@@ -73,6 +74,17 @@ export default class VoiceRecordingList extends Component {
@titleLabel={{i18n "voice.admin.recordings_title"}}
/>
+ {{#unless @model.last_webhook_at}}
+ <DFlashMessage
+ class="voice-recordings__webhook-note"
+ @flash={{i18n
+ "voice.admin.recordings.webhook_config_hint"
+ }}
+ @type="info"
+ />
+ {{/unless}}
+
{{#if this.recordings.length}}
<table class="d-admin-table voice-recordings__table">
<thead>
diff --git a/plugins/voice/app/controllers/voice/admin_recordings_controller.rb b/plugins/voice/app/controllers/voice/admin_recordings_controller.rb
index 07edceb6145..5edfad8f3dd 100644
--- a/plugins/voice/app/controllers/voice/admin_recordings_controller.rb
+++ b/plugins/voice/app/controllers/voice/admin_recordings_controller.rb
@@ -21,6 +21,8 @@ module Voice
render json: {
recordings: serialize_data(recordings, Voice::AdminRecordingSerializer, root: false),
has_more: has_more,
+ last_webhook_at: Voice::Livekit.last_webhook_at&.iso8601,
+ webhook_url: "#{Discourse.base_url}/voice/livekit/webhook",
}
end
end
diff --git a/plugins/voice/app/validators/voice_livekit_recording_s3_bucket_validator.rb b/plugins/voice/app/validators/voice_livekit_recording_s3_bucket_validator.rb
new file mode 100644
index 00000000000..2466e5ae10f
--- /dev/null
+++ b/plugins/voice/app/validators/voice_livekit_recording_s3_bucket_validator.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+
+class VoiceLivekitRecordingS3BucketValidator
+ include RegexSettingValidation
+
+ def initialize(opts = {})
+ initialize_regex_opts(opts)
+ end
+
+ def valid_value?(value)
+ @error_key = nil
+ @regex_fail = false
+ return true if value.blank?
+ return false if !regex_match?(value)
+
+ @error_key =
+ if SiteSetting.voice_livekit_recording_s3_access_key_id.blank? ||
+ SiteSetting.voice_livekit_recording_s3_secret_access_key.blank?
+ "voice_livekit_recording_s3_requires_credentials"
+ elsif SiteSetting.voice_livekit_recording_s3_region.blank? &&
+ SiteSetting.voice_livekit_recording_s3_endpoint.blank?
+ "voice_livekit_recording_s3_requires_region"
+ elsif !SiteSetting.voice_livekit_url.start_with?("wss://")
+ "voice_livekit_recording_s3_requires_wss"
+ end
+
+ @error_key.nil?
+ end
+
+ def error_message
+ return I18n.t(@regex_error) if @regex_fail
+
+ I18n.t("site_settings.errors.#{@error_key}") if @error_key
+ end
+end
diff --git a/plugins/voice/config/locales/client.en.yml b/plugins/voice/config/locales/client.en.yml
index 01cfc89d59a..27a7cd755a0 100644
--- a/plugins/voice/config/locales/client.en.yml
+++ b/plugins/voice/config/locales/client.en.yml
@@ -295,6 +295,7 @@ en:
dashboard_title: "Dashboard"
recordings_title: "Recordings"
recordings:
+ webhook_config_hint: "No LiveKit webhooks have been received recently. Configure a webhook in LiveKit pointing to %{webhook_url}. Use the same API key configured in the voice livekit api key site setting and include egress_ended events so recording statuses and download notifications update when recordings finish."
description: "Call recordings produced by the LiveKit egress service. Files stay on the storage configured on the recording server; completed recordings link to that location when it is a URL."
room: "Room"
requested_by: "Requested by"
diff --git a/plugins/voice/config/locales/server.en.yml b/plugins/voice/config/locales/server.en.yml
index dad0d652e0c..4cdf05092d2 100644
--- a/plugins/voice/config/locales/server.en.yml
+++ b/plugins/voice/config/locales/server.en.yml
@@ -38,9 +38,17 @@ en:
voice_livekit_room_policy: "Which rooms use the LiveKit media server instead of the peer-to-peer mesh. Changes never affect calls already in progress — each room switches when its next call starts."
voice_livekit_room_prefix: "Namespace prefix for room names on the LiveKit server. Leave empty to use the site's database name."
voice_livekit_mesh_fallback: "When a LiveKit access token cannot be issued and the room is empty, start the call on the peer-to-peer mesh instead of failing the join. Off by default because silent degradation can hide a LiveKit outage."
- voice_livekit_recording_enabled: "Allow room moderators to record calls that run on the LiveKit media server. Recordings are produced by LiveKit's Egress service and stored wherever that deployment is configured to write (S3, GCS, local disk) — they are not uploaded to this site."
+ voice_livekit_recording_enabled: "Allow room moderators to record calls that run on the LiveKit media server. LiveKit Cloud requires {{setting:voice_livekit_recording_s3_bucket}}. Self-hosted Egress can use its own storage configuration. Recordings are not Discourse uploads.<br><br>Configure a webhook in LiveKit pointing to <code>https://YOUR-FORUM/voice/livekit/webhook</code>, replacing YOUR-FORUM with this site's hostname. Use the same API key as {{setting:voice_livekit_api_key}} and include <code>egress_ended</code> events so recording statuses and download notifications update when recordings finish."
voice_livekit_recording_filepath: "Filepath passed to LiveKit Egress for recordings. Supports LiveKit's template placeholders such as {room_name}, {room_id}, {time} and {utc}; the file extension is added automatically."
+ voice_livekit_recording_s3_bucket: "Dedicated S3 bucket for voice recordings, without a path. Set the recording credentials and region before saving this setting. Use {{setting:voice_livekit_recording_filepath}} for a folder prefix. Leave empty to use self-hosted Egress storage. Discourse upload storage settings are not used."
+ voice_livekit_recording_s3_region: "AWS region of the recording bucket, such as us-east-1. Required unless {{setting:voice_livekit_recording_s3_endpoint}} is set."
+ voice_livekit_recording_s3_access_key_id: "S3 access key for the recording bucket. Sent to the configured LiveKit server over HTTPS when starting a recording. Use credentials with write access limited to the recording location."
+ voice_livekit_recording_s3_secret_access_key: "S3 secret key for the recording bucket. Sent only to the configured LiveKit server over HTTPS, never to participants."
+ voice_livekit_recording_s3_endpoint: "Optional HTTPS endpoint for S3-compatible recording storage, without a path or trailing slash. Leave empty for AWS S3. Custom endpoints use path-style bucket addressing."
errors:
+ voice_livekit_recording_s3_requires_credentials: "Set the recording S3 access key and secret key before setting a recording bucket."
+ voice_livekit_recording_s3_requires_region: "Set the recording S3 region or a custom endpoint before setting a recording bucket."
+ voice_livekit_recording_s3_requires_wss: "Use a wss:// LiveKit URL before configuring S3 recording storage so storage credentials are sent over HTTPS."
voice_turn_secret_servers_requires_secret: "Set voice_turn_secret before adding TURN servers that use short-lived credentials."
voice_livekit_policy_requires_url: "Set voice_livekit_url to a valid wss:// URL before enabling a LiveKit room policy."
voice_livekit_url_invalid: "The LiveKit URL must be a ws:// or wss:// URL with a hostname and no embedded credentials."
diff --git a/plugins/voice/config/settings.yml b/plugins/voice/config/settings.yml
index 13e3fe2e2f1..6b0503e2a4c 100644
--- a/plugins/voice/config/settings.yml
+++ b/plugins/voice/config/settings.yml
@@ -95,6 +95,21 @@ plugins:
client: true
voice_livekit_recording_filepath:
default: "voice/{room_name}-{utc}"
+ voice_livekit_recording_s3_region:
+ default: "us-east-1"
+ voice_livekit_recording_s3_access_key_id:
+ default: ""
+ secret: true
+ voice_livekit_recording_s3_secret_access_key:
+ default: ""
+ secret: true
+ voice_livekit_recording_s3_endpoint:
+ default: ""
+ regex: '^https://[a-zA-Z0-9.-]+(:[0-9]+)?$'
+ voice_livekit_recording_s3_bucket:
+ default: ""
+ regex: '^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$'
+ validator: "VoiceLivekitRecordingS3BucketValidator"
voice_video_enabled:
default: true
client: true
diff --git a/plugins/voice/docs/livekit.md b/plugins/voice/docs/livekit.md
index fe33c607c07..783379ef676 100644
--- a/plugins/voice/docs/livekit.md
+++ b/plugins/voice/docs/livekit.md
@@ -100,6 +100,51 @@ With `per_room` policy, room creators/managers get a "Use media server (SFU)"
checkbox in the room form. Toggling it affects the room's next call, never a
live one.
+## Recording to S3 with LiveKit Cloud
+
+LiveKit Cloud runs the recorder, but each recording request must specify
+where to store the file. Voice supports a dedicated S3 bucket using the
+settings below. These settings are independent of Discourse's upload and
+backup storage configuration.
+
+1. Create an S3 bucket for recordings and credentials with permission to
+ write objects under the recording prefix. Keep the bucket private unless
+ you intentionally want anyone with a recording URL to be able to read it.
+2. Configure `voice_livekit_url` with the project's `wss://` URL and set its
+ API key and secret.
+3. In Discourse site settings, configure these values, saving the bucket
+ last:
+
+ | Setting | Value |
+ | --- | --- |
+ | `voice_livekit_recording_s3_region` | The recording bucket's AWS region |
+ | `voice_livekit_recording_s3_access_key_id` | Dedicated recording access key |
+ | `voice_livekit_recording_s3_secret_access_key` | Dedicated recording secret key |
+ | `voice_livekit_recording_s3_endpoint` | Leave empty for AWS S3; an HTTPS origin for S3-compatible storage |
+ | `voice_livekit_recording_s3_bucket` | Bucket name only, without a folder prefix |
+ | `voice_livekit_recording_filepath` | Object key template, default `voice/{room_name}-{utc}` |
+
+4. Enable `voice_livekit_recording_enabled` and start a recording in a
+ LiveKit-routed room. Egress adds the file extension and Voice adds a random
+ suffix to the object key.
+
+The recording credentials are sent to the configured LiveKit server over
+HTTPS with each start request. No S3 credentials are sent to participants.
+The endpoint option uses path-style addressing for S3-compatible providers.
+
+When recording finishes, Voice sends the requester a PM with the location
+returned by LiveKit. **This is not a signed download URL.** For private
+buckets, an operator must retrieve the file using authenticated S3 access;
+the PM link alone does not grant access. Discourse secure-upload rules do
+not apply to these external recordings.
+
+An empty recording bucket preserves self-hosted Egress storage configuration.
+On LiveKit Cloud, a filepath without a storage destination can fail with
+`request has missing or invalid field: output`. Configure the dedicated S3
+settings to resolve this error; changing the filepath alone does not help.
+
+See [LiveKit's output and storage documentation](https://docs.livekit.io/transport/media/ingress-egress/egress/outputs/).
+
## Verifying a deployment
1. Join a LiveKit-routed room from two different networks and confirm you can
diff --git a/plugins/voice/lib/voice/livekit/egress_client.rb b/plugins/voice/lib/voice/livekit/egress_client.rb
index ac1b3ecf02d..d02b9715cce 100644
--- a/plugins/voice/lib/voice/livekit/egress_client.rb
+++ b/plugins/voice/lib/voice/livekit/egress_client.rb
@@ -3,9 +3,8 @@
module Voice
module Livekit
# Twirp-JSON client for LiveKit's Egress service, which records rooms
- # server-side. Where the recording lands (S3, GCS, local disk) is the
- # egress deployment's own configuration — Discourse only passes a
- # filepath, so no storage credentials live here.
+ # server-side. Dedicated S3 settings override the egress deployment's
+ # storage configuration and are required for recording on LiveKit Cloud.
#
# Unlike RoomServiceClient's fire-and-forget sync calls, these return a
# structured result: the caller (RecordingManager) must know whether a
@@ -17,11 +16,33 @@ module Voice
class << self
def start_room_composite(room, filepath:)
+ output = { filepath: filepath }
+ if SiteSetting.voice_livekit_recording_s3_bucket.present?
+ validator = VoiceLivekitRecordingS3BucketValidator.new
+ unless validator.valid_value?(SiteSetting.voice_livekit_recording_s3_bucket)
+ Rails.logger.warn(
+ "[voice-livekit] StartRoomCompositeEgress refused: #{validator.error_message}",
+ )
+ return { ok: false, error: validator.error_message }
+ end
+
+ output[:s3] = {
+ bucket: SiteSetting.voice_livekit_recording_s3_bucket,
+ region: SiteSetting.voice_livekit_recording_s3_region,
+ accessKey: SiteSetting.voice_livekit_recording_s3_access_key_id,
+ secret: SiteSetting.voice_livekit_recording_s3_secret_access_key,
+ }
+ if SiteSetting.voice_livekit_recording_s3_endpoint.present?
+ output[:s3][:endpoint] = SiteSetting.voice_livekit_recording_s3_endpoint
+ output[:s3][:forcePathStyle] = true
+ end
+ end
+
request(
"StartRoomCompositeEgress",
roomName: Livekit.room_name(room),
audioOnly: !room.video_allowed?,
- fileOutputs: [{ filepath: filepath }],
+ fileOutputs: [output],
)
end
@@ -56,7 +77,7 @@ module Voice
# surfaced to the UI only carries the status code.
Rails.logger.warn(
"[voice-livekit] #{method} failed: " \
- "HTTP #{response.status} #{response.body.to_s.truncate(200)}",
+ "HTTP #{response.status} #{redact_credentials(response.body).truncate(200)}",
)
{ ok: false, error: "HTTP #{response.status}" }
end
@@ -66,8 +87,20 @@ module Voice
error: "The LiveKit URL resolves to an address this server is not allowed to reach",
}
rescue StandardError => e
- Rails.logger.warn("[voice-livekit] #{method} failed: #{e.class} #{e.message}")
- { ok: false, error: "#{e.class}: #{e.message}" }
+ message = redact_credentials(e.message)
+ Rails.logger.warn("[voice-livekit] #{method} failed: #{e.class} #{message}")
+ { ok: false, error: "#{e.class}: #{message}" }
+ end
+
+ def redact_credentials(message)
+ message = message.to_s
+ [
+ SiteSetting.voice_livekit_recording_s3_access_key_id,
+ SiteSetting.voice_livekit_recording_s3_secret_access_key,
+ ].each do |credential|
+ message = message.gsub(credential, "[FILTERED]") if credential.present?
+ end
+ message
end
end
end
diff --git a/plugins/voice/spec/lib/voice/livekit/egress_client_spec.rb b/plugins/voice/spec/lib/voice/livekit/egress_client_spec.rb
index 4d4941f896e..a8efc0272d2 100644
--- a/plugins/voice/spec/lib/voice/livekit/egress_client_spec.rb
+++ b/plugins/voice/spec/lib/voice/livekit/egress_client_spec.rb
@@ -32,7 +32,111 @@ RSpec.describe Voice::Livekit::EgressClient do
stub_request(:post, "https://livekit.example.com/twirp/livekit.Egress/#{method}")
end
+ def configure_recording_s3
+ SiteSetting.voice_livekit_recording_s3_access_key_id = "recording-access-key"
+ SiteSetting.voice_livekit_recording_s3_secret_access_key = "recording-secret-key"
+ SiteSetting.voice_livekit_recording_s3_region = "eu-west-1"
+ SiteSetting.voice_livekit_recording_s3_bucket = "voice-recordings"
+ end
+
describe ".start_room_composite" do
+ it "sends dedicated S3 storage credentials without using the upload settings" do
+ configure_recording_s3
+ SiteSetting.s3_access_key_id = "upload-access-key"
+ SiteSetting.s3_secret_access_key = "upload-secret-key"
+ SiteSetting.s3_upload_bucket = "uploads"
+ stub =
+ twirp_stub("StartRoomCompositeEgress")
+ .with do |request|
+ JSON.parse(request.body)["fileOutputs"] ==
+ [
+ {
+ "filepath" => "voice/test-abc123",
+ "s3" => {
+ "bucket" => "voice-recordings",
+ "region" => "eu-west-1",
+ "accessKey" => "recording-access-key",
+ "secret" => "recording-secret-key",
+ },
+ },
+ ]
+ end
+ .to_return(body: { egressId: "EG_1" }.to_json)
+
+ result = described_class.start_room_composite(room, filepath: "voice/test-abc123")
+
+ expect(result).to eq(ok: true, data: { "egressId" => "EG_1" })
+ expect(stub).to have_been_requested.once
+ end
+
+ it "uses path-style addressing for a custom S3 endpoint" do
+ configure_recording_s3
+ SiteSetting.voice_livekit_recording_s3_endpoint = "https://storage.example.com"
+ stub =
+ twirp_stub("StartRoomCompositeEgress")
+ .with do |request|
+ storage = JSON.parse(request.body)["fileOutputs"].first["s3"]
+ storage["endpoint"] == "https://storage.example.com" &&
+ storage["forcePathStyle"] == true
+ end
+ .to_return(body: "{}")
+
+ result = described_class.start_room_composite(room, filepath: "voice/test")
+
+ expect(result[:ok]).to eq(true)
+ expect(stub).to have_been_requested.once
+ end
+
+ it "refuses to start if recording credentials were cleared after configuring the bucket" do
+ configure_recording_s3
+ SiteSetting.voice_livekit_recording_s3_secret_access_key = ""
+ stub = twirp_stub("StartRoomCompositeEgress")
+
+ result = described_class.start_room_composite(room, filepath: "voice/test")
+
+ expect(result).to eq(
+ ok: false,
+ error: I18n.t("site_settings.errors.voice_livekit_recording_s3_requires_credentials"),
+ )
+ expect(stub).not_to have_been_requested
+ end
+
+ it "refuses to send recording credentials over HTTP after a URL change" do
+ configure_recording_s3
+ SiteSetting.voice_livekit_url = "ws://livekit.example.com"
+ stub =
+ stub_request(
+ :post,
+ "http://livekit.example.com/twirp/livekit.Egress/StartRoomCompositeEgress",
+ )
+
+ result = described_class.start_room_composite(room, filepath: "voice/test")
+
+ expect(result).to eq(
+ ok: false,
+ error: I18n.t("site_settings.errors.voice_livekit_recording_s3_requires_wss"),
+ )
+ expect(stub).not_to have_been_requested
+ end
+
+ it "redacts recording credentials echoed in upstream errors" do
+ configure_recording_s3
+ credentials = [
+ SiteSetting.voice_livekit_recording_s3_access_key_id,
+ SiteSetting.voice_livekit_recording_s3_secret_access_key,
+ ]
+ twirp_stub("StartRoomCompositeEgress").to_return(status: 400, body: credentials.join(" "))
+
+ logs =
+ track_log_messages do
+ result = described_class.start_room_composite(room, filepath: "voice/test")
+ expect(result).to eq(ok: false, error: "HTTP 400")
+ end
+
+ expect(logs.warnings.join).to include("[FILTERED]")
+ credentials.each { |credential| expect(logs.warnings.join).not_to include(credential) }
+ end
+
it "POSTs the room name and file output with a roomRecord-granted token" do
SiteSetting.voice_video_enabled = false
stub = twirp_stub("StartRoomCompositeEgress").to_return(body: { egressId: "EG_1" }.to_json)
diff --git a/plugins/voice/spec/requests/voice/admin_recordings_controller_spec.rb b/plugins/voice/spec/requests/voice/admin_recordings_controller_spec.rb
index db0a783dffc..4c237d408d1 100644
--- a/plugins/voice/spec/requests/voice/admin_recordings_controller_spec.rb
+++ b/plugins/voice/spec/requests/voice/admin_recordings_controller_spec.rb
@@ -60,6 +60,8 @@ RSpec.describe Voice::AdminRecordingsController do
expect(response.status).to eq(200)
payload = response.parsed_body
expect(payload["has_more"]).to eq(false)
+ expect(payload["last_webhook_at"]).to be_nil
+ expect(payload["webhook_url"]).to eq("#{Discourse.base_url}/voice/livekit/webhook")
expect(payload["recordings"].map { |row| row["egress_id"] }).to eq(%w[EG_2 EG_1])
completed = payload["recordings"].last
@@ -70,6 +72,16 @@ RSpec.describe Voice::AdminRecordingsController do
expect(completed["duration_ms"]).to eq(65_000)
end
+ it "reports received webhooks so the setup note can be hidden" do
+ freeze_time
+ Voice::Livekit.touch_last_webhook!
+ sign_in(admin)
+
+ get "/admin/plugins/voice/recordings.json"
+
+ expect(Time.iso8601(response.parsed_body["last_webhook_at"]).to_i).to eq(Time.current.to_i)
+ end
+
it "paginates past the page size" do
stub_const(Voice::AdminRecordingsController, "PAGE_SIZE", 1) do
sign_in(admin)
diff --git a/plugins/voice/spec/validators/voice_livekit_recording_s3_bucket_validator_spec.rb b/plugins/voice/spec/validators/voice_livekit_recording_s3_bucket_validator_spec.rb
new file mode 100644
index 00000000000..bf4f5bac53b
--- /dev/null
+++ b/plugins/voice/spec/validators/voice_livekit_recording_s3_bucket_validator_spec.rb
@@ -0,0 +1,69 @@
+# frozen_string_literal: true
+
+RSpec.describe VoiceLivekitRecordingS3BucketValidator do
+ subject(:validator) { described_class.new }
+
+ before do
+ SiteSetting.voice_livekit_url = "wss://livekit.example.com"
+ SiteSetting.voice_livekit_recording_s3_access_key_id = "recording-access-key"
+ SiteSetting.voice_livekit_recording_s3_secret_access_key = "recording-secret-key"
+ end
+
+ it "accepts an empty bucket for self-hosted storage" do
+ SiteSetting.voice_livekit_recording_s3_secret_access_key = ""
+
+ expect(validator.valid_value?("")).to eq(true)
+ end
+
+ it "accepts a bucket when the recording credentials and region are configured" do
+ expect(validator.valid_value?("voice-recordings")).to eq(true)
+ end
+
+ it "validates the configured bucket name regex when saving the setting" do
+ ["voice-recordings/folder", "Voice-recordings", "ab", "a" * 64].each do |bucket|
+ expect { SiteSetting.voice_livekit_recording_s3_bucket = bucket }.to raise_error(
+ Discourse::InvalidParameters,
+ "voice_livekit_recording_s3_bucket: #{I18n.t("site_settings.errors.regex_mismatch")}",
+ )
+ end
+
+ SiteSetting.voice_livekit_recording_s3_bucket = "voice-recordings"
+ expect(SiteSetting.voice_livekit_recording_s3_bucket).to eq("voice-recordings")
+
+ SiteSetting.voice_livekit_recording_s3_bucket = ""
+ expect(SiteSetting.voice_livekit_recording_s3_bucket).to eq("")
+ end
+
+ it "requires both recording credentials" do
+ SiteSetting.voice_livekit_recording_s3_access_key_id = ""
+ expect(validator.valid_value?("voice-recordings")).to eq(false)
+
+ SiteSetting.voice_livekit_recording_s3_access_key_id = "recording-access-key"
+ SiteSetting.voice_livekit_recording_s3_secret_access_key = ""
+ expect(validator.valid_value?("voice-recordings")).to eq(false)
+ expect(validator.error_message).to eq(
+ I18n.t("site_settings.errors.voice_livekit_recording_s3_requires_credentials"),
+ )
+ end
+
+ it "requires a region unless a custom endpoint is configured" do
+ SiteSetting.voice_livekit_recording_s3_region = ""
+
+ expect(validator.valid_value?("voice-recordings")).to eq(false)
+ expect(validator.error_message).to eq(
+ I18n.t("site_settings.errors.voice_livekit_recording_s3_requires_region"),
+ )
+
+ SiteSetting.voice_livekit_recording_s3_endpoint = "https://storage.example.com"
+ expect(validator.valid_value?("voice-recordings")).to eq(true)
+ end
+
+ it "requires an encrypted connection to LiveKit" do
+ SiteSetting.voice_livekit_url = "ws://livekit.example.com"
+
+ expect(validator.valid_value?("voice-recordings")).to eq(false)
+ expect(validator.error_message).to eq(
+ I18n.t("site_settings.errors.voice_livekit_recording_s3_requires_wss"),
+ )
+ end
+end