{ "name": "F6-2: Self-Service Registration", "nodes": [ { "parameters": { "httpMethod": "POST", "path": "register-request" }, "name": "Webhook: Заявка", "type": "n8n-nodes-base.webhook", "typeVersion": 2, "position": [-400, 200], "webhookId": "f6-2-register" }, { "parameters": { "jsCode": "const d = $json.body || $json;\nconst u = d.username || 'user';\nconst n = d.name || 'User';\nconst e = d.email || 'u@b.ru';\nconst g = d.groups || 'gitea';\nconst approve = 'approve:' + u + ':' + e;\nconst deny = 'deny:' + u;\nreturn { json: { username: u, name: n, email: e, groups: g, approve_callback: approve, deny_callback: deny } };" }, "name": "Code: Prepare Data", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [-150, 200] }, { "parameters": { "method": "POST", "url": "https://193.233.210.184/tg-api/bot/sendMessage", "sendHeaders": true, "headerParameters": { "parameters": [{ "name": "Content-Type", "value": "application/json" }] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"chat_id\": 273442500,\n \"text\": \"🆕 Новая заявка\\n\\n👤 Имя: {{ $json.name }}\\n👤 Логин: {{ $json.username }}\\n📧 Email: {{ $json.email }}\\n🔑 Группы: {{ $json.groups }}\\n\\nВыберите действие:\",\n \"parse_mode\": \"HTML\",\n \"reply_markup\": {\n \"inline_keyboard\": [\n [\n {\"text\": \"✅ Одобрить\", \"callback_data\": \"{{ $json.approve_callback }}\"},\n {\"text\": \"❌ Отклонить\", \"callback_data\": \"{{ $json.deny_callback }}\"}\n ]\n ]\n }\n}", "options": { "allowUnauthorizedCerts": true } }, "name": "HTTP: Отправить Admin", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [100, 200] }, { "parameters": { "httpMethod": "POST", "path": "tg-callback" }, "name": "Webhook: Callback TG", "type": "n8n-nodes-base.webhook", "typeVersion": 2, "position": [-400, 500], "webhookId": "f6-2-callback" }, { "parameters": { "conditions": { "conditions": [ { "leftValue": "={{ $json.body?.callback_query?.data || $json.data }}", "rightValue": "approve:", "operator": { "type": "string", "operation": "startsWith" } } ] } }, "name": "IF: Одобрено?", "type": "n8n-nodes-base.if", "typeVersion": 2.2, "position": [-150, 500] }, { "parameters": { "method": "POST", "url": "http://192.168.1.114:9000/api/v3/core/users/", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "Authorization", "value": "Bearer " }, { "name": "Content-Type", "value": "application/json" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "{\n \"username\": \"{{ ($json.body?.callback_query?.data || $json.data).split(':')[1] }}\",\n \"name\": \"{{ ($json.body?.callback_query?.data || $json.data).split(':')[1] }}\",\n \"email\": \"{{ ($json.body?.callback_query?.data || $json.data).split(':')[2] }}\",\n \"is_active\": true\n}", "options": {} }, "name": "Authentik: Создать", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [100, 400] }, { "parameters": { "method": "POST", "url": "https://193.233.210.184/tg-api/bot/sendMessage", "sendHeaders": true, "headerParameters": { "parameters": [{ "name": "Content-Type", "value": "application/json" }] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"chat_id\": 273442500,\n \"text\": \"✅ Создан!\\n\\n👤 {{ ($json.body?.callback_query?.data || $json.data).split(':')[1] }}\\n🔗 Enrollment (24ч)\",\n \"parse_mode\": \"HTML\"\n}", "options": { "allowUnauthorizedCerts": true } }, "name": "HTTP: Ссылка Admin", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [350, 400] }, { "parameters": { "method": "POST", "url": "https://193.233.210.184/tg-api/bot/sendMessage", "sendHeaders": true, "headerParameters": { "parameters": [{ "name": "Content-Type", "value": "application/json" }] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"chat_id\": 273442500,\n \"text\": \"❌ Отклонено\\n\\nПользователь {{ ($json.body?.callback_query?.data || $json.data).split(':')[1] }} не был создан.\",\n \"parse_mode\": \"HTML\"\n}", "options": { "allowUnauthorizedCerts": true } }, "name": "HTTP: Отказ Admin", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [100, 600] } ], "connections": { "Webhook: Заявка": { "main": [[{ "node": "Code: Prepare Data", "type": "main", "index": 0 }]] }, "Code: Prepare Data": { "main": [[{ "node": "HTTP: Отправить Admin", "type": "main", "index": 0 }]] }, "Webhook: Callback TG": { "main": [[{ "node": "IF: Одобрено?", "type": "main", "index": 0 }]] }, "IF: Одобрено?": { "main": [[{ "node": "Authentik: Создать", "type": "main", "index": 0 }], [{ "node": "HTTP: Отказ Admin", "type": "main", "index": 0 }]] }, "Authentik: Создать": { "main": [[{ "node": "HTTP: Ссылка Admin", "type": "main", "index": 0 }]] } } }