feat(Chat): implement chat incident reporting feature
All checks were successful
Deploy to production / deploy (push) Successful in 1m57s
All checks were successful
Deploy to production / deploy (push) Successful in 1m57s
- Added reportChatIncident method in ChatController to handle reporting of chat incidents. - Introduced a new API route for reporting incidents in chatRouter. - Implemented chatService methods to ensure the chat report table is created and to handle incident data storage. - Enhanced frontend components to allow users to report incidents in both multi and random chat dialogs. - Updated internationalization files to include new strings for reporting functionality in multiple languages.
This commit is contained in:
@@ -16,6 +16,7 @@ class ChatController {
|
||||
this.getRoomCreateOptions = this.getRoomCreateOptions.bind(this);
|
||||
this.getOwnRooms = this.getOwnRooms.bind(this);
|
||||
this.deleteOwnRoom = this.deleteOwnRoom.bind(this);
|
||||
this.reportChatIncident = this.reportChatIncident.bind(this);
|
||||
}
|
||||
|
||||
async getMessages(req, res) {
|
||||
@@ -215,6 +216,32 @@ class ChatController {
|
||||
res.status(status).json({ error: error.message });
|
||||
}
|
||||
}
|
||||
|
||||
async reportChatIncident(req, res) {
|
||||
const schema = Joi.object({
|
||||
context: Joi.string().valid('random_chat', 'multi_chat', 'one_to_one').required(),
|
||||
reporterHashedId: Joi.string().allow('', null),
|
||||
reporterRandomId: Joi.string().allow('', null),
|
||||
reporterUsername: Joi.string().allow('', null),
|
||||
offenderHashedId: Joi.string().allow('', null),
|
||||
offenderRandomId: Joi.string().allow('', null),
|
||||
offenderUsername: Joi.string().allow('', null),
|
||||
incidentAt: Joi.date().iso().required(),
|
||||
chatHistory: Joi.array().min(1).required(),
|
||||
metadata: Joi.object().unknown(true).optional()
|
||||
});
|
||||
const { error, value } = schema.validate(req.body || {});
|
||||
if (error) {
|
||||
return res.status(400).json({ error: error.details[0].message });
|
||||
}
|
||||
try {
|
||||
const result = await chatService.reportChatIncident(value);
|
||||
return res.status(201).json(result);
|
||||
} catch (err) {
|
||||
console.error('Error in reportChatIncident:', err);
|
||||
return res.status(400).json({ error: err.message });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default ChatController;
|
||||
|
||||
Reference in New Issue
Block a user