Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: transcriber settings precedence #518

Merged
merged 5 commits into from
Feb 13, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 28 additions & 9 deletions src/main/java/org/jitsi/jigasi/TranscriptionGateway.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,22 @@ private String getCustomTranscriptionServiceClass(String tenant)
REMOTE_TRANSCRIPTION_CONFIG_URL,
null);

if (remoteTranscriptionConfigUrl != null)
if (remoteTranscriptionConfigUrl != null && tenant != null)
{
String transcriberClass = null;
String tsConfigUrl = remoteTranscriptionConfigUrl + "/" + tenant;
if (logger.isDebugEnabled())
{
logger.debug("Retrieving transcriber from remote URL " + tsConfigUrl);
}

try
{
URL url = new URL(remoteTranscriptionConfigUrl + "/" + tenant);
URL url = new URL(tsConfigUrl);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Content-Type", "application/json");
conn.setConnectTimeout(3000);
int responseCode = conn.getResponseCode();
if (responseCode == 200)
{
Expand All @@ -133,24 +140,36 @@ private String getCustomTranscriptionServiceClass(String tenant)
}
JSONObject obj = new JSONObject(responseBody.toString());
transcriberClass = obj.getString("transcriber");
if (logger.isDebugEnabled())
{
logger.debug("Using " + transcriberClass + " as the transcriber class.");
}
logger.info("Using " + transcriberClass + " as the transcriber class.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, is this duplicated with the print bellow.

conn.disconnect();
return transcriberClass;
}
else
{
logger.warn("Could not retrieve transcriber from remote URL. Response code: " + responseCode);
}
conn.disconnect();
return transcriberClass;
}
catch (Exception ex)
{
logger.error("Could not retrieve transcriber from remote URL." + ex);
}
}

return JigasiBundleActivator.getConfigurationService()
logger.info("Attempting to retrieve transcriber from local configuration.");
String customTranscriptionServiceClass
= JigasiBundleActivator.getConfigurationService()
.getString(
CUSTOM_TRANSCRIPTION_SERVICE_PROP,
null);
if (customTranscriptionServiceClass != null)
{
logger.info("Using " + customTranscriptionServiceClass + " as the transcriber class.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe leave only the print if there is a tenant enabling non default transcription.
And please add the callContext to the log as the rest of the code.

}
else
{
logger.info("No custom transcriber class found, falling back to default.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not need this log.

}
return customTranscriptionServiceClass;
}

@Override
Expand Down
Loading