Compare commits
No commits in common. "f7a08cdf0907ba2e4b880f6c2103af27e9e06af2" and "f79d460f10abf975ab06ab3277bcb47362c6e4e8" have entirely different histories.
f7a08cdf09
...
f79d460f10
@ -2,13 +2,12 @@ package com.red.circle.console.adapter.app.party3rd;//package com.sugartime.app.
|
||||
|
||||
import com.red.circle.external.inner.endpoint.oss.OssServiceClient;
|
||||
import com.red.circle.framework.core.asserts.ResponseAssert;
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
@ -58,30 +57,23 @@ public class AliYunRestController {
|
||||
fileHeaders.setContentType(MediaType.parseMediaType(file.getContentType()));
|
||||
}
|
||||
|
||||
ByteArrayResource resource = new ByteArrayResource(file.getBytes()) {
|
||||
@Override
|
||||
public String getFilename() {
|
||||
return Objects.toString(file.getOriginalFilename(), "upload.bin");
|
||||
}
|
||||
};
|
||||
|
||||
MultiValueMap<String, Object> body = new LinkedMultiValueMap<>();
|
||||
body.add("file", new HttpEntity<>(resource, fileHeaders));
|
||||
|
||||
String uploadUrl = externalBaseUrl.replaceAll("/+$", "")
|
||||
+ "/oss/upload/general?dir=" + encode(dir)
|
||||
+ "&filename=" + encode(filename);
|
||||
ResponseEntity<Map> response;
|
||||
try (InputStream inputStream = file.getInputStream()) {
|
||||
InputStreamResource resource = new InputStreamResource(inputStream) {
|
||||
@Override
|
||||
public String getFilename() {
|
||||
return Objects.toString(file.getOriginalFilename(), "upload.bin");
|
||||
}
|
||||
|
||||
@Override
|
||||
public long contentLength() {
|
||||
return file.getSize();
|
||||
}
|
||||
};
|
||||
|
||||
MultiValueMap<String, Object> body = new LinkedMultiValueMap<>();
|
||||
body.add("file", new HttpEntity<>(resource, fileHeaders));
|
||||
response = new RestTemplate().postForEntity(
|
||||
uploadUrl,
|
||||
new HttpEntity<>(body, requestHeaders),
|
||||
Map.class);
|
||||
}
|
||||
ResponseEntity<Map> response = new RestTemplate().postForEntity(
|
||||
uploadUrl,
|
||||
new HttpEntity<>(body, requestHeaders),
|
||||
Map.class);
|
||||
Map<?, ?> responseBody = response.getBody();
|
||||
if (responseBody == null || !Boolean.TRUE.equals(responseBody.get("status"))) {
|
||||
String errorMsg = responseBody == null ? "upload failed"
|
||||
|
||||
@ -69,7 +69,6 @@ public class UserDataViolationServiceImpl implements UserDataViolationService {
|
||||
}*/
|
||||
|
||||
public void processUpdateAccountStatus(ApprovalAccountCmd param) {
|
||||
boolean realtimeKicked = false;
|
||||
|
||||
// 警告
|
||||
if (ConsoleAccountStatusEnum.WARNING.eq(param.getAccountStatusEnum())) {
|
||||
@ -113,8 +112,8 @@ public class UserDataViolationServiceImpl implements UserDataViolationService {
|
||||
redisService
|
||||
.delete(SecurityConstant.getAccessTokenCacheKeyMd5(param.getBeApprovalUserId()));
|
||||
|
||||
kickUserAndRemoveAuthToken(param.getBeApprovalUserId());
|
||||
realtimeKicked = true;
|
||||
imAccountClient.kick(param.getBeApprovalUserId());
|
||||
authClient.removeToken(param.getBeApprovalUserId());
|
||||
}
|
||||
// 封禁+设备
|
||||
else if (ConsoleAccountStatusEnum.ARCHIVE_DEVICE.eq(param.getAccountStatusEnum())) {
|
||||
@ -138,8 +137,9 @@ public class UserDataViolationServiceImpl implements UserDataViolationService {
|
||||
redisService
|
||||
.delete(SecurityConstant.getAccessTokenCacheKeyMd5(relationUser.getUserId()));
|
||||
|
||||
kickUserAndRemoveAuthToken(relationUser.getUserId());
|
||||
ResponseAssert.requiredSuccess(newsletterClient.send(
|
||||
imAccountClient.kick(relationUser.getUserId());
|
||||
authClient.removeToken(relationUser.getUserId());
|
||||
ResponseAssert.requiredSuccess(newsletterClient.send(
|
||||
new NewsletterResultCmd()
|
||||
.setUserIds(List.of(relationUser.getUserId()))
|
||||
.setEvent(NewsletterEvent.ARCHIVE_DEVICE)
|
||||
@ -215,9 +215,7 @@ public class UserDataViolationServiceImpl implements UserDataViolationService {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!realtimeKicked) {
|
||||
removeTrtcRoom(param.getBeApprovalUserId());
|
||||
}
|
||||
removeTrtcRoom(param);
|
||||
|
||||
addLog(param, param.getBeApprovalUserId());
|
||||
|
||||
@ -225,15 +223,9 @@ public class UserDataViolationServiceImpl implements UserDataViolationService {
|
||||
|
||||
}
|
||||
|
||||
private void kickUserAndRemoveAuthToken(Long userId) {
|
||||
imAccountClient.kick(userId);
|
||||
authClient.removeToken(userId);
|
||||
removeTrtcRoom(userId);
|
||||
}
|
||||
|
||||
private void removeTrtcRoom(Long userId) {
|
||||
private void removeTrtcRoom(ApprovalAccountCmd param) {
|
||||
String sessionId = ResponseAssert.requiredSuccess(
|
||||
userOnlineClient.getSessionId(userId));
|
||||
userOnlineClient.getSessionId(param.getBeApprovalUserId()));
|
||||
if (Objects.nonNull(sessionId)) {
|
||||
RoomProfileDTO roomProfile = ResponseAssert.requiredSuccess(
|
||||
roomManagerClient.getProfileById(Long.valueOf(sessionId)));
|
||||
@ -241,7 +233,7 @@ public class UserDataViolationServiceImpl implements UserDataViolationService {
|
||||
trtcClient.removeUser(
|
||||
new TrtcRemoveUserCmd()
|
||||
.setRoomId(Long.parseLong(roomProfile.getRoomAccount()))
|
||||
.setUserIds(List.of(userId))
|
||||
.setUserIds(List.of(param.getBeApprovalUserId()))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
@Configuration
|
||||
public class UndertowUploadLimitConfiguration {
|
||||
|
||||
private static final long MAX_UPLOAD_SIZE_BYTES = 500L * 1024 * 1024;
|
||||
private static final long MAX_UPLOAD_SIZE_BYTES = 20L * 1024 * 1024;
|
||||
|
||||
@Bean
|
||||
public WebServerFactoryCustomizer<ConfigurableUndertowWebServerFactory> undertowUploadLimitCustomizer() {
|
||||
|
||||
@ -4,7 +4,7 @@ server:
|
||||
servlet:
|
||||
context-path: /console
|
||||
undertow:
|
||||
max-http-post-size: 500MB
|
||||
max-http-post-size: 20MB
|
||||
no-request-timeout: 60000
|
||||
|
||||
spring:
|
||||
@ -19,9 +19,9 @@ spring:
|
||||
dev: dev,web-framework,openfeign,mybatis-plus
|
||||
prod: prod,web-framework,openfeign,mybatis-plus
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 500MB
|
||||
max-request-size: 500MB
|
||||
multipart:
|
||||
max-file-size: 20MB
|
||||
max-request-size: 20MB
|
||||
enabled: true
|
||||
---
|
||||
spring:
|
||||
|
||||
@ -31,7 +31,7 @@ import java.util.UUID;
|
||||
public class OssRestController {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(OssRestController.class);
|
||||
private static final long MAX_UPLOAD_SIZE_BYTES = 500L * 1024 * 1024;
|
||||
private static final long MAX_UPLOAD_SIZE_BYTES = 20L * 1024 * 1024;
|
||||
|
||||
private final AliYunStsService aliYunStsService;
|
||||
private final OssService ossService;
|
||||
@ -78,7 +78,7 @@ public class OssRestController {
|
||||
return ResultResponse.failure(OssErrorCode.FILE_IS_NULL);
|
||||
}
|
||||
if (file.getSize() > MAX_UPLOAD_SIZE_BYTES) {
|
||||
return ResultResponse.failure(OssErrorCode.FILE_SIZE_GREATER_THAN_500M);
|
||||
return ResultResponse.failure(OssErrorCode.FILE_SIZE_GREATER_THAN_20M);
|
||||
}
|
||||
String name = file.getOriginalFilename().toLowerCase();
|
||||
if(!FileUtils.fileContentType(name)) {
|
||||
@ -123,7 +123,7 @@ public class OssRestController {
|
||||
return ResultResponse.failure(OssErrorCode.FILE_IS_NULL);
|
||||
}
|
||||
if (file.getSize() > MAX_UPLOAD_SIZE_BYTES) {
|
||||
return ResultResponse.failure(OssErrorCode.FILE_SIZE_GREATER_THAN_500M);
|
||||
return ResultResponse.failure(OssErrorCode.FILE_SIZE_GREATER_THAN_20M);
|
||||
}
|
||||
String storageKey = buildStorageKey(dir, filename, file.getOriginalFilename());
|
||||
if (tencentCosStorageService.isEnabled()) {
|
||||
|
||||
@ -5,7 +5,7 @@ import com.red.circle.framework.dto.IResponseErrorCode;
|
||||
public enum OssErrorCode implements IResponseErrorCode {
|
||||
FILE_IS_NULL(20001, "file is null"),
|
||||
FILE_TYPE_NOT_SUPPORTED(20003, "File type not supported"),
|
||||
FILE_SIZE_GREATER_THAN_500M(20003, "File size greater than 500M"),
|
||||
FILE_SIZE_GREATER_THAN_20M(20003, "File size greater than 20M"),
|
||||
NETWORK_ANOMALY(20004, "network anomaly");
|
||||
|
||||
private final int code;
|
||||
|
||||
@ -9,7 +9,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
@Configuration
|
||||
public class UndertowUploadLimitConfiguration {
|
||||
|
||||
private static final long MAX_UPLOAD_SIZE_BYTES = 500L * 1024 * 1024;
|
||||
private static final long MAX_UPLOAD_SIZE_BYTES = 20L * 1024 * 1024;
|
||||
|
||||
@Bean
|
||||
public WebServerFactoryCustomizer<ConfigurableUndertowWebServerFactory> undertowUploadLimitCustomizer() {
|
||||
|
||||
@ -2,7 +2,7 @@ server:
|
||||
port: 3000
|
||||
shutdown: graceful
|
||||
undertow:
|
||||
max-http-post-size: 500MB
|
||||
max-http-post-size: 20MB
|
||||
no-request-timeout: 60000
|
||||
|
||||
spring:
|
||||
@ -12,8 +12,8 @@ spring:
|
||||
allow-bean-definition-overriding: true
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 500MB
|
||||
max-request-size: 500MB
|
||||
max-file-size: 20MB
|
||||
max-request-size: 20MB
|
||||
enabled: true
|
||||
profiles:
|
||||
active: @profiles.active@
|
||||
|
||||
@ -32,10 +32,10 @@ public class IpCountryUtils {
|
||||
"香港", "澳门", "澳門", "台湾", "台灣", "Hong Kong", "Macau", "Macao", "Taiwan"
|
||||
);
|
||||
private static final List<String> BLOCKED_COUNTRY_CODES = List.of(
|
||||
"MO", "SG", "TW"
|
||||
"HK", "MO", "SG", "TW"
|
||||
);
|
||||
private static final List<String> BLOCKED_COUNTRY_NAMES = List.of(
|
||||
"澳门", "澳門", "台湾", "台灣", "Macau", "Macao", "Taiwan", "新加坡", "Singapore"
|
||||
"香港", "澳门", "澳門", "台湾", "台灣", "Hong Kong", "Macau", "Macao", "Taiwan", "新加坡", "Singapore"
|
||||
);
|
||||
private static final List<IpGeoProvider> IP_GEO_PROVIDERS = List.of(
|
||||
new IpGeoProvider("ip.sb", "https://api.ip.sb/geoip/%s"),
|
||||
|
||||
@ -69,19 +69,11 @@ public class IpCountryUtilsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allowHongKongRegion() {
|
||||
public void blockHongKongRegion() {
|
||||
IpCountryUtils.IpGeoData data = new IpCountryUtils.IpGeoData("CN", "中国", "香港", "test");
|
||||
|
||||
assertFalse(IpCountryUtils.isMainlandChina(data));
|
||||
assertFalse(IpCountryUtils.isBlockedIpRegion(data));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allowHongKongCountryCode() {
|
||||
IpCountryUtils.IpGeoData data = new IpCountryUtils.IpGeoData("HK", "Hong Kong", "", "test");
|
||||
|
||||
assertFalse(IpCountryUtils.isMainlandChina(data));
|
||||
assertFalse(IpCountryUtils.isBlockedIpRegion(data));
|
||||
assertTrue(IpCountryUtils.isBlockedIpRegion(data));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user