mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-11-07 04:42:54 -05:00
fix email/sms/messaging customised templates #6994
Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
18
meshsms.js
18
meshsms.js
@@ -169,6 +169,7 @@ module.exports.CreateMeshSMS = function (parent) {
|
||||
function getTemplate(templateNumber, domain, lang) {
|
||||
parent.debug('email', 'Getting SMS template #' + templateNumber + ', lang: ' + lang);
|
||||
if (Array.isArray(lang)) { lang = lang[0]; } // TODO: For now, we only use the first language given.
|
||||
if (lang != null) { lang = lang.split('-')[0]; } // Take the first part of the language, "xx-xx"
|
||||
|
||||
var r = {}, emailsPath = null;
|
||||
if ((domain != null) && (domain.webemailspath != null)) { emailsPath = domain.webemailspath; }
|
||||
@@ -194,6 +195,23 @@ module.exports.CreateMeshSMS = function (parent) {
|
||||
}
|
||||
}
|
||||
|
||||
// If no english sms and a non-english language is requested, try to get the default translated sms
|
||||
if (txtfile == null && (lang != null) && (lang != 'en')) {
|
||||
var translationsPath = obj.parent.path.join(obj.parent.webEmailsPath, 'translations');
|
||||
var translationsPathTxt = obj.parent.path.join(obj.parent.webEmailsPath, 'translations', 'sms-messages_' + lang + '.txt');
|
||||
if (obj.parent.fs.existsSync(translationsPath) && obj.parent.fs.existsSync(translationsPathTxt)) {
|
||||
txtfile = obj.parent.fs.readFileSync(translationsPathTxt).toString();
|
||||
}
|
||||
}
|
||||
|
||||
// If no default translated sms, try to get the default english sms
|
||||
if (txtfile == null) {
|
||||
var pathTxt = obj.parent.path.join(obj.parent.webEmailsPath, 'sms-messages.txt');
|
||||
if (obj.parent.fs.existsSync(pathTxt)) {
|
||||
txtfile = obj.parent.fs.readFileSync(pathTxt).toString();
|
||||
}
|
||||
}
|
||||
|
||||
// No email templates
|
||||
if (txtfile == null) { return null; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user