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