package com.alttd.altitudeweb.controllers.chat;

import com.alttd.altitudeweb.api.ChatApi;
import com.alttd.altitudeweb.model.ChatMessageDto;
import com.alttd.altitudeweb.model.ServerStateDto;
import com.alttd.altitudeweb.services.chat.ChatService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequiredArgsConstructor
public class ChatController implements ChatApi {

    private final ChatService chatService;

    @Override
    public ResponseEntity<Void> sendChatMessages(List<ChatMessageDto> chatMessageDtoList) {
        List<ChatMessage> list = chatMessageDtoList.stream().map(ChatMessageMapper::fromDto).toList();
        chatService.addChatMessage(list);
        return new ResponseEntity<>(HttpStatus.ACCEPTED);
    }

    @Override
    public ResponseEntity<Void> updateServerStates(ServerStateDto serverStateDto) {
        //TODO [Stijn] [2026-07-18]: Implement handling server state updates (push to listeners)
        throw new UnsupportedOperationException("Not implemented");
    }
}
