Add password reset localization and chat configuration
- 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.
This commit is contained in:
@@ -1,11 +1,19 @@
|
||||
import forumService from '../services/forumService.js';
|
||||
import Joi from 'joi';
|
||||
|
||||
const forumController = {
|
||||
async createForum(req, res) {
|
||||
const schema = Joi.object({
|
||||
name: Joi.string().min(1).max(255).required(),
|
||||
permissions: Joi.array().items(Joi.string().min(1).max(255)).required()
|
||||
});
|
||||
const { error, value } = schema.validate(req.body);
|
||||
if (error) {
|
||||
return res.status(400).json({ error: error.details[0].message });
|
||||
}
|
||||
try {
|
||||
const { userid: userId } = req.headers;
|
||||
const { name, permissions } = req.body;
|
||||
const forum = await forumService.createForum(userId, name, permissions);
|
||||
const forum = await forumService.createForum(userId, value.name, value.permissions);
|
||||
res.status(201).json(forum);
|
||||
} catch (error) {
|
||||
console.error('Error in createForum:', error);
|
||||
@@ -49,10 +57,18 @@ const forumController = {
|
||||
},
|
||||
|
||||
async createTopic(req, res) {
|
||||
const schema = Joi.object({
|
||||
forumId: Joi.number().integer().required(),
|
||||
title: Joi.string().min(1).max(255).required(),
|
||||
content: Joi.string().min(1).max(5000).required()
|
||||
});
|
||||
const { error, value } = schema.validate(req.body);
|
||||
if (error) {
|
||||
return res.status(400).json({ error: error.details[0].message });
|
||||
}
|
||||
try {
|
||||
const { userid: userId } = req.headers;
|
||||
const { forumId, title, content } = req.body;
|
||||
const result = await forumService.createTopic(userId, forumId, title, content);
|
||||
const result = await forumService.createTopic(userId, value.forumId, value.title, value.content);
|
||||
res.status(201).json(result);
|
||||
} catch (error) {
|
||||
console.error('Error in createTopic:', error);
|
||||
@@ -73,11 +89,17 @@ const forumController = {
|
||||
},
|
||||
|
||||
async addMessage(req, res) {
|
||||
const schema = Joi.object({
|
||||
content: Joi.string().min(1).max(5000).required()
|
||||
});
|
||||
const { error, value } = schema.validate(req.body);
|
||||
if (error) {
|
||||
return res.status(400).json({ error: error.details[0].message });
|
||||
}
|
||||
try {
|
||||
const { userid: userId } = req.headers;
|
||||
const { id: topicId } = req.params;
|
||||
const { content } = req.body;
|
||||
const result = await forumService.addMessage(userId, topicId, content);
|
||||
const result = await forumService.addMessage(userId, topicId, value.content);
|
||||
res.status(201).json(result);
|
||||
} catch (error) {
|
||||
console.error('Error in addMessage:', error);
|
||||
|
||||
Reference in New Issue
Block a user