Add room creation options endpoint and integrate with chat UI: Implement getRoomCreateOptions in ChatController and ChatService, add corresponding API route, and enhance MultiChatDialog for room creation with localized labels and validation. Update i18n files for new room creation features.
This commit is contained in:
@@ -13,6 +13,7 @@ class ChatController {
|
||||
this.sendOneToOneMessage = this.sendOneToOneMessage.bind(this);
|
||||
this.getOneToOneMessageHistory = this.getOneToOneMessageHistory.bind(this);
|
||||
this.getRoomList = this.getRoomList.bind(this);
|
||||
this.getRoomCreateOptions = this.getRoomCreateOptions.bind(this);
|
||||
}
|
||||
|
||||
async getMessages(req, res) {
|
||||
@@ -175,6 +176,15 @@ class ChatController {
|
||||
res.status(500).json({ error: error.message });
|
||||
}
|
||||
}
|
||||
|
||||
async getRoomCreateOptions(req, res) {
|
||||
try {
|
||||
const options = await chatService.getRoomCreateOptions();
|
||||
res.status(200).json(options);
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: error.message });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default ChatController;
|
||||
|
||||
@@ -15,5 +15,6 @@ router.post('/initOneToOne', authenticate, chatController.initOneToOne);
|
||||
router.post('/oneToOne/sendMessage', authenticate, chatController.sendOneToOneMessage); // Neue Route zum Senden einer Nachricht
|
||||
router.get('/oneToOne/messageHistory', authenticate, chatController.getOneToOneMessageHistory); // Neue Route zum Abrufen der Nachrichtengeschichte
|
||||
router.get('/rooms', chatController.getRoomList);
|
||||
router.get('/room-create-options', authenticate, chatController.getRoomCreateOptions);
|
||||
|
||||
export default router;
|
||||
|
||||
@@ -148,6 +148,27 @@ class ChatService {
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async getRoomCreateOptions() {
|
||||
const { default: UserRightType } = await import('../models/type/user_right.js');
|
||||
const { default: InterestType } = await import('../models/type/interest.js');
|
||||
|
||||
const [rights, interests] = await Promise.all([
|
||||
UserRightType.findAll({
|
||||
attributes: ['id', 'title'],
|
||||
order: [['id', 'ASC']]
|
||||
}),
|
||||
InterestType.findAll({
|
||||
attributes: ['id', 'name'],
|
||||
order: [['id', 'ASC']]
|
||||
})
|
||||
]);
|
||||
|
||||
return {
|
||||
rights: rights.map((r) => ({ id: r.id, title: r.title })),
|
||||
roomTypes: interests.map((i) => ({ id: i.id, name: i.name }))
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default new ChatService();
|
||||
|
||||
Reference in New Issue
Block a user