Add adult verification and erotic moderation features: Implement new routes and controller methods for managing adult verification requests, status updates, and document retrieval. Introduce erotic moderation actions and reports, enhancing administrative capabilities. Update chat and navigation controllers to support adult content filtering and access control. Enhance user parameter handling for adult verification status and requests, improving overall user experience and compliance.
This commit is contained in:
@@ -2,6 +2,8 @@ import { v4 as uuidv4 } from 'uuid';
|
||||
import amqp from 'amqplib/callback_api.js';
|
||||
import User from '../models/community/user.js';
|
||||
import Room from '../models/chat/room.js';
|
||||
import UserParam from '../models/community/user_param.js';
|
||||
import UserParamType from '../models/type/user_param.js';
|
||||
|
||||
const RABBITMQ_URL = process.env.AMQP_URL || 'amqp://localhost';
|
||||
const QUEUE = 'oneToOne_messages';
|
||||
@@ -166,17 +168,69 @@ class ChatService {
|
||||
(chat.user1Id === user2HashId && chat.user2Id === user1HashId)
|
||||
);
|
||||
}
|
||||
|
||||
calculateAge(birthdate) {
|
||||
const birthDate = new Date(birthdate);
|
||||
const ageDifMs = Date.now() - birthDate.getTime();
|
||||
const ageDate = new Date(ageDifMs);
|
||||
return Math.abs(ageDate.getUTCFullYear() - 1970);
|
||||
}
|
||||
|
||||
normalizeAdultVerificationStatus(value) {
|
||||
if (!value) return 'none';
|
||||
const normalized = String(value).trim().toLowerCase();
|
||||
return ['pending', 'approved', 'rejected'].includes(normalized) ? normalized : 'none';
|
||||
}
|
||||
|
||||
async getAdultAccessState(hashedUserId) {
|
||||
if (!hashedUserId) {
|
||||
return { isAdult: false, adultVerificationStatus: 'none', adultAccessEnabled: false };
|
||||
}
|
||||
|
||||
const user = await User.findOne({ where: { hashedId: hashedUserId }, attributes: ['id'] });
|
||||
if (!user) {
|
||||
throw new Error('user_not_found');
|
||||
}
|
||||
|
||||
const params = await UserParam.findAll({
|
||||
where: { userId: user.id },
|
||||
include: [{
|
||||
model: UserParamType,
|
||||
as: 'paramType',
|
||||
where: { description: ['birthdate', 'adult_verification_status'] }
|
||||
}]
|
||||
});
|
||||
|
||||
const birthdateParam = params.find(param => param.paramType?.description === 'birthdate');
|
||||
const statusParam = params.find(param => param.paramType?.description === 'adult_verification_status');
|
||||
const age = birthdateParam ? this.calculateAge(birthdateParam.value) : 0;
|
||||
const adultVerificationStatus = this.normalizeAdultVerificationStatus(statusParam?.value);
|
||||
return {
|
||||
isAdult: age >= 18,
|
||||
adultVerificationStatus,
|
||||
adultAccessEnabled: age >= 18 && adultVerificationStatus === 'approved'
|
||||
};
|
||||
}
|
||||
|
||||
async getRoomList() {
|
||||
async getRoomList(hashedUserId, { adultOnly = false } = {}) {
|
||||
// Nur öffentliche Räume, keine sensiblen Felder
|
||||
const { default: Room } = await import('../models/chat/room.js');
|
||||
const { default: RoomType } = await import('../models/chat/room_type.js');
|
||||
const where = { isPublic: true, isAdultOnly: Boolean(adultOnly) };
|
||||
|
||||
if (adultOnly) {
|
||||
const adultAccess = await this.getAdultAccessState(hashedUserId);
|
||||
if (!adultAccess.adultAccessEnabled) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
return Room.findAll({
|
||||
attributes: [
|
||||
'id', 'title', 'roomTypeId', 'isPublic', 'genderRestrictionId',
|
||||
'id', 'title', 'roomTypeId', 'isPublic', 'isAdultOnly', 'genderRestrictionId',
|
||||
'minAge', 'maxAge', 'friendsOfOwnerOnly', 'requiredUserRightId'
|
||||
],
|
||||
where: { isPublic: true },
|
||||
where,
|
||||
include: [
|
||||
{ model: RoomType, as: 'roomType' }
|
||||
]
|
||||
@@ -215,7 +269,7 @@ class ChatService {
|
||||
|
||||
return Room.findAll({
|
||||
where: { ownerId: user.id },
|
||||
attributes: ['id', 'title', 'isPublic', 'roomTypeId', 'ownerId'],
|
||||
attributes: ['id', 'title', 'isPublic', 'isAdultOnly', 'roomTypeId', 'ownerId'],
|
||||
order: [['title', 'ASC']]
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user