Skip to content

Commit b911ec3

Browse files
committed
fix(language): Added language selection with ?locale=et query argument
1 parent 3571b41 commit b911ec3

File tree

8 files changed

+891
-939
lines changed

8 files changed

+891
-939
lines changed

lib/api-routes/chat-routes.js

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ const { Account } = require('../account');
55
const getSecret = require('../get-secret');
66
const Boom = require('@hapi/boom');
77
const Joi = require('joi');
8-
const { failAction, getBoolean, validationHelper } = require('../tools');
8+
const { failAction, getBoolean } = require('../tools');
99
const settings = require('../settings');
1010
const util = require('util');
11-
const { joiLocales } = require('../translations');
1211

1312
const LOG_VERBOSE = getBoolean(process.env.EE_OPENAPI_VERBOSE);
1413

@@ -422,18 +421,15 @@ async function init(args) {
422421
account: accountIdSchema.required()
423422
}),
424423

425-
payload: validationHelper(
426-
joiLocales,
427-
Joi.object({
428-
question: Joi.string()
429-
.trim()
430-
.max(1024)
431-
.example('When did Jason last message me?')
432-
.description('Chat message to use')
433-
.label('ChatMessage')
434-
.required()
435-
}).label('RequestChat')
436-
)
424+
payload: Joi.object({
425+
question: Joi.string()
426+
.trim()
427+
.max(1024)
428+
.example('When did Jason last message me?')
429+
.description('Chat message to use')
430+
.label('ChatMessage')
431+
.required()
432+
}).label('RequestChat')
437433
},
438434

439435
response: {
@@ -495,6 +491,7 @@ async function init(args) {
495491
}
496492
},
497493
options: {
494+
tags: ['test'],
498495
validate: {
499496
options: {
500497
stripUnknown: true,
@@ -504,19 +501,16 @@ async function init(args) {
504501

505502
failAction,
506503

507-
payload: validationHelper(
508-
joiLocales,
509-
Joi.object({
510-
account: accountIdSchema.required(),
511-
question: Joi.string()
512-
.trim()
513-
.max(1024)
514-
.example('When did Jason last message me?')
515-
.description('Chat message to use')
516-
.label('ChatMessage')
517-
.required()
518-
})
519-
)
504+
payload: Joi.object({
505+
account: accountIdSchema.required(),
506+
question: Joi.string()
507+
.trim()
508+
.max(1024)
509+
.example('When did Jason last message me?')
510+
.description('Chat message to use')
511+
.label('ChatMessage')
512+
.required()
513+
})
520514
}
521515
}
522516
});

lib/api-routes/template-routes.js

Lines changed: 44 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ const getSecret = require('../get-secret');
66
const { templates } = require('../templates');
77
const Boom = require('@hapi/boom');
88
const Joi = require('joi');
9-
const { failAction, validationHelper } = require('../tools');
10-
const { joiLocales } = require('../translations');
9+
const { failAction } = require('../tools');
1110

1211
const { templateSchemas, accountIdSchema } = require('../schemas');
1312

@@ -77,36 +76,33 @@ async function init(args) {
7776
},
7877
failAction,
7978

80-
payload: validationHelper(
81-
joiLocales,
82-
Joi.object({
83-
account: Joi.string()
84-
.empty('')
85-
.trim()
86-
.allow(null)
87-
.max(256)
88-
.example('example')
89-
.description('Account ID. Use `null` for public templates.')
90-
.required(),
91-
92-
name: Joi.string().max(256).example('Transaction receipt').description('Name of the template').label('TemplateName').required(),
93-
description: Joi.string()
94-
.allow('')
95-
.max(1024)
96-
.example('Something about the template')
97-
.description('Optional description of the template')
98-
.label('TemplateDescription'),
99-
format: Joi.string().valid('html', 'markdown').default('html').description('Markup language for HTML ("html" or "markdown")'),
100-
content: Joi.object({
101-
subject: templateSchemas.subject,
102-
text: templateSchemas.text,
103-
html: templateSchemas.html,
104-
previewText: templateSchemas.previewText
105-
})
106-
.required()
107-
.label('CreateTemplateContent')
108-
}).label('CreateTemplate')
109-
)
79+
payload: Joi.object({
80+
account: Joi.string()
81+
.empty('')
82+
.trim()
83+
.allow(null)
84+
.max(256)
85+
.example('example')
86+
.description('Account ID. Use `null` for public templates.')
87+
.required(),
88+
89+
name: Joi.string().max(256).example('Transaction receipt').description('Name of the template').label('TemplateName').required(),
90+
description: Joi.string()
91+
.allow('')
92+
.max(1024)
93+
.example('Something about the template')
94+
.description('Optional description of the template')
95+
.label('TemplateDescription'),
96+
format: Joi.string().valid('html', 'markdown').default('html').description('Markup language for HTML ("html" or "markdown")'),
97+
content: Joi.object({
98+
subject: templateSchemas.subject,
99+
text: templateSchemas.text,
100+
html: templateSchemas.html,
101+
previewText: templateSchemas.previewText
102+
})
103+
.required()
104+
.label('CreateTemplateContent')
105+
}).label('CreateTemplate')
110106
},
111107

112108
response: {
@@ -172,25 +168,22 @@ async function init(args) {
172168
template: Joi.string().max(256).required().example('example').description('Template ID')
173169
}).label('GetTemplateRequest'),
174170

175-
payload: validationHelper(
176-
joiLocales,
177-
Joi.object({
178-
name: Joi.string().empty('').max(256).example('Transaction receipt').description('Name of the template').label('TemplateName'),
179-
description: Joi.string()
180-
.allow('')
181-
.max(1024)
182-
.example('Something about the template')
183-
.description('Optional description of the template')
184-
.label('TemplateDescription'),
185-
format: Joi.string().empty('').valid('html', 'markdown').default('html').description('Markup language for HTML ("html" or "markdown")'),
186-
content: Joi.object({
187-
subject: templateSchemas.subject,
188-
text: templateSchemas.text,
189-
html: templateSchemas.html,
190-
previewText: templateSchemas.previewText
191-
}).label('UpdateTemplateContent')
192-
}).label('UpdateTemplate')
193-
)
171+
payload: Joi.object({
172+
name: Joi.string().empty('').max(256).example('Transaction receipt').description('Name of the template').label('TemplateName'),
173+
description: Joi.string()
174+
.allow('')
175+
.max(1024)
176+
.example('Something about the template')
177+
.description('Optional description of the template')
178+
.label('TemplateDescription'),
179+
format: Joi.string().empty('').valid('html', 'markdown').default('html').description('Markup language for HTML ("html" or "markdown")'),
180+
content: Joi.object({
181+
subject: templateSchemas.subject,
182+
text: templateSchemas.text,
183+
html: templateSchemas.html,
184+
previewText: templateSchemas.previewText
185+
}).label('UpdateTemplateContent')
186+
}).label('UpdateTemplate')
194187
},
195188

196189
response: {

0 commit comments

Comments
 (0)