From 17e10b200a3d36be96ee2ade11062fb7a2f9c56d Mon Sep 17 00:00:00 2001 From: streamer45 Date: Wed, 28 Jun 2023 16:41:23 -0600 Subject: [PATCH 1/3] Add RecordingID to RecorderConfig --- build/entrypoint.sh | 1 + build/pkgs_list | 6 +- cmd/recorder/config/config.go | 19 ++++- cmd/recorder/config/config_test.go | 113 ++++++++++++++++++----------- cmd/recorder/recorder.go | 4 +- cmd/recorder/recorder_test.go | 9 ++- cmd/recorder/upload_test.go | 9 ++- 7 files changed, 100 insertions(+), 61 deletions(-) diff --git a/build/entrypoint.sh b/build/entrypoint.sh index 85cc1e7..b6dbbb2 100755 --- a/build/entrypoint.sh +++ b/build/entrypoint.sh @@ -68,6 +68,7 @@ runuser -l $RECORDER_USER -c \ AUTH_TOKEN=$AUTH_TOKEN \ CALL_ID=$CALL_ID \ THREAD_ID=$THREAD_ID \ + RECORDING_ID=$RECORDING_ID \ WIDTH=${WIDTH:-0} \ HEIGHT=${HEIGHT:-0} \ VIDEO_RATE=${VIDEO_RATE:-0} \ diff --git a/build/pkgs_list b/build/pkgs_list index ef693c8..0198da3 100644 --- a/build/pkgs_list +++ b/build/pkgs_list @@ -1,7 +1,7 @@ ca-certificates=20230311 -chromium=114.0.5735.133-1 -chromium-driver=114.0.5735.133-1 -chromium-sandbox=114.0.5735.133-1 +chromium=114.0.5735.198-1 +chromium-driver=114.0.5735.198-1 +chromium-sandbox=114.0.5735.198-1 ffmpeg=7:5.1.3-1 fonts-recommended=1 pulseaudio=16.1+dfsg1-2+b1 diff --git a/cmd/recorder/config/config.go b/cmd/recorder/config/config.go index 83717e3..ff92c19 100644 --- a/cmd/recorder/config/config.go +++ b/cmd/recorder/config/config.go @@ -53,10 +53,11 @@ const ( type RecorderConfig struct { // input config - SiteURL string - CallID string - ThreadID string - AuthToken string + SiteURL string + CallID string + ThreadID string + RecordingID string + AuthToken string // output config Width int @@ -106,6 +107,12 @@ func (cfg RecorderConfig) IsValid() error { return fmt.Errorf("ThreadID parsing failed") } + if cfg.RecordingID == "" { + return fmt.Errorf("RecordingID cannot be empty") + } else if !idRE.MatchString(cfg.RecordingID) { + return fmt.Errorf("RecordingID parsing failed") + } + if cfg.AuthToken == "" { return fmt.Errorf("AuthToken cannot be empty") } else if !idRE.MatchString(cfg.AuthToken) { @@ -172,6 +179,7 @@ func (cfg RecorderConfig) ToEnv() []string { fmt.Sprintf("SITE_URL=%s", cfg.SiteURL), fmt.Sprintf("CALL_ID=%s", cfg.CallID), fmt.Sprintf("THREAD_ID=%s", cfg.ThreadID), + fmt.Sprintf("RECORDING_ID=%s", cfg.RecordingID), fmt.Sprintf("AUTH_TOKEN=%s", cfg.AuthToken), fmt.Sprintf("WIDTH=%d", cfg.Width), fmt.Sprintf("HEIGHT=%d", cfg.Height), @@ -188,6 +196,7 @@ func (cfg RecorderConfig) ToMap() map[string]any { "site_url": cfg.SiteURL, "call_id": cfg.CallID, "thread_id": cfg.ThreadID, + "recording_id": cfg.RecordingID, "auth_token": cfg.AuthToken, "width": cfg.Width, "height": cfg.Height, @@ -203,6 +212,7 @@ func (cfg *RecorderConfig) FromMap(m map[string]any) *RecorderConfig { cfg.SiteURL, _ = m["site_url"].(string) cfg.CallID, _ = m["call_id"].(string) cfg.ThreadID, _ = m["thread_id"].(string) + cfg.RecordingID, _ = m["recording_id"].(string) cfg.AuthToken, _ = m["auth_token"].(string) if width, ok := m["width"].(float64); ok { cfg.Width = int(width) @@ -247,6 +257,7 @@ func LoadFromEnv() (RecorderConfig, error) { cfg.SiteURL = strings.TrimSuffix(os.Getenv("SITE_URL"), "/") cfg.CallID = os.Getenv("CALL_ID") cfg.ThreadID = os.Getenv("THREAD_ID") + cfg.RecordingID = os.Getenv("RECORDING_ID") cfg.AuthToken = os.Getenv("AUTH_TOKEN") if val := os.Getenv("WIDTH"); val != "" { diff --git a/cmd/recorder/config/config_test.go b/cmd/recorder/config/config_test.go index c5865ac..19bccf7 100644 --- a/cmd/recorder/config/config_test.go +++ b/cmd/recorder/config/config_test.go @@ -41,72 +41,88 @@ func TestConfigIsValid(t *testing.T) { }, expectedError: "ThreadID cannot be empty", }, + { + name: "missing RecordingID", + cfg: RecorderConfig{ + SiteURL: "http://localhost:8065", + CallID: "8w8jorhr7j83uqr6y1st894hqe", + ThreadID: "udzdsg7dwidbzcidx5khrf8nee", + AuthToken: "qj75unbsef83ik9p7ueypb6iyw", + }, + expectedError: "RecordingID cannot be empty", + }, { name: "missing AuthToken", cfg: RecorderConfig{ - SiteURL: "http://localhost:8065", - CallID: "8w8jorhr7j83uqr6y1st894hqe", - ThreadID: "udzdsg7dwidbzcidx5khrf8nee", + SiteURL: "http://localhost:8065", + CallID: "8w8jorhr7j83uqr6y1st894hqe", + ThreadID: "udzdsg7dwidbzcidx5khrf8nee", + RecordingID: "67t5u6cmtfbb7jug739d43xa9e", }, expectedError: "AuthToken cannot be empty", }, { name: "invalid Width", cfg: RecorderConfig{ - SiteURL: "http://localhost:8065", - CallID: "8w8jorhr7j83uqr6y1st894hqe", - ThreadID: "udzdsg7dwidbzcidx5khrf8nee", - AuthToken: "qj75unbsef83ik9p7ueypb6iyw", + SiteURL: "http://localhost:8065", + CallID: "8w8jorhr7j83uqr6y1st894hqe", + ThreadID: "udzdsg7dwidbzcidx5khrf8nee", + RecordingID: "67t5u6cmtfbb7jug739d43xa9e", + AuthToken: "qj75unbsef83ik9p7ueypb6iyw", }, expectedError: "Width value is not valid", }, { name: "invalid Height", cfg: RecorderConfig{ - SiteURL: "http://localhost:8065", - CallID: "8w8jorhr7j83uqr6y1st894hqe", - ThreadID: "udzdsg7dwidbzcidx5khrf8nee", - AuthToken: "qj75unbsef83ik9p7ueypb6iyw", - Width: 1280, + SiteURL: "http://localhost:8065", + CallID: "8w8jorhr7j83uqr6y1st894hqe", + ThreadID: "udzdsg7dwidbzcidx5khrf8nee", + RecordingID: "67t5u6cmtfbb7jug739d43xa9e", + AuthToken: "qj75unbsef83ik9p7ueypb6iyw", + Width: 1280, }, expectedError: "Height value is not valid", }, { name: "invalid VideoRate", cfg: RecorderConfig{ - SiteURL: "http://localhost:8065", - CallID: "8w8jorhr7j83uqr6y1st894hqe", - ThreadID: "udzdsg7dwidbzcidx5khrf8nee", - AuthToken: "qj75unbsef83ik9p7ueypb6iyw", - Width: 1280, - Height: 720, + SiteURL: "http://localhost:8065", + CallID: "8w8jorhr7j83uqr6y1st894hqe", + ThreadID: "udzdsg7dwidbzcidx5khrf8nee", + RecordingID: "67t5u6cmtfbb7jug739d43xa9e", + AuthToken: "qj75unbsef83ik9p7ueypb6iyw", + Width: 1280, + Height: 720, }, expectedError: "VideoRate value is not valid", }, { name: "invalid AudioRate", cfg: RecorderConfig{ - SiteURL: "http://localhost:8065", - CallID: "8w8jorhr7j83uqr6y1st894hqe", - ThreadID: "udzdsg7dwidbzcidx5khrf8nee", - AuthToken: "qj75unbsef83ik9p7ueypb6iyw", - Width: 1280, - Height: 720, - VideoRate: 1000, + SiteURL: "http://localhost:8065", + CallID: "8w8jorhr7j83uqr6y1st894hqe", + ThreadID: "udzdsg7dwidbzcidx5khrf8nee", + RecordingID: "67t5u6cmtfbb7jug739d43xa9e", + AuthToken: "qj75unbsef83ik9p7ueypb6iyw", + Width: 1280, + Height: 720, + VideoRate: 1000, }, expectedError: "AudioRate value is not valid", }, { name: "invalid FrameRate", cfg: RecorderConfig{ - SiteURL: "http://localhost:8065", - CallID: "8w8jorhr7j83uqr6y1st894hqe", - ThreadID: "udzdsg7dwidbzcidx5khrf8nee", - AuthToken: "qj75unbsef83ik9p7ueypb6iyw", - Width: 1280, - Height: 720, - VideoRate: 1000, - AudioRate: 64, + SiteURL: "http://localhost:8065", + CallID: "8w8jorhr7j83uqr6y1st894hqe", + ThreadID: "udzdsg7dwidbzcidx5khrf8nee", + RecordingID: "67t5u6cmtfbb7jug739d43xa9e", + AuthToken: "qj75unbsef83ik9p7ueypb6iyw", + Width: 1280, + Height: 720, + VideoRate: 1000, + AudioRate: 64, }, expectedError: "FrameRate value is not valid", }, @@ -116,6 +132,7 @@ func TestConfigIsValid(t *testing.T) { SiteURL: "http://localhost:8065", CallID: "8w8jorhr7j83uqr6y1st894hqe", ThreadID: "udzdsg7dwidbzcidx5khrf8nee", + RecordingID: "67t5u6cmtfbb7jug739d43xa9e", AuthToken: "qj75unbsef83ik9p7ueypb6iyw", Width: 1280, Height: 720, @@ -129,15 +146,16 @@ func TestConfigIsValid(t *testing.T) { { name: "invalid format", cfg: RecorderConfig{ - SiteURL: "http://localhost:8065", - CallID: "8w8jorhr7j83uqr6y1st894hqe", - ThreadID: "udzdsg7dwidbzcidx5khrf8nee", - AuthToken: "qj75unbsef83ik9p7ueypb6iyw", - Width: 1280, - Height: 720, - VideoRate: 1000, - AudioRate: 64, - FrameRate: 30, + SiteURL: "http://localhost:8065", + CallID: "8w8jorhr7j83uqr6y1st894hqe", + ThreadID: "udzdsg7dwidbzcidx5khrf8nee", + RecordingID: "67t5u6cmtfbb7jug739d43xa9e", + AuthToken: "qj75unbsef83ik9p7ueypb6iyw", + Width: 1280, + Height: 720, + VideoRate: 1000, + AudioRate: 64, + FrameRate: 30, }, expectedError: "OutputFormat value is not valid", }, @@ -147,6 +165,7 @@ func TestConfigIsValid(t *testing.T) { SiteURL: "http://localhost:8065", CallID: "8w8jorhr7j83uqr6y1st894hqe", ThreadID: "udzdsg7dwidbzcidx5khrf8nee", + RecordingID: "67t5u6cmtfbb7jug739d43xa9e", AuthToken: "qj75unbsef83ik9p7ueypb6iyw", Width: 1280, Height: 720, @@ -250,6 +269,8 @@ func TestLoadFromEnv(t *testing.T) { defer os.Unsetenv("CALL_ID") os.Setenv("THREAD_ID", "udzdsg7dwidbzcidx5khrf8nee") defer os.Unsetenv("THREAD_ID") + os.Setenv("RECORDING_ID", "67t5u6cmtfbb7jug739d43xa9e") + defer os.Unsetenv("RECORDING_ID") os.Setenv("AUTH_TOKEN", "qj75unbsef83ik9p7ueypb6iyw") defer os.Unsetenv("AUTH_TOKEN") os.Setenv("WIDTH", "1920") @@ -271,6 +292,7 @@ func TestLoadFromEnv(t *testing.T) { SiteURL: "http://localhost:8065", CallID: "8w8jorhr7j83uqr6y1st894hqe", ThreadID: "udzdsg7dwidbzcidx5khrf8nee", + RecordingID: "67t5u6cmtfbb7jug739d43xa9e", AuthToken: "qj75unbsef83ik9p7ueypb6iyw", Width: 1920, Height: 1080, @@ -286,13 +308,15 @@ func TestRecorderConfigToEnv(t *testing.T) { var cfg RecorderConfig cfg.SiteURL = "http://localhost:8065" cfg.CallID = "8w8jorhr7j83uqr6y1st894hqe" - cfg.AuthToken = "qj75unbsef83ik9p7ueypb6iyw" cfg.ThreadID = "udzdsg7dwidbzcidx5khrf8nee" + cfg.RecordingID = "67t5u6cmtfbb7jug739d43xa9e" + cfg.AuthToken = "qj75unbsef83ik9p7ueypb6iyw" cfg.SetDefaults() require.Equal(t, []string{ "SITE_URL=http://localhost:8065", "CALL_ID=8w8jorhr7j83uqr6y1st894hqe", "THREAD_ID=udzdsg7dwidbzcidx5khrf8nee", + "RECORDING_ID=67t5u6cmtfbb7jug739d43xa9e", "AUTH_TOKEN=qj75unbsef83ik9p7ueypb6iyw", "WIDTH=1920", "HEIGHT=1080", @@ -308,8 +332,9 @@ func TestRecorderConfigMap(t *testing.T) { var cfg RecorderConfig cfg.SiteURL = "http://localhost:8065" cfg.CallID = "8w8jorhr7j83uqr6y1st894hqe" - cfg.AuthToken = "qj75unbsef83ik9p7ueypb6iyw" cfg.ThreadID = "udzdsg7dwidbzcidx5khrf8nee" + cfg.RecordingID = "67t5u6cmtfbb7jug739d43xa9e" + cfg.AuthToken = "qj75unbsef83ik9p7ueypb6iyw" cfg.SetDefaults() t.Run("default config", func(t *testing.T) { diff --git a/cmd/recorder/recorder.go b/cmd/recorder/recorder.go index 379f08c..9869b8a 100644 --- a/cmd/recorder/recorder.go +++ b/cmd/recorder/recorder.go @@ -229,8 +229,8 @@ func (rec *Recorder) Start() error { return fmt.Errorf("failed to marshal data: %s", err) } - recURL := fmt.Sprintf("%s/plugins/%s/standalone/recording.html?call_id=%s#%s", - rec.cfg.SiteURL, pluginID, rec.cfg.CallID, base64.URLEncoding.EncodeToString(data)) + recURL := fmt.Sprintf("%s/plugins/%s/standalone/recording.html?call_id=%s&context_id=%s#%s", + rec.cfg.SiteURL, pluginID, rec.cfg.CallID, rec.cfg.RecordingID, base64.URLEncoding.EncodeToString(data)) go func() { if err := rec.runBrowser(recURL); err != nil { diff --git a/cmd/recorder/recorder_test.go b/cmd/recorder/recorder_test.go index 6f7a3d8..28c585f 100644 --- a/cmd/recorder/recorder_test.go +++ b/cmd/recorder/recorder_test.go @@ -17,10 +17,11 @@ func TestNewRecorder(t *testing.T) { t.Run("valid config", func(t *testing.T) { cfg := config.RecorderConfig{ - SiteURL: "http://localhost:8065", - CallID: "8w8jorhr7j83uqr6y1st894hqe", - ThreadID: "udzdsg7dwidbzcidx5khrf8nee", - AuthToken: "qj75unbsef83ik9p7ueypb6iyw", + SiteURL: "http://localhost:8065", + CallID: "8w8jorhr7j83uqr6y1st894hqe", + ThreadID: "udzdsg7dwidbzcidx5khrf8nee", + RecordingID: "67t5u6cmtfbb7jug739d43xa9e", + AuthToken: "qj75unbsef83ik9p7ueypb6iyw", } cfg.SetDefaults() rec, err := NewRecorder(cfg) diff --git a/cmd/recorder/upload_test.go b/cmd/recorder/upload_test.go index d1333c7..dc9e5a6 100644 --- a/cmd/recorder/upload_test.go +++ b/cmd/recorder/upload_test.go @@ -28,10 +28,11 @@ func TestUploadRecording(t *testing.T) { defer ts.Close() cfg := config.RecorderConfig{ - SiteURL: ts.URL, - CallID: "8w8jorhr7j83uqr6y1st894hqe", - ThreadID: "udzdsg7dwidbzcidx5khrf8nee", - AuthToken: "qj75unbsef83ik9p7ueypb6iyw", + SiteURL: ts.URL, + CallID: "8w8jorhr7j83uqr6y1st894hqe", + ThreadID: "udzdsg7dwidbzcidx5khrf8nee", + RecordingID: "67t5u6cmtfbb7jug739d43xa9e", + AuthToken: "qj75unbsef83ik9p7ueypb6iyw", } cfg.SetDefaults() rec, err := NewRecorder(cfg) From a60ee4ae680627fdefe17ce7ce71c3db146e0a57 Mon Sep 17 00:00:00 2001 From: streamer45 Date: Mon, 28 Aug 2023 10:23:16 -0600 Subject: [PATCH 2/3] ContextID --> JobID --- cmd/recorder/recorder.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/recorder/recorder.go b/cmd/recorder/recorder.go index 648984f..74921c6 100644 --- a/cmd/recorder/recorder.go +++ b/cmd/recorder/recorder.go @@ -253,7 +253,7 @@ func (rec *Recorder) Start() error { return fmt.Errorf("failed to marshal data: %s", err) } - recURL := fmt.Sprintf("%s/plugins/%s/standalone/recording.html?call_id=%s&context_id=%s#%s", + recURL := fmt.Sprintf("%s/plugins/%s/standalone/recording.html?call_id=%s&job_id=%s#%s", rec.cfg.SiteURL, pluginID, rec.cfg.CallID, rec.cfg.RecordingID, base64.URLEncoding.EncodeToString(data)) go func() { From 8d9dc42f3e27d37681cd77bd2d164d426dbd21ac Mon Sep 17 00:00:00 2001 From: streamer45 Date: Mon, 28 Aug 2023 10:23:42 -0600 Subject: [PATCH 3/3] Bump deps --- build/pkgs_list | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build/pkgs_list b/build/pkgs_list index 9669e0c..582bc19 100644 --- a/build/pkgs_list +++ b/build/pkgs_list @@ -1,8 +1,8 @@ ca-certificates=20230311 -chromium=115.0.5790.170-1 -chromium-driver=115.0.5790.170-1 -chromium-sandbox=115.0.5790.170-1 -ffmpeg=7:6.0-5 +chromium=116.0.5845.110-2 +chromium-driver=116.0.5845.110-2 +chromium-sandbox=116.0.5845.110-2 +ffmpeg=7:6.0-6 fonts-recommended=1 pulseaudio=16.1+dfsg1-2+b1 wget=1.21.3-1+b2