Refactor code structure for improved readability and maintainability; optimize performance across multiple modules.
All checks were successful
Deploy to production / deploy (push) Successful in 2m56s

This commit is contained in:
Torsten Schulz (local)
2026-07-21 09:08:15 +02:00
parent 75b52de282
commit 1ab9407e79
1400 changed files with 22278 additions and 485 deletions

14
backend/services/socialnetworkService.js Normal file → Executable file
View File

@@ -28,12 +28,26 @@ import DOMPurify from 'dompurify';
import sharp from 'sharp';
import Diary from '../models/community/diary.js';
import Friendship from '../models/community/friendship.js';
import UserBlock from '../models/community/user_block.js';
import { getUserSession } from '../utils/redis.js';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
class SocialNetworkService extends BaseService {
async blockUser(hashedBlockerId, blockedHashedId) {
const blockerId = await this.checkUserAccess(hashedBlockerId);
const blocked = await User.findOne({ where: { hashedId: blockedHashedId } });
if (!blocked || blocked.id === blockerId) throw new Error('Invalid block target');
await UserBlock.findOrCreate({ where: { blockerId, blockedId: blocked.id } });
}
async unblockUser(hashedBlockerId, blockedHashedId) {
const blockerId = await this.checkUserAccess(hashedBlockerId);
const blocked = await User.findOne({ where: { hashedId: blockedHashedId } });
if (!blocked) return;
await UserBlock.destroy({ where: { blockerId, blockedId: blocked.id } });
}
normalizeAdultVerificationStatus(value) {
if (!value) return 'none';
const normalized = String(value).trim().toLowerCase();