Activity check: closing in the background with a "closing" status, color #206694 in the palette
- Website shows "Being closed …" and reloads itself until the bot has sent the DMs and role changes (previously the website timed out after 10 s even though the bot finished) - Palette: new color dark blue #206694 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
392994e1cd
commit
a252d8d180
3 changed files with 16 additions and 7 deletions
11
activity.php
11
activity.php
|
|
@ -93,6 +93,7 @@ include __DIR__ . '/includes/header.php';
|
|||
<?php
|
||||
$c = $detail['counts'] ?? [];
|
||||
$isOpen = $detail['status'] === 'open';
|
||||
$isClosing = $detail['status'] === 'closing';
|
||||
$present = array_values(array_filter($detail['responses'] ?? [], static fn ($r) => $r['status'] === 'present'));
|
||||
$absent = array_values(array_filter($detail['responses'] ?? [], static fn ($r) => $r['status'] === 'absent'));
|
||||
$missing = $isOpen ? ($detail['pending'] ?? []) : ($detail['result']['missing'] ?? []);
|
||||
|
|
@ -101,14 +102,18 @@ include __DIR__ . '/includes/header.php';
|
|||
<a href="/activity.php" class="text-muted">‹ Alle Aktivitätschecks</a>
|
||||
<div class="raid-header">
|
||||
<h1>📋 <?= e($detail['title']) ?></h1>
|
||||
<span class="badge <?= $isOpen ? 'badge-active' : '' ?>"><?= $isOpen ? 'Läuft' : ($detail['status'] === 'cancelled' ? 'Abgebrochen' : 'Abgeschlossen') ?></span>
|
||||
<span class="badge <?= $isOpen ? 'badge-active' : '' ?>"><?= $isOpen ? 'Läuft' : ($isClosing ? 'Wird abgeschlossen …' : ($detail['status'] === 'cancelled' ? 'Abgebrochen' : 'Abgeschlossen')) ?></span>
|
||||
</div>
|
||||
<p class="text-muted">
|
||||
#<?= e((string) ($detail['channel_name'] ?? $detail['channel_id'])) ?> · für @<?= e((string) ($detail['target_role_name'] ?? '?')) ?> ·
|
||||
<?= $isOpen ? 'endet ' . e(date('d.m.Y H:i', (int) $detail['deadline'])) . ' Uhr (' . e($relative((int) $detail['deadline'])) . ')'
|
||||
: 'beendet ' . e(date('d.m.Y H:i', (int) $detail['closed_at'])) . ' Uhr von ' . e((string) $detail['closed_by']) ?>
|
||||
: ($isClosing ? 'wird gerade abgeschlossen' : 'beendet ' . e(date('d.m.Y H:i', (int) $detail['closed_at'])) . ' Uhr von ' . e((string) $detail['closed_by'])) ?>
|
||||
<?php if (!empty($detail['jump_url'])): ?> · <a href="<?= e($detail['jump_url']) ?>" target="_blank" rel="noopener">Im Discord ansehen</a><?php endif; ?>
|
||||
</p>
|
||||
<?php if ($isClosing): ?>
|
||||
<div class="flash flash-info activity-closing">⏳ Der Bot verschickt gerade die PNs und ändert Rollen - das kann bei vielen Leuten ein, zwei Minuten dauern. Die Seite aktualisiert sich von selbst.</div>
|
||||
<script>setTimeout(function () { location.reload(); }, 5000);</script>
|
||||
<?php endif; ?>
|
||||
<?php if ($isOpen): ?>
|
||||
<div class="activity-actions">
|
||||
<form method="post" action="/activity_action.php" class="inline-form"
|
||||
|
|
@ -152,7 +157,7 @@ include __DIR__ . '/includes/header.php';
|
|||
<div class="panel activity-column activity-missing">
|
||||
<h2>⏳ <?= $isOpen ? 'Noch offen' : 'Ohne Rückmeldung' ?> <span class="chip-count"><?= count($missing) ?></span></h2>
|
||||
<ul><?php foreach ($missing as $r): ?><?= $person((string) $r['user_id'], (string) ($r['user_name'] ?? $r['name'] ?? '?')) ?><?php endforeach; ?></ul>
|
||||
<?php if (!$missing): ?><p class="text-muted"><?= $isOpen ? 'Alle haben sich gemeldet 🎉' : 'Alle haben sich gemeldet 🎉' ?></p><?php endif; ?>
|
||||
<?php if (!$missing): ?><p class="text-muted"><?= $isClosing ? 'Wird gerade ermittelt …' : 'Alle haben sich gemeldet 🎉' ?></p><?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -81,17 +81,20 @@ try {
|
|||
|
||||
case 'close':
|
||||
case 'cancel':
|
||||
$result = activity_api_request('POST', '/' . $id . '/close', [], [
|
||||
// Abschliessen: der Bot antwortet sofort und arbeitet PNs/Rollen im Hintergrund ab
|
||||
// (bei vielen Leuten dauert das laenger, als die Website warten kann).
|
||||
$response = activity_api_request('POST', '/' . $id . '/close', [], [
|
||||
'cancel' => $action === 'cancel',
|
||||
'closed_by' => $myName . ' (Website)',
|
||||
])['result'] ?? [];
|
||||
]);
|
||||
admin_log($action === 'cancel' ? '🚫 Aktivitätscheck abgebrochen' : '📋 Aktivitätscheck abgeschlossen', [
|
||||
'Check' => '#' . $id,
|
||||
'Ohne Rückmeldung' => $action === 'cancel' ? '' : (string) count($result['missing'] ?? []),
|
||||
], $action === 'cancel' ? 'warning' : 'success', 'events');
|
||||
set_flash('success', $action === 'cancel'
|
||||
? 'Aktivitätscheck abgebrochen - ohne Folgen.'
|
||||
: 'Aktivitätscheck abgeschlossen. Ohne Rückmeldung: ' . count($result['missing'] ?? []) . '.');
|
||||
: (($response['state'] ?? '') === 'closing'
|
||||
? 'Aktivitätscheck wird abgeschlossen - PNs und Rollen werden gerade verschickt. Das Ergebnis erscheint gleich hier und im Log-Kanal.'
|
||||
: 'Aktivitätscheck ist abgeschlossen.'));
|
||||
redirect('/activity.php?id=' . $id);
|
||||
|
||||
case 'delete':
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ const ACTIVITY_COLORS = [
|
|||
'#f0b232' => 'Orange',
|
||||
'#9b59b6' => 'Lila',
|
||||
'#1abc9c' => 'Türkis',
|
||||
'#206694' => 'Dunkelblau',
|
||||
];
|
||||
|
||||
const ACTIVITY_DEFAULT_DM = 'Hallo {name}! Du hast dich beim Aktivitätscheck **{titel}** auf **{server}** nicht zurückgemeldet. '
|
||||
|
|
|
|||
Loading…
Reference in a new issue