forked from Cookies_Github_mirror/AquaDX
[mai2] limit upload user portrait file size
This commit is contained in:
@@ -12,6 +12,7 @@ import icu.samnyan.aqua.sega.general.model.Card;
|
||||
import icu.samnyan.aqua.sega.general.service.CardService;
|
||||
import icu.samnyan.aqua.sega.maimai2.dao.userdata.*;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.*;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
@@ -83,6 +84,11 @@ public class ApiMaimai2PlayerDataController {
|
||||
this.userUdemaeRepository = userUdemaeRepository;
|
||||
}
|
||||
|
||||
@GetMapping("config/userPhoto/divMaxLength")
|
||||
public long getConfigUserPhotoDivMaxLength(@Value("${game.maimai2.userPhoto.divMaxLength:16}") long divMaxLength) {
|
||||
return divMaxLength;
|
||||
}
|
||||
|
||||
@GetMapping("profile")
|
||||
public ProfileResp getProfile(@RequestParam long aimeId) {
|
||||
return mapper.convert(userDataRepository.findByCard_ExtId(aimeId).orElseThrow(), new TypeReference<>() {
|
||||
|
||||
@@ -27,13 +27,16 @@ public class UploadUserPortraitHandler implements BaseHandler {
|
||||
|
||||
private final String picSavePath;
|
||||
private final boolean enable;
|
||||
private final long divMaxLength;
|
||||
|
||||
public UploadUserPortraitHandler(BasicMapper mapper,
|
||||
@Value("${game.maimai2.userPhoto.enable:true}") boolean enable,
|
||||
@Value("${game.maimai2.userPhoto.picSavePath:data/userPhoto}") String picSavePath) {
|
||||
@Value("${game.maimai2.userPhoto.enable:true}") boolean enable,
|
||||
@Value("${game.maimai2.userPhoto.picSavePath:data/userPhoto}") String picSavePath,
|
||||
@Value("${game.maimai2.userPhoto.divMaxLength:16}") long divMaxLength) {
|
||||
this.mapper = mapper;
|
||||
this.picSavePath = picSavePath;
|
||||
this.enable = enable;
|
||||
this.divMaxLength = divMaxLength;
|
||||
|
||||
if (enable) {
|
||||
try {
|
||||
@@ -60,6 +63,9 @@ public class UploadUserPortraitHandler implements BaseHandler {
|
||||
int divLength = userPhoto.getDivLength();
|
||||
String divData = userPhoto.getDivData();
|
||||
|
||||
if (divLength > divMaxLength)
|
||||
return "{\"returnCode\":-1,\"apiName\":\"com.sega.maimai2servlet.api.UploadUserPortraitApi\"}";
|
||||
|
||||
try {
|
||||
var tmp_filename = Paths.get(picSavePath, userId + "-up.tmp");
|
||||
if (divNumber == 0)
|
||||
|
||||
Reference in New Issue
Block a user