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,4 +1,5 @@
|
||||
import settingsService from '../services/settingsService.js';
|
||||
import Joi from 'joi';
|
||||
|
||||
class SettingsController {
|
||||
async filterSettings(req, res) {
|
||||
@@ -13,9 +14,17 @@ class SettingsController {
|
||||
}
|
||||
|
||||
async updateSetting(req, res) {
|
||||
const { userid, settingId, value } = req.body;
|
||||
const schema = Joi.object({
|
||||
userid: Joi.string().required(),
|
||||
settingId: Joi.number().integer().required(),
|
||||
value: Joi.any().required()
|
||||
});
|
||||
const { error, value } = schema.validate(req.body);
|
||||
if (error) {
|
||||
return res.status(400).json({ error: error.details[0].message });
|
||||
}
|
||||
try {
|
||||
await settingsService.updateSetting(userid, settingId, value);
|
||||
await settingsService.updateSetting(value.userid, value.settingId, value.value);
|
||||
res.status(200).json({ message: 'Setting updated successfully' });
|
||||
} catch (error) {
|
||||
console.error('Error updating user setting:', error);
|
||||
@@ -68,8 +77,16 @@ class SettingsController {
|
||||
}
|
||||
|
||||
async setAccountSettings(req, res) {
|
||||
const schema = Joi.object({
|
||||
userId: Joi.string().required(),
|
||||
settings: Joi.object().required()
|
||||
});
|
||||
const { error, value } = schema.validate(req.body);
|
||||
if (error) {
|
||||
return res.status(400).json({ error: error.details[0].message });
|
||||
}
|
||||
try {
|
||||
await settingsService.setAccountSettings(req.body);
|
||||
await settingsService.setAccountSettings(value);
|
||||
res.status(200).json({ message: 'Account settings updated successfully' });
|
||||
} catch (error) {
|
||||
console.error('Error updating account settings:', error);
|
||||
@@ -100,10 +117,16 @@ class SettingsController {
|
||||
}
|
||||
|
||||
async addInterest(req, res) {
|
||||
const schema = Joi.object({
|
||||
name: 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 } = req.body;
|
||||
const interest = await settingsService.addInterest(userId, name);
|
||||
const interest = await settingsService.addInterest(userId, value.name);
|
||||
res.status(200).json({ interest });
|
||||
} catch (error) {
|
||||
console.error('Error adding interest:', error);
|
||||
@@ -112,10 +135,16 @@ class SettingsController {
|
||||
}
|
||||
|
||||
async addUserInterest(req, res) {
|
||||
const schema = Joi.object({
|
||||
interestid: Joi.number().integer().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 { interestid: interestId } = req.body;
|
||||
await settingsService.addUserInterest(userId, interestId);
|
||||
await settingsService.addUserInterest(userId, value.interestid);
|
||||
res.status(200).json({ message: 'User interest added successfully' });
|
||||
} catch (error) {
|
||||
console.error('Error adding user interest:', error);
|
||||
|
||||
Reference in New Issue
Block a user