Stage 4: alert acknowledgement and comments

- Migration 004: acknowledged_by/acknowledged_at columns on alerts,
  alert_comments table (FK cascade on delete)
- POST /api/alerts/{id}/acknowledge — stamps authed user + timestamp,
  returns updated alert with acknowledged_by username
- DELETE /api/alerts/{id}/acknowledge — clears ack (204)
- GET /api/alerts/{id}/comments — list in chronological order
- POST /api/alerts/{id}/comments — add comment (returns 201)
- DELETE /api/alerts/{id}/comments/{commentID} — own comments only (204)
- All alert queries now LEFT JOIN users for ack username
This commit is contained in:
Niklas Ye
2026-05-20 21:57:11 +02:00
parent 9b4ca1482f
commit c3348a410a
6 changed files with 248 additions and 19 deletions
+5
View File
@@ -13,4 +13,9 @@ type Alert struct {
EndsAt *time.Time `json:"ends_at,omitempty"`
GeneratorURL string `json:"generator_url"`
ReceivedAt time.Time `json:"received_at"`
// Populated when the alert has been acknowledged.
AcknowledgedByID *int64 `json:"acknowledged_by_id,omitempty"`
AcknowledgedByUser *string `json:"acknowledged_by,omitempty"`
AcknowledgedAt *time.Time `json:"acknowledged_at,omitempty"`
}
+12
View File
@@ -0,0 +1,12 @@
package models
import "time"
type Comment struct {
ID int64 `json:"id"`
AlertID int64 `json:"alert_id"`
UserID int64 `json:"user_id"`
Username string `json:"username"`
Content string `json:"content"`
CreatedAt time.Time `json:"created_at"`
}