mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-24 07:00:49 +08:00
feat: email fix & default avatar
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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"));
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user