ge plugin: submit partially completed trades

This commit is contained in:
Adam
2020-05-29 13:49:38 -04:00
parent 6d46bb09c4
commit 17d6921a4a
4 changed files with 258 additions and 31 deletions

View File

@@ -29,6 +29,7 @@ import java.util.Collection;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.runelite.http.api.RuneLiteAPI;
import net.runelite.http.api.ge.GrandExchangeTrade;
import net.runelite.http.service.account.AuthFilter;
import net.runelite.http.service.account.beans.SessionEntry;
@@ -58,14 +59,23 @@ public class GrandExchangeController
@PostMapping
public void submit(HttpServletRequest request, HttpServletResponse response, @RequestBody GrandExchangeTrade grandExchangeTrade) throws IOException
{
SessionEntry session = authFilter.handle(request, response);
if (session == null)
SessionEntry session = null;
if (request.getHeader(RuneLiteAPI.RUNELITE_AUTH) != null)
{
return;
session = authFilter.handle(request, response);
if (session == null)
{
// error is set here on the response, so we shouldn't continue
return;
}
}
Integer userId = session == null ? null : session.getUser();
grandExchangeService.add(session.getUser(), grandExchangeTrade);
// We don't keep track of pending trades in the web UI, so only add cancelled or completed trades
if (userId != null && (grandExchangeTrade.isCancel() || grandExchangeTrade.getQuantity() == grandExchangeTrade.getTotal()))
{
grandExchangeService.add(userId, grandExchangeTrade);
}
}
@GetMapping