Skip to content

Commit

Permalink
[MM-57483] Add job config validation (#667)
Browse files Browse the repository at this point in the history
* Add job config validation

* Update calls-offloader

* go mod tidy
  • Loading branch information
streamer45 committed Mar 27, 2024
1 parent 2eb996f commit d7dd8ca
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/Masterminds/semver v1.5.0
github.com/gorilla/websocket v1.5.1
github.com/jmoiron/sqlx v1.3.5
github.com/mattermost/calls-offloader v0.6.0
github.com/mattermost/calls-offloader v0.8.0
github.com/mattermost/calls-recorder v0.6.4
github.com/mattermost/calls-transcriber v0.1.8
github.com/mattermost/logr/v2 v2.0.21
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mattermost/calls-offloader v0.6.0 h1:0DlkX9gR9Eiw7Dv3Z+W7DuBzOgMD9aBEnGkAVIOKS74=
github.com/mattermost/calls-offloader v0.6.0/go.mod h1:/xyDQiBZ0XNKNC/ALGp7pkGNApfC6v94CD7tPWGcFvM=
github.com/mattermost/calls-offloader v0.8.0 h1:XCAAMR11V/wSlLIJl1DuUQ8PGT8RRwPFbtM4YGZvfLw=
github.com/mattermost/calls-offloader v0.8.0/go.mod h1:xmVZZfWM9KfTcOp2Zb8XdFRin4JBNcQqg+vcwtTmdPc=
github.com/mattermost/calls-recorder v0.6.4 h1:LCS7a8Q4eGUbZmBkgARTwNLOUyJyxkDfrIpx/Gv26Uo=
github.com/mattermost/calls-recorder v0.6.4/go.mod h1:v/52mE+wIXGJE7ZflpAkoyGd56hbVgC9ZuEBBaRd8KU=
github.com/mattermost/calls-transcriber v0.1.8 h1:vwmxHxRHuuuo4wyf+ZfvDj5n2TNpebQO43Qy6u+BAQY=
Expand Down
9 changes: 9 additions & 0 deletions server/job_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,16 @@ func (s *jobService) RunJob(jobType job.Type, callID, postID, jobID, authToken s
baseRecorderCfg.RecordingID = jobID
baseRecorderCfg.AuthToken = authToken

if err := baseRecorderCfg.IsValid(); err != nil {
return "", fmt.Errorf("recorder config is not valid: %w", err)
}

jobCfg.Runner = recorderJobRunner
jobCfg.MaxDurationSec = int64(*cfg.MaxRecordingDuration * 60)
jobCfg.InputData = baseRecorderCfg.ToMap()
case job.TypeTranscribing:
var transcriberConfig transcriber.CallTranscriberConfig
transcriberConfig.SetDefaults()
transcriberConfig.SiteURL = siteURL
if siteURLOverride := os.Getenv("MM_CALLS_TRANSCRIBER_SITE_URL"); siteURLOverride != "" {
s.ctx.LogInfo("using SiteURL override for transcriber job", "siteURL", siteURL, "siteURLOverride", siteURLOverride)
Expand All @@ -329,6 +334,10 @@ func (s *jobService) RunJob(jobType job.Type, callID, postID, jobID, authToken s
transcriberConfig.NumThreads, _ = strconv.Atoi(val)
}

if err := transcriberConfig.IsValid(); err != nil {
return "", fmt.Errorf("transcriber config is not valid: %w", err)
}

jobCfg.Runner = transcriberJobRunner
// Setting the max duration to double the value of the recording's setting as
// the transcribing process will extend well after the call has ended.
Expand Down

0 comments on commit d7dd8ca

Please sign in to comment.