chat controller: return 404 if task is not found
This was returning a 200 with an empty body, causing the client to npe due to deserializing it as a Task with no task or location
This commit is contained in:
@@ -34,6 +34,9 @@ import net.runelite.http.api.chat.LayoutRoom;
|
|||||||
import net.runelite.http.api.chat.Task;
|
import net.runelite.http.api.chat.Task;
|
||||||
import net.runelite.http.service.util.exception.NotFoundException;
|
import net.runelite.http.service.util.exception.NotFoundException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.CacheControl;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
@@ -155,9 +158,18 @@ public class ChatController
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/task")
|
@GetMapping("/task")
|
||||||
public Task getTask(@RequestParam String name)
|
public ResponseEntity<Task> getTask(@RequestParam String name)
|
||||||
{
|
{
|
||||||
return chatService.getTask(name);
|
Task task = chatService.getTask(name);
|
||||||
|
if (task == null)
|
||||||
|
{
|
||||||
|
return ResponseEntity.status(HttpStatus.NOT_FOUND)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResponseEntity.ok()
|
||||||
|
.cacheControl(CacheControl.maxAge(2, TimeUnit.MINUTES).cachePublic())
|
||||||
|
.body(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/pb")
|
@PostMapping("/pb")
|
||||||
|
|||||||
Reference in New Issue
Block a user