Merge branch 'main' into codex/update-usercontroller-for-user-data-retrieval

This commit is contained in:
Tim
2025-07-01 13:24:28 +08:00
committed by GitHub
4 changed files with 81 additions and 62 deletions

View File

@@ -1,25 +1,33 @@
# for mysql
spring.datasource.url=${MYSQL_URL:jdbc:mysql://localhost:3306/openisle}
spring.datasource.username=${MYSQL_USER:root}
spring.datasource.password=${MYSQL_PASSWORD:password}
spring.jpa.hibernate.ddl-auto=update
resend.api.key=${RESEND_API_KEY:}
cos.base-url=${COS_BASE_URL:https://example.com}
cos.secret-id=${COS_SECRET_ID:}
cos.secret-key=${COS_SECRET_KEY:}
cos.region=${COS_REGION:ap-guangzhou}
cos.bucket-name=${COS_BUCKET_NAME:}
# Image upload configuration
app.upload.check-type=${UPLOAD_CHECK_TYPE:true}
app.upload.max-size=${UPLOAD_MAX_SIZE:5242880}
# for jwt
app.jwt.secret=${JWT_SECRET:ChangeThisSecretKeyForJwt}
app.jwt.expiration=${JWT_EXPIRATION:86400000}
# Post publish mode: DIRECT or REVIEW
app.post.publish-mode=${POST_PUBLISH_MODE:DIRECT}
# Image upload configuration
app.upload.check-type=${UPLOAD_CHECK_TYPE:true}
app.upload.max-size=${UPLOAD_MAX_SIZE:5242880}
# Default list size for user posts and replies
app.user.posts-limit=${USER_POSTS_LIMIT:10}
app.user.replies-limit=${USER_REPLIES_LIMIT:50}
# ========= Optional =========
# for resend email send service, you can improve your service by yourself
resend.api.key=${RESEND_API_KEY:}
# your email services: ...
# for tencent cloud image upload service, you can improve your service by yourself
cos.base-url=${COS_BASE_URL:https://example.com}
cos.secret-id=${COS_SECRET_ID:}
cos.secret-key=${COS_SECRET_KEY:}
cos.region=${COS_REGION:ap-guangzhou}
cos.bucket-name=${COS_BUCKET_NAME:}
# your image upload services: ...

View File

@@ -58,6 +58,12 @@ class PublishModeIntegrationTest {
return rest.exchange(url, HttpMethod.POST, new HttpEntity<>(body, h), Map.class);
}
private <T> ResponseEntity<T> get(String url, Class<T> type, String token) {
HttpHeaders h = new HttpHeaders();
if (token != null) h.setBearerAuth(token);
return rest.exchange(url, HttpMethod.GET, new HttpEntity<>(h), type);
}
@Test
void postRequiresApproval() {
String userToken = registerAndLogin("eve", "e@example.com");
@@ -74,7 +80,7 @@ class PublishModeIntegrationTest {
List<?> list = rest.getForObject("/api/posts", List.class);
assertTrue(list.isEmpty(), "Post should not be listed before approval");
List<Map<String, Object>> pending = (List<Map<String, Object>>) rest.getForObject("/api/admin/posts/pending", List.class);
List<Map<String, Object>> pending = get("/api/admin/posts/pending", List.class, adminToken).getBody();
assertEquals(1, pending.size());
assertEquals(postId.intValue(), ((Number)pending.get(0).get("id")).intValue());

View File

@@ -16,6 +16,6 @@ class CosImageUploaderTest {
String url = uploader.upload("data".getBytes(), "img.png").join();
verify(client).putObject(any(PutObjectRequest.class));
assertEquals("http://cos.example.com/img.png", url);
assertTrue(url.matches("http://cos.example.com/[a-f0-9]{32}\\.png"));
}
}