package httpapi

import (
	"net/http"

	"git.az-it.net/az/morz-infoboard/server/backend/internal/campaigns/messagewall"
)

func handleResolveMessageWall(w http.ResponseWriter, r *http.Request) {
	var request messagewall.ResolveRequest
	if err := decodeJSON(r, &request); err != nil {
		writeError(w, http.StatusBadRequest, "invalid_json", "request body is not valid JSON", err.Error())
		return
	}

	result, err := messagewall.Resolve(request)
	if err != nil {
		writeError(w, http.StatusBadRequest, "invalid_layout_json", "layout_json is invalid", err.Error())
		return
	}

	writeJSON(w, http.StatusOK, result)
}
