Refactor project structure: enhance tests, improve server shutdown, expand CI checks, and update UI for better event presentation.
Some checks failed
CI / build-test (push) Failing after 4s
CI / docker (push) Has been skipped

This commit is contained in:
2026-02-23 21:12:39 +01:00
parent d38a0e7044
commit e4f32132e3
7 changed files with 153 additions and 28 deletions

View File

@@ -32,17 +32,6 @@ var (
updates = make(map[string]DiunEvent)
)
// Exported for test package
func GetUpdatesMap() map[string]DiunEvent {
return updates
}
func UpdatesReset() {
mu.Lock()
defer mu.Unlock()
updates = make(map[string]DiunEvent)
}
func UpdateEvent(event DiunEvent) {
mu.Lock()
defer mu.Unlock()
@@ -60,10 +49,21 @@ func GetUpdates() map[string]DiunEvent {
}
func WebhookHandler(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
return
}
var event DiunEvent
if err := json.NewDecoder(r.Body).Decode(&event); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
log.Printf("WebhookHandler: failed to decode request: %v", err)
http.Error(w, "bad request", http.StatusBadRequest)
return
}
if event.Image == "" {
http.Error(w, "bad request: image field is required", http.StatusBadRequest)
return
}