From f9ff325c8a83cfd1332782fd483432a77c6e837c Mon Sep 17 00:00:00 2001
From: glpshchn <464976@niuitmo.ru>
Date: Tue, 11 Nov 2025 03:54:39 +0300
Subject: [PATCH] Update files
---
backend/models/AdminConfirmation.js | 1 -
moderation/frontend/src/App.jsx | 156 +++++++++++++++++-----------
2 files changed, 97 insertions(+), 60 deletions(-)
diff --git a/backend/models/AdminConfirmation.js b/backend/models/AdminConfirmation.js
index 80ca669..8daed3a 100644
--- a/backend/models/AdminConfirmation.js
+++ b/backend/models/AdminConfirmation.js
@@ -12,7 +12,6 @@ const AdminConfirmationSchema = new mongoose.Schema({
},
adminNumber: {
type: Number,
- required: true,
min: 1,
max: 10
},
diff --git a/moderation/frontend/src/App.jsx b/moderation/frontend/src/App.jsx
index 733d3df..c510ea3 100644
--- a/moderation/frontend/src/App.jsx
+++ b/moderation/frontend/src/App.jsx
@@ -167,6 +167,9 @@ export default function App() {
loadReports();
} else if (tab === 'admins') {
loadAdmins();
+ } else if (tab === 'publish') {
+ // Загрузить список админов для проверки прав публикации
+ loadAdmins();
} else if (tab === 'chat' && user) {
initChat();
}
@@ -278,8 +281,16 @@ export default function App() {
const initChat = () => {
if (!user || chatSocketRef.current) return;
- const socket = io('/mod-chat', {
- transports: ['websocket', 'polling']
+
+ const API_URL = import.meta.env.VITE_API_URL || (
+ import.meta.env.PROD ? window.location.origin : 'http://localhost:3000'
+ );
+
+ const socket = io(`${API_URL}/mod-chat`, {
+ transports: ['websocket', 'polling'],
+ reconnection: true,
+ reconnectionDelay: 1000,
+ reconnectionAttempts: 5
});
socket.on('connect', () => {
@@ -626,67 +637,94 @@ export default function App() {
);
- const renderPublish = () => (
-
-
-
Публикация в @reichenbfurry
-
-
-
-
-
-
- {publishState.files.length > 0 && (
-
- {publishState.files.map((file, index) => (
-
- {file.name} ({Math.round(file.size / 1024)} KB)
+ const renderPublish = () => {
+ // Найти админа текущего пользователя
+ const currentAdmin = adminsData.admins.find((admin) => admin.telegramId === user.telegramId);
+ const canPublish = currentAdmin && currentAdmin.adminNumber >= 1 && currentAdmin.adminNumber <= 10;
+
+ return (
+
+
+
Публикация в @reichenbfurry
+
+
+ {!canPublish && (
+
+ ⚠️ Публиковать в канал могут только админы с номерами от 1 до 10.
+ {currentAdmin ? (
+
+ Ваш номер: #{currentAdmin.adminNumber} (доступ запрещён)
- ))}
+ ) : (
+
+ Вам не присвоен номер админа. Обратитесь к владельцу.
+
+ )}
)}
-
+
+
+
+
+ {currentAdmin && (
+
+ Ваш номер админа:
#{currentAdmin.adminNumber}
+
+ Автоматически будет добавлен тег #a{currentAdmin.adminNumber}
+
+
+ )}
+
+ {publishState.files.length > 0 && (
+
+ {publishState.files.map((file, index) => (
+
+ {file.name} ({Math.round(file.size / 1024)} KB)
+
+ ))}
+
+ )}
+
+
-
- );
+ );
+ };
const renderAdmins = () => (