diff --git a/backend/routes/modApp.js b/backend/routes/modApp.js index abaab74..ae99240 100644 --- a/backend/routes/modApp.js +++ b/backend/routes/modApp.js @@ -187,6 +187,63 @@ router.get('/posts', authenticateModeration, requireModerationAccess, async (req }); }); +// Получить пост с комментариями +router.get('/posts/:id', authenticateModeration, requireModerationAccess, async (req, res) => { + try { + const post = await Post.findById(req.params.id) + .populate('author', 'username firstName lastName photoUrl') + .populate('comments.author', 'username firstName lastName photoUrl') + .exec(); + + if (!post) { + return res.status(404).json({ error: 'Пост не найден' }); + } + + res.json({ + post: { + id: post._id, + author: post.author ? serializeUser(post.author) : null, + content: post.content, + hashtags: post.hashtags, + tags: post.tags, + images: post.images || (post.imageUrl ? [post.imageUrl] : []), + comments: post.comments || [], + likesCount: post.likes?.length || 0, + isNSFW: post.isNSFW, + createdAt: post.createdAt + } + }); + } catch (error) { + console.error('Ошибка получения поста:', error); + res.status(500).json({ error: 'Ошибка сервера' }); + } +}); + +// Удалить комментарий (модераторский интерфейс) +router.delete('/posts/:postId/comments/:commentId', authenticateModeration, requireModerationAccess, async (req, res) => { + try { + const post = await Post.findById(req.params.postId); + + if (!post) { + return res.status(404).json({ error: 'Пост не найден' }); + } + + const comment = post.comments.id(req.params.commentId); + if (!comment) { + return res.status(404).json({ error: 'Комментарий не найден' }); + } + + post.comments.pull(req.params.commentId); + await post.save(); + await post.populate('comments.author', 'username firstName lastName photoUrl'); + + res.json({ comments: post.comments }); + } catch (error) { + console.error('Ошибка удаления комментария:', error); + res.status(500).json({ error: 'Ошибка сервера' }); + } +}); + router.put('/posts/:id', authenticateModeration, requireModerationAccess, async (req, res) => { const { content, hashtags, tags, isNSFW } = req.body; diff --git a/frontend/src/pages/Profile.jsx b/frontend/src/pages/Profile.jsx index 79a6e4e..ab4c6c2 100644 --- a/frontend/src/pages/Profile.jsx +++ b/frontend/src/pages/Profile.jsx @@ -1,10 +1,8 @@ import { useState } from 'react' -import { Settings, Heart, Edit2, Shield, Copy, Users } from 'lucide-react' +import { Settings, Heart, Edit2, Shield } from 'lucide-react' import { updateProfile } from '../utils/api' -import { hapticFeedback, showAlert } from '../utils/telegram' -import { decodeHtmlEntities } from '../utils/htmlEntities' +import { hapticFeedback } from '../utils/telegram' import ThemeToggle from '../components/ThemeToggle' -import FollowListModal from '../components/FollowListModal' import './Profile.css' const DONATION_URL = 'https://donatepay.ru/don/1435720' @@ -40,8 +38,6 @@ export default function Profile({ user, setUser }) { const [showSettings, setShowSettings] = useState(false) const [showEditBio, setShowEditBio] = useState(false) const [bio, setBio] = useState(user.bio || '') - const [showFollowers, setShowFollowers] = useState(false) - const [showFollowing, setShowFollowing] = useState(false) const [settings, setSettings] = useState(normalizeSettings(user.settings)) const [saving, setSaving] = useState(false) @@ -144,7 +140,7 @@ export default function Profile({ user, setUser }) { {user.bio ? (
{decodeHtmlEntities(user.bio)}
+{user.bio}
@@ -158,12 +154,12 @@ export default function Profile({ user, setUser }) {Получи +1 к счетчику, когда приглашенный создаст первый пост
-{`https://t.me/${import.meta.env.VITE_TELEGRAM_BOT_NAME || 'NakamaSpaceBot'}?startapp=${user.referralCode}`}
-