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:
@@ -1,9 +1,12 @@
|
||||
import RoomType from '../models/chat/room_type.js';
|
||||
import ChatRight from '../models/chat/rights.js';
|
||||
import UserRight from "../models/community/user_right.js";
|
||||
import UserRightType from "../models/type/user_right.js";
|
||||
import InterestType from "../models/type/interest.js"
|
||||
import InterestTranslationType from "../models/type/interest_translation.js"
|
||||
import InterestType from "../models/type/interest.js";
|
||||
import InterestTranslationType from "../models/type/interest_translation.js";
|
||||
import User from "../models/community/user.js";
|
||||
import UserParamValue from "../models/type/user_param_value.js";
|
||||
import UserParamType from "../models/type/user_param.js";
|
||||
import ContactMessage from "../models/service/contactmessage.js";
|
||||
import ContactService from "./ContactService.js";
|
||||
import { sendAnswerEmail } from './emailService.js';
|
||||
@@ -12,6 +15,7 @@ import FalukantUser from "../models/falukant/data/user.js";
|
||||
import FalukantCharacter from "../models/falukant/data/character.js";
|
||||
import FalukantPredefineFirstname from "../models/falukant/predefine/firstname.js";
|
||||
import FalukantPredefineLastname from "../models/falukant/predefine/lastname.js";
|
||||
import Room from '../models/chat/room.js';
|
||||
|
||||
class AdminService {
|
||||
async hasUserAccess(userId, section) {
|
||||
@@ -286,6 +290,39 @@ class AdminService {
|
||||
await falukantUser.save();
|
||||
await character.save();
|
||||
}
|
||||
|
||||
// --- Chat Room Admin ---
|
||||
async getRoomTypes() {
|
||||
return await RoomType.findAll();
|
||||
}
|
||||
|
||||
async getGenderRestrictions() {
|
||||
// Find the UserParamType for gender restriction (e.g. description = 'gender')
|
||||
const genderType = await UserParamType.findOne({ where: { description: 'gender' } });
|
||||
if (!genderType) return [];
|
||||
return await UserParamValue.findAll({ where: { userParamTypeId: genderType.id } });
|
||||
}
|
||||
|
||||
async getUserRights() {
|
||||
return await ChatRight.findAll();
|
||||
}
|
||||
|
||||
async getRooms() {
|
||||
return await Room.findAll({
|
||||
include: [
|
||||
{ model: RoomType, as: 'roomType' },
|
||||
{ model: UserParamValue, as: 'genderRestriction' },
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async createRoom(data) {
|
||||
return await Room.create(data);
|
||||
}
|
||||
|
||||
async deleteRoom(id) {
|
||||
return await Room.destroy({ where: { id } });
|
||||
}
|
||||
}
|
||||
|
||||
export default new AdminService();
|
||||
Reference in New Issue
Block a user