feat(chat): add chat room management functionality
- Created new chat schema in the database. - Implemented chat room model with necessary fields (title, ownerId, roomTypeId, etc.). - Added room type model and rights model for chat functionality. - Developed API endpoints for managing chat rooms, including create, edit, and delete operations. - Integrated chat room management into the admin interface with a dedicated view and dialog for room creation/editing. - Added internationalization support for chat room management UI. - Implemented autocomplete for victim selection in underground activities. - Enhanced the underground view with new activity types and political target selection.
This commit is contained in:
43
backend/utils/initializeChat.js
Normal file
43
backend/utils/initializeChat.js
Normal file
@@ -0,0 +1,43 @@
|
||||
import ChatRight from "../models/chat/rights.js";
|
||||
import RoomType from "../models/chat/room_type.js";
|
||||
|
||||
const initializeChat = async () => {
|
||||
initializeChatRights();
|
||||
initializeRoomTypes();
|
||||
}
|
||||
|
||||
const RoomTypes = [
|
||||
'chat',
|
||||
'dice',
|
||||
'poker',
|
||||
'hangman'
|
||||
];
|
||||
|
||||
const ChatRights = [
|
||||
'talk',
|
||||
'scream',
|
||||
'whisper',
|
||||
'start game',
|
||||
'open room',
|
||||
'systemmessage'
|
||||
];
|
||||
|
||||
const initializeChatRights = async () => {
|
||||
for (const right of ChatRights) {
|
||||
await ChatRight.findOrCreate({
|
||||
where: { tr: right },
|
||||
defaults: { tr: right }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const initializeRoomTypes = async () => {
|
||||
for (const type of RoomTypes) {
|
||||
await RoomType.findOrCreate({
|
||||
where: { tr: type },
|
||||
defaults: { tr: type }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default initializeChat;
|
||||
@@ -21,6 +21,7 @@ const createSchemas = async () => {
|
||||
await sequelize.query('CREATE SCHEMA IF NOT EXISTS falukant_type');
|
||||
await sequelize.query('CREATE SCHEMA IF NOT EXISTS falukant_predefine');
|
||||
await sequelize.query('CREATE SCHEMA IF NOT EXISTS falukant_log');
|
||||
await sequelize.query('CREATE SCHEMA IF NOT EXISTS chat');
|
||||
};
|
||||
|
||||
const initializeDatabase = async () => {
|
||||
|
||||
@@ -10,6 +10,7 @@ import setupAssociations from '../models/associations.js';
|
||||
import models from '../models/index.js';
|
||||
import { createTriggers } from '../models/trigger.js';
|
||||
import initializeForum from './initializeForum.js';
|
||||
import initializeChat from './initializeChat.js';
|
||||
|
||||
const syncDatabase = async () => {
|
||||
try {
|
||||
@@ -43,6 +44,9 @@ const syncDatabase = async () => {
|
||||
console.log("Creating triggers...");
|
||||
await createTriggers();
|
||||
|
||||
console.log("Initializing chat...");
|
||||
await initializeChat();
|
||||
|
||||
console.log('Database synchronization complete.');
|
||||
} catch (error) {
|
||||
console.error('Unable to synchronize the database:', error);
|
||||
|
||||
Reference in New Issue
Block a user