loottracker: submit loot when not logged in

This is to aid the wiki drop log project. The data is not otherwise
stored.
This commit is contained in:
Adam
2020-10-01 10:03:50 -04:00
parent 32638ccf63
commit 1799c9e593
7 changed files with 54 additions and 27 deletions

View File

@@ -65,14 +65,22 @@ public class LootTrackerController
@RequestMapping(method = RequestMethod.POST)
public void storeLootRecord(HttpServletRequest request, HttpServletResponse response, @RequestBody Collection<LootRecord> records) throws IOException
{
SessionEntry e = auth.handle(request, response);
if (e == null)
SessionEntry session = null;
if (request.getHeader(RuneLiteAPI.RUNELITE_AUTH) != null)
{
response.setStatus(HttpStatusCodes.STATUS_CODE_UNAUTHORIZED);
return;
session = auth.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();
service.store(records, e.getUser());
if (userId != null)
{
service.store(records, userId);
}
response.setStatus(HttpStatusCodes.STATUS_CODE_OK);
try (Jedis jedis = redisPool.getResource())