Template
Feat(bugs): notifications Discord, invitations et comptes
Envoie chaque signalement dans un canal forum Discord (post avec résumé + logs par morceaux), met à jour le post quand le statut change côté admin, et ajoute l'inscription par code d'invitation à usage unique + changement de mot de passe dans le panneau.
This commit is contained in:
1 parent
f7605ae6f0
commit
f94e6e1f15
7 files changed
+885
-7
No files matched your search
+35
-4
@@ -12,6 +12,7 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
require __DIR__ . '/bugs/db.php';
|
||||
require __DIR__ . '/bugs/discord.php';
|
||||
|
||||
/* Jamais d'avertissements/stack traces PHP visibles côté client */
|
||||
ini_set('display_errors', '0');
|
||||
@@ -116,15 +117,17 @@ if (fws_bugs_count_recent_for_ip($pdo, $ip) >= 25) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/* Insertion */
|
||||
/* Insertion — l'id repart de 1 et saute ceux déjà pris */
|
||||
try {
|
||||
$bugId = fws_bugs_next_id($pdo, 'bug_reports');
|
||||
$stmt = $pdo->prepare(
|
||||
'INSERT INTO bug_reports
|
||||
(app, version, type, title, description, email, system_info, logs, ip, user_agent)
|
||||
(id, app, version, type, title, description, email, system_info, logs, ip, user_agent)
|
||||
VALUES
|
||||
(:app, :version, :type, :title, :description, :email, :system_info, :logs, :ip, :ua)'
|
||||
(:id, :app, :version, :type, :title, :description, :email, :system_info, :logs, :ip, :ua)'
|
||||
);
|
||||
$stmt->execute([
|
||||
':id' => $bugId,
|
||||
':app' => $app,
|
||||
':version' => $version,
|
||||
':type' => $type !== '' ? $type : 'bug',
|
||||
@@ -146,9 +149,37 @@ try {
|
||||
http_response_code(201);
|
||||
echo json_encode([
|
||||
'ok' => true,
|
||||
'id' => (int) $pdo->lastInsertId(),
|
||||
'id' => $bugId,
|
||||
'message' => 'Signalement enregistré. Merci !',
|
||||
], JSON_UNESCAPED_UNICODE);
|
||||
|
||||
/* Envoie la réponse au client tout de suite ; la notif Discord suit en arrière-plan. */
|
||||
if (function_exists('fastcgi_finish_request')) {
|
||||
fastcgi_finish_request();
|
||||
} else {
|
||||
flush();
|
||||
}
|
||||
|
||||
/* Notification Discord (best-effort : n'affecte jamais la réponse de l'API) */
|
||||
try {
|
||||
$discord = fws_bugs_discord_notify([
|
||||
'id' => $bugId,
|
||||
'app' => $app,
|
||||
'version' => $version,
|
||||
'type' => $type !== '' ? $type : 'bug',
|
||||
'title' => $title,
|
||||
'description' => $description,
|
||||
'email' => $email,
|
||||
'system_info' => $systemInfo,
|
||||
'logs' => $logs,
|
||||
'status' => 'nouveau',
|
||||
]);
|
||||
if (is_array($discord) && !empty($discord['thread_id'])) {
|
||||
fws_bugs_save_discord_info($pdo, $bugId, (string) $discord['thread_id'], (string) ($discord['post_url'] ?? ''));
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
error_log('[fws-bugs] discord : ' . $e->getMessage());
|
||||
}
|
||||
exit;
|
||||
|
||||
/* ──────────────────────────────────────────── */
|
||||
|
||||
Reference in new issue
Block a user