Browse Source

new db update 2 fix 2

master
gsd 1 year ago
parent
commit
89fd223b46
  1. 17
      src/main/java/app/controllers/user/MessagesController.java

17
src/main/java/app/controllers/user/MessagesController.java

@ -7,6 +7,7 @@ import app.entities.other.SteamID;
import app.services.db.MessageService; import app.services.db.MessageService;
import app.utils.SteamIDConverter; import app.utils.SteamIDConverter;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
@ -26,12 +27,12 @@ public class MessagesController {
@CheckWebAccess(auth_method = AuthMethod.STEAM64) @CheckWebAccess(auth_method = AuthMethod.STEAM64)
@WaitAfterNext(order = "messages") @WaitAfterNext(order = "messages")
public ResponseEntity getMessages(HttpServletRequest request, public ResponseEntity getMessages(HttpServletRequest request,
@RequestBody(required = false) String filter, @RequestBody(required = false) Payload filter,
@RequestParam(required = false) String srv, @RequestParam(required = false) String srv,
@RequestParam(required = false, defaultValue = "0") Integer offset, @RequestParam(required = false, defaultValue = "0") Integer offset,
@RequestParam(required = false, defaultValue = "20") Integer limit) { @RequestParam(required = false, defaultValue = "20") Integer limit) {
if (limit > 20) return new ResponseEntity(HttpStatus.NOT_ACCEPTABLE); if (limit > 20) return new ResponseEntity(HttpStatus.NOT_ACCEPTABLE);
return new ResponseEntity(messageService.getAllMessages(srv, filter==null||filter.isEmpty()?null:filter, offset, limit), HttpStatus.OK); return new ResponseEntity(messageService.getAllMessages(srv, filter==null?null:filter.getMessage(), offset, limit), HttpStatus.OK);
} }
@PostMapping("/account") @PostMapping("/account")
@ -39,14 +40,22 @@ public class MessagesController {
@WaitAfterNext(order = "messages") @WaitAfterNext(order = "messages")
public ResponseEntity getAccountMessages(HttpServletRequest request, public ResponseEntity getAccountMessages(HttpServletRequest request,
@CookieValue(value = "steam64", defaultValue = "") String mysteam64, @CookieValue(value = "steam64", defaultValue = "") String mysteam64,
@RequestBody(required = false) Payload filter,
@RequestParam(required = false) String steam64, @RequestParam(required = false) String steam64,
@RequestBody(required = false) String filter,
@RequestParam(required = false) String srv, @RequestParam(required = false) String srv,
@RequestParam(required = false, defaultValue = "0") Integer offset, @RequestParam(required = false, defaultValue = "0") Integer offset,
@RequestParam(required = false, defaultValue = "20") Integer limit) { @RequestParam(required = false, defaultValue = "20") Integer limit) {
SteamID steamID = steam64 == null || steam64.isEmpty() ? SteamIDConverter.getSteamID(mysteam64) : SteamIDConverter.getSteamID(steam64); SteamID steamID = steam64 == null || steam64.isEmpty() ? SteamIDConverter.getSteamID(mysteam64) : SteamIDConverter.getSteamID(steam64);
if (steamID == null) return new ResponseEntity(HttpStatus.NOT_FOUND); if (steamID == null) return new ResponseEntity(HttpStatus.NOT_FOUND);
if (limit > 20) return new ResponseEntity(HttpStatus.NOT_ACCEPTABLE); if (limit > 20) return new ResponseEntity(HttpStatus.NOT_ACCEPTABLE);
return new ResponseEntity(messageService.getAccountMessages(steamID, srv, filter==null||filter.isEmpty()?null:filter, offset, limit), HttpStatus.OK); return new ResponseEntity(messageService.getAccountMessages(steamID, srv, filter==null?null: filter.getMessage(), offset, limit), HttpStatus.OK);
}
@Data
public class Payload {
public String message;
public String getMessage() {
return message==null||message.isEmpty()?null:message;
}
} }
} }

Loading…
Cancel
Save