[MM-36747] Spellchecker custom urls (cherrypick to TS) (#1669)

* [MM-36747] Allow users to specify spellchecker url for downloading dictionaries

* fix settings keys

Co-authored-by: = <=>
This commit is contained in:
Guillermo Vayá
2021-07-26 15:28:49 +02:00
committed by GitHub
parent f5ca0f9ef5
commit d77c823bd5
5 changed files with 129 additions and 10 deletions

View File

@@ -88,6 +88,7 @@ const configDataSchemaV2 = Joi.object<ConfigV2>({
enableHardwareAcceleration: Joi.boolean().default(true),
autostart: Joi.boolean().default(true),
spellCheckerLocale: Joi.string().regex(/^[a-z]{2}-[A-Z]{2}$/).default('en-US'),
spellCheckerURL: Joi.string().allow(null),
darkMode: Joi.boolean().default(false),
downloadLocation: Joi.string(),
});
@@ -117,6 +118,7 @@ const configDataSchemaV3 = Joi.object<ConfigV3>({
enableHardwareAcceleration: Joi.boolean().default(true),
autostart: Joi.boolean().default(true),
spellCheckerLocale: Joi.string().regex(/^[a-z]{2}-[A-Z]{2}$/).default('en-US'),
spellCheckerURL: Joi.string().allow(null),
darkMode: Joi.boolean().default(false),
downloadLocation: Joi.string(),
});
@@ -208,6 +210,10 @@ export function validateV2ConfigData(data: ConfigV2) {
// replace original teams
data.teams = teams;
}
if (data.spellCheckerURL && !urlUtils.isValidURL(data.spellCheckerURL)) {
log.error('Invalid download location for spellchecker dictionary, removing from config');
delete data.spellCheckerURL;
}
return validateAgainstSchema(data, configDataSchemaV2);
}
@@ -227,6 +233,10 @@ export function validateV3ConfigData(data: ConfigV3) {
// replace original teams
data.teams = teams;
}
if (data.spellCheckerURL && !urlUtils.isValidURL(data.spellCheckerURL)) {
log.error('Invalid download location for spellchecker dictionary, removing from config');
delete data.spellCheckerURL;
}
return validateAgainstSchema(data, configDataSchemaV3);
}