feat: email fix & default avatar

This commit is contained in:
Tim
2025-07-30 14:47:10 +08:00
parent 8efdd5a50d
commit e27c821d80
7 changed files with 15 additions and 15 deletions

View File

@@ -22,7 +22,7 @@ public class AdminUserController {
User user = userRepository.findById(id).orElseThrow();
user.setApproved(true);
userRepository.save(user);
emailSender.sendEmail(user.getEmail(), "【OpenIsle】您的注册已审核通过",
emailSender.sendEmail(user.getEmail(), "您的注册已审核通过",
"🎉您的注册已经审核通过, 点击以访问网站: " + websiteUrl);
return ResponseEntity.ok().build();
}
@@ -32,7 +32,7 @@ public class AdminUserController {
User user = userRepository.findById(id).orElseThrow();
user.setApproved(false);
userRepository.save(user);
emailSender.sendEmail(user.getEmail(), "【OpenIsle】您的注册已被管理员拒绝",
emailSender.sendEmail(user.getEmail(), "您的注册已被管理员拒绝",
"您的注册被管理员拒绝, 点击链接可以重新填写理由申请: " + websiteUrl);
return ResponseEntity.ok().build();
}

View File

@@ -56,7 +56,7 @@ public class AuthController {
}
User user = userService.register(
req.getUsername(), req.getEmail(), req.getPassword(), "", registerModeService.getRegisterMode());
emailService.sendEmail(user.getEmail(), "【OpenIsle】在网站填写验证码以验证", "您的验证码是 " + user.getVerificationCode());
emailService.sendEmail(user.getEmail(), "在网站填写验证码以验证", "您的验证码是 " + user.getVerificationCode());
if (!user.isApproved()) {
notificationService.createRegisterRequestNotifications(user, user.getRegisterReason());
}
@@ -92,7 +92,7 @@ public class AuthController {
User user = userOpt.get();
if (!user.isVerified()) {
user = userService.register(user.getUsername(), user.getEmail(), user.getPassword(), user.getRegisterReason(), registerModeService.getRegisterMode());
emailService.sendEmail(user.getEmail(), "【OpenIsle】在网站填写验证码以验证", "您的验证码是 " + user.getVerificationCode());
emailService.sendEmail(user.getEmail(), "在网站填写验证码以验证", "您的验证码是 " + user.getVerificationCode());
return ResponseEntity.badRequest().body(Map.of(
"error", "User not verified",
"reason_code", "NOT_VERIFIED",
@@ -279,7 +279,7 @@ public class AuthController {
return ResponseEntity.badRequest().body(Map.of("error", "User not found"));
}
String code = userService.generatePasswordResetCode(req.getEmail());
emailService.sendEmail(req.getEmail(), "【OpenIsle】请填写验证码以重置密码", "您的验证码是" + code);
emailService.sendEmail(req.getEmail(), "请填写验证码以重置密码", "您的验证码是" + code);
return ResponseEntity.ok(Map.of("message", "Verification code sent"));
}

View File

@@ -9,13 +9,13 @@ import java.nio.charset.StandardCharsets;
@Service
public class AvatarGenerator {
@Value("${app.avatar.base-url:https://api.dicebear.com/6.x}")
@Value("${app.avatar.base-url}")
private String baseUrl;
@Value("${app.avatar.style:identicon}")
@Value("${app.avatar.style}")
private String style;
@Value("${app.avatar.size:64}")
@Value("${app.avatar.size}")
private int size;
public String generate(String seed) {

View File

@@ -66,7 +66,7 @@ public class NotificationService {
if (type == NotificationType.COMMENT_REPLY && user.getEmail() != null && post != null && comment != null) {
String url = String.format("%s/posts/%d#comment-%d", websiteUrl, post.getId(), comment.getId());
String pushContent = comment.getAuthor() + "回复了你: \"" + comment.getContent() + "\"";
emailSender.sendEmail(user.getEmail(), "【OpenIsle】您有新的回复", pushContent + ", 点击以查看: " + url);
emailSender.sendEmail(user.getEmail(), "您有新的回复", pushContent + ", 点击以查看: " + url);
sendCustomPush(user, pushContent, url);
} else if (type == NotificationType.REACTION && comment != null) {
long count = reactionRepository.countReceived(comment.getAuthor().getUsername());
@@ -74,7 +74,7 @@ public class NotificationService {
String url = websiteUrl + "/messages";
sendCustomPush(comment.getAuthor(), "你有新的互动", url);
if (comment.getAuthor().getEmail() != null) {
emailSender.sendEmail(comment.getAuthor().getEmail(), "【OpenIsle】你有新的互动", "你有新的互动, 点击以查看: " + url);
emailSender.sendEmail(comment.getAuthor().getEmail(), "你有新的互动", "你有新的互动, 点击以查看: " + url);
}
}
} else if (type == NotificationType.REACTION && post != null) {
@@ -83,7 +83,7 @@ public class NotificationService {
String url = websiteUrl + "/messages";
sendCustomPush(post.getAuthor(), "你有新的互动", url);
if (post.getAuthor().getEmail() != null) {
emailSender.sendEmail(post.getAuthor().getEmail(), "【OpenIsle】你有新的互动", "你有新的互动, 点击以查看: " + url);
emailSender.sendEmail(post.getAuthor().getEmail(), "你有新的互动", "你有新的互动, 点击以查看: " + url);
}
}
}

View File

@@ -25,8 +25,8 @@ app.upload.check-type=${UPLOAD_CHECK_TYPE:true}
app.upload.max-size=${UPLOAD_MAX_SIZE:5242880}
# Default avatar generator configuration
app.avatar.style=${AVATAR_STYLE:identicon}
app.avatar.size=${AVATAR_SIZE:64}
app.avatar.style=${AVATAR_STYLE:pixel-art-neutral}
app.avatar.size=${AVATAR_SIZE:128}
app.avatar.base-url=${AVATAR_BASE_URL:https://api.dicebear.com/6.x}
# Default list size for user posts and replies

View File

@@ -172,7 +172,7 @@ class NotificationServiceTest {
service.createNotification(user, NotificationType.COMMENT_REPLY, post, comment, null, null, null, null);
verify(email).sendEmail("a@a.com", "【OpenIsle】有人回复了你", "https://ex.com/posts/1#comment-2");
verify(email).sendEmail("a@a.com", "有人回复了你", "https://ex.com/posts/1#comment-2");
verify(push).sendNotification(eq(user), contains("/posts/1#comment-2"));
}
}

View File

@@ -38,7 +38,7 @@ class ReactionServiceTest {
service.reactToPost("bob", 3L, ReactionType.LIKE);
verify(email).sendEmail("a@a.com", "【OpenIsle】你有新的互动", "https://ex.com/messages");
verify(email).sendEmail("a@a.com", "你有新的互动", "https://ex.com/messages");
verify(notif).sendCustomPush(author, "你有新的互动", "https://ex.com/messages");
}
}