- Implemented German and English localization for password reset functionality. - Added WebSocket URL resolution logic in chat services to support various environments and configurations. - Created centralized chat configuration for event keys and payload mappings. - Developed RoomsView component for admin chat room management, including create, edit, and delete functionalities.
30 lines
1008 B
JavaScript
30 lines
1008 B
JavaScript
import ContactService from '../services/ContactService.js';
|
|
import Joi from 'joi';
|
|
|
|
class ContactController {
|
|
constructor() {
|
|
this.addContactMessage = this.addContactMessage.bind(this);
|
|
}
|
|
|
|
async addContactMessage(req, res) {
|
|
const schema = Joi.object({
|
|
email: Joi.string().email().required(),
|
|
name: Joi.string().min(1).max(255).required(),
|
|
message: Joi.string().min(1).max(2000).required(),
|
|
acceptDataSave: Joi.boolean().required()
|
|
});
|
|
const { error, value } = schema.validate(req.body);
|
|
if (error) {
|
|
return res.status(400).json({ error: error.details[0].message });
|
|
}
|
|
try {
|
|
await ContactService.addContactMessage(value.email, value.name, value.message, value.acceptDataSave);
|
|
res.status(200).json({ status: 'ok' });
|
|
} catch (error) {
|
|
res.status(409).json({ error: error.message });
|
|
}
|
|
}
|
|
}
|
|
|
|
export default ContactController;
|