违规提示阿语区处理
This commit is contained in:
parent
4bb1da87e4
commit
b3d3e276ea
@ -14,6 +14,7 @@ import com.red.circle.other.app.enums.violation.TargetTypeEnum;
|
||||
import com.red.circle.other.app.enums.violation.ViolationTypeEnum;
|
||||
import com.red.circle.other.app.service.room.RoomThemeService;
|
||||
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
|
||||
import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway;
|
||||
import com.red.circle.other.domain.gateway.violation.ViolationRecordGateway;
|
||||
import com.red.circle.other.domain.model.user.UserProfile;
|
||||
import com.red.circle.other.domain.violation.ViolationRecord;
|
||||
@ -51,6 +52,7 @@ public class RoomViolationAdjustCmdExe {
|
||||
private final RoomProfileManagerService roomProfileManagerService;
|
||||
private final AdministratorAuthService administratorAuthService;
|
||||
private final OfficialNoticeClient officialNoticeClient;
|
||||
private final UserRegionGateway userRegionGateway;
|
||||
private final UserProfileGateway userProfileGateway;
|
||||
private final EnumConfigCacheService enumConfigCacheService;
|
||||
private final AdministratorService administratorService;
|
||||
@ -182,7 +184,7 @@ public class RoomViolationAdjustCmdExe {
|
||||
* 发送调整通知
|
||||
*/
|
||||
private void sendAdjustNotification(Long userId, ViolationTypeEnum violationType, String adjustedContent) {
|
||||
String content = getAdjustNotificationContent(violationType, adjustedContent);
|
||||
String content = getAdjustNotificationContent(userId, violationType, adjustedContent);
|
||||
|
||||
Map<String, Object> titleMap = new HashMap<>();
|
||||
titleMap.put("type", "violation_adjust");
|
||||
@ -200,13 +202,35 @@ public class RoomViolationAdjustCmdExe {
|
||||
/**
|
||||
* 获取调整通知内容
|
||||
*/
|
||||
private String getAdjustNotificationContent(ViolationTypeEnum violationType, String adjustedContent) {
|
||||
private String getAdjustNotificationContent(Long userId, ViolationTypeEnum violationType, String adjustedContent) {
|
||||
boolean isArabic = isArabicRegion(userId);
|
||||
|
||||
return switch (violationType) {
|
||||
case ROOM_NICKNAME -> String.format("Your room name has been changed to '%s' due to violation of rules.", adjustedContent);
|
||||
case ROOM_COVER -> "Your room profile picture has been changed to the default image due to violation of rules.";
|
||||
case ROOM_NOTICE -> String.format("Your room notice has been changed to '%s' due to violation of regulations.", adjustedContent);
|
||||
case ROOM_THEME -> "Your room theme has been changed to the default theme due to violation of rules.";
|
||||
default -> "Your room information has been adjusted due to violation of rules.";
|
||||
case ROOM_NICKNAME -> isArabic ?
|
||||
String.format("تم تغيير اسم الغرفة إلى '%s' بسبب انتهاك القواعد.", adjustedContent) :
|
||||
String.format("Your room name has been changed to '%s' due to violation of rules.", adjustedContent);
|
||||
case ROOM_COVER -> isArabic ?
|
||||
"تم تغيير صورة ملف الغرفة إلى الصورة الافتراضية بسبب انتهاك القواعد." :
|
||||
"Your room profile picture has been changed to the default image due to violation of rules.";
|
||||
case ROOM_NOTICE -> isArabic ?
|
||||
String.format("تم تغيير إشعار الغرفة إلى '%s' بسبب انتهاك اللوائح.", adjustedContent) :
|
||||
String.format("Your room notice has been changed to '%s' due to violation of regulations.", adjustedContent);
|
||||
case ROOM_THEME -> isArabic ?
|
||||
"تم تغيير سمة الغرفة إلى السمة الافتراضية بسبب انتهاك القواعد." :
|
||||
"Your room theme has been changed to the default theme due to violation of rules.";
|
||||
default -> isArabic ?
|
||||
"تم تعديل معلومات الغرفة بسبب انتهاك القواعد." :
|
||||
"Your room information has been adjusted due to violation of rules.";
|
||||
};
|
||||
}
|
||||
|
||||
private boolean isArabicRegion(Long userId) {
|
||||
String regionCode = userRegionGateway.getRegionConfigByUserId(userId).getRegionCode();
|
||||
try {
|
||||
return "ar".equalsIgnoreCase(regionCode);
|
||||
} catch (Exception e) {
|
||||
log.warn("Failed to get user region, userId={}", userId, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@ import com.red.circle.other.domain.violation.ViolationRecord;
|
||||
import com.red.circle.other.infra.database.mongo.entity.live.RoomProfile;
|
||||
import com.red.circle.other.infra.database.mongo.service.live.RoomProfileManagerService;
|
||||
import com.red.circle.other.infra.database.rds.service.sys.AdministratorAuthService;
|
||||
import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway;
|
||||
import com.red.circle.other.infra.database.rds.service.sys.AdministratorService;
|
||||
import com.red.circle.other.inner.asserts.RoomErrorCode;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -39,6 +40,7 @@ public class RoomViolationWarningCmdExe {
|
||||
private final RoomProfileManagerService roomProfileManagerService;
|
||||
private final AdministratorAuthService administratorAuthService;
|
||||
private final OfficialNoticeClient officialNoticeClient;
|
||||
private final UserRegionGateway userRegionGateway;
|
||||
private final UserProfileGateway userProfileGateway;
|
||||
private final AdministratorService administratorService;
|
||||
|
||||
@ -101,7 +103,7 @@ public class RoomViolationWarningCmdExe {
|
||||
* 发送警告消息
|
||||
*/
|
||||
private void sendWarningMessage(Long userId, ViolationTypeEnum violationType) {
|
||||
String content = getWarningContent(violationType);
|
||||
String content = getWarningContent(userId, violationType);
|
||||
|
||||
Map<String, Object> titleMap = new HashMap<>();
|
||||
titleMap.put("type", "violation_warning");
|
||||
@ -119,13 +121,34 @@ public class RoomViolationWarningCmdExe {
|
||||
/**
|
||||
* 获取警告内容
|
||||
*/
|
||||
private String getWarningContent(ViolationTypeEnum violationType) {
|
||||
private String getWarningContent(Long userId, ViolationTypeEnum violationType) {
|
||||
boolean isArabic = isArabicRegion(userId);
|
||||
|
||||
return switch (violationType) {
|
||||
case ROOM_NICKNAME -> "Your room name is in violation of the rules. Please correct the current room name immediately.";
|
||||
case ROOM_COVER -> "Your room profile picture violates the rules. Please change your current room profile picture immediately.";
|
||||
case ROOM_NOTICE -> "Your room notice is in violation of regulations. Please rectify it immediately.";
|
||||
case ROOM_THEME -> "Your room theme violates the rules. Please rectify it immediately.";
|
||||
default -> "Your room information is in violation of the rules. Please correct it immediately.";
|
||||
case ROOM_NICKNAME -> isArabic ?
|
||||
"اسم الغرفة ينتهك القواعد. يرجى تصحيح اسم الغرفة الحالي على الفور." :
|
||||
"Your room name is in violation of the rules. Please correct the current room name immediately.";
|
||||
case ROOM_COVER -> isArabic ?
|
||||
"صورة ملف الغرفة تنتهك القواعد. يرجى تغيير صورة ملف الغرفة الحالية على الفور." :
|
||||
"Your room profile picture violates the rules. Please change your current room profile picture immediately.";
|
||||
case ROOM_NOTICE -> isArabic ?
|
||||
"إشعار الغرفة ينتهك اللوائح. يرجى تصحيحه على الفور." :
|
||||
"Your room notice is in violation of regulations. Please rectify it immediately.";
|
||||
case ROOM_THEME -> isArabic ?
|
||||
"سمة الغرفة تنتهك القواعد. يرجى تصحيحها على الفور." :
|
||||
"Your room theme violates the rules. Please rectify it immediately.";
|
||||
default -> isArabic ?
|
||||
"معلومات الغرفة تنتهك القواعد. يرجى تصحيحها على الفور." :
|
||||
"Your room information is in violation of the rules. Please correct it immediately.";
|
||||
};
|
||||
}
|
||||
|
||||
private boolean isArabicRegion(Long userId) {
|
||||
try {
|
||||
return "ar".equalsIgnoreCase(userRegionGateway.getRegionConfigByUserId(userId).getRegionName());
|
||||
} catch (Exception e) {
|
||||
log.warn("Failed to get user region, userId={}", userId, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@ import com.red.circle.other.app.enums.violation.TargetTypeEnum;
|
||||
import com.red.circle.other.app.enums.violation.ViolationTypeEnum;
|
||||
import com.red.circle.other.domain.gateway.violation.ViolationRecordGateway;
|
||||
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
|
||||
import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway;
|
||||
import com.red.circle.other.domain.model.user.UserProfile;
|
||||
import com.red.circle.other.domain.violation.ViolationRecord;
|
||||
import com.red.circle.other.infra.database.cache.service.other.EnumConfigCacheService;
|
||||
@ -45,6 +46,7 @@ public class UserViolationAdjustCmdExe {
|
||||
private final OfficialNoticeClient officialNoticeClient;
|
||||
private final EnumConfigCacheService enumConfigCacheService;
|
||||
private final AdministratorService administratorService;
|
||||
private final UserRegionGateway userRegionGateway;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ViolationHandleResultCO execute(UserViolationHandleCmd cmd) {
|
||||
@ -128,7 +130,7 @@ public class UserViolationAdjustCmdExe {
|
||||
}
|
||||
|
||||
private void sendAdjustMessage(Long userId, ViolationTypeEnum violationType) {
|
||||
String content = buildAdjustContent(violationType);
|
||||
String content = buildAdjustContent(userId, violationType);
|
||||
officialNoticeClient.send(
|
||||
NoticeExtTemplateCustomizeCmd.builder()
|
||||
.toAccount(userId)
|
||||
@ -138,14 +140,32 @@ public class UserViolationAdjustCmdExe {
|
||||
.build());
|
||||
}
|
||||
|
||||
private String buildAdjustContent(ViolationTypeEnum violationType) {
|
||||
private String buildAdjustContent(Long userId, ViolationTypeEnum violationType) {
|
||||
// 获取用户区域信息
|
||||
boolean isArabic = isArabicRegion(userId);
|
||||
|
||||
switch (violationType) {
|
||||
case USER_NICKNAME:
|
||||
return "Your username has been adjusted due to rule violations. Please update your username as soon as possible.";
|
||||
return isArabic ?
|
||||
"تم تعديل اسم المستخدم الخاص بك بسبب انتهاك القواعد. يرجى تحديث اسم المستخدم الخاص بك في أقرب وقت ممكن." :
|
||||
"Your username has been adjusted due to rule violations. Please update your username as soon as possible.";
|
||||
case USER_AVATAR:
|
||||
return "Your profile picture has been adjusted due to rule violations. Please update your profile picture as soon as possible.";
|
||||
return isArabic ?
|
||||
"تم تعديل صورة ملفك الشخصي بسبب انتهاك القواعد. يرجى تحديث صورة ملفك الشخصي في أقرب وقت ممكن." :
|
||||
"Your profile picture has been adjusted due to rule violations. Please update your profile picture as soon as possible.";
|
||||
default:
|
||||
return "Your information has been adjusted due to rule violations. Please update it as soon as possible.";
|
||||
return isArabic ?
|
||||
"تم تعديل معلوماتك بسبب انتهاك القواعد. يرجى تحديثها في أقرب وقت ممكن." :
|
||||
"Your information has been adjusted due to rule violations. Please update it as soon as possible.";
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isArabicRegion(Long userId) {
|
||||
try {
|
||||
return "ar".equalsIgnoreCase(userRegionGateway.getRegionConfigByUserId(userId).getRegionName());
|
||||
} catch (Exception e) {
|
||||
log.warn("Failed to get user region, userId={}", userId, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -13,6 +13,7 @@ import com.red.circle.other.app.enums.violation.TargetTypeEnum;
|
||||
import com.red.circle.other.app.enums.violation.ViolationTypeEnum;
|
||||
import com.red.circle.other.domain.gateway.violation.ViolationRecordGateway;
|
||||
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
|
||||
import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway;
|
||||
import com.red.circle.other.domain.model.user.UserProfile;
|
||||
import com.red.circle.other.domain.violation.ViolationRecord;
|
||||
import com.red.circle.other.infra.database.rds.service.sys.AdministratorAuthService;
|
||||
@ -42,6 +43,7 @@ public class UserViolationWarningCmdExe {
|
||||
private final AdministratorAuthService administratorAuthService;
|
||||
private final AdministratorService administratorService;
|
||||
private final OfficialNoticeClient officialNoticeClient;
|
||||
private final UserRegionGateway userRegionGateway;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ViolationHandleResultCO execute(UserViolationHandleCmd cmd) {
|
||||
@ -91,7 +93,7 @@ public class UserViolationWarningCmdExe {
|
||||
}
|
||||
|
||||
private void sendWarningMessage(Long userId, ViolationTypeEnum violationType) {
|
||||
String content = buildWarningContent(violationType);
|
||||
String content = buildWarningContent(userId, violationType);
|
||||
officialNoticeClient.send(
|
||||
NoticeExtTemplateCustomizeCmd.builder()
|
||||
.toAccount(userId)
|
||||
@ -101,14 +103,32 @@ public class UserViolationWarningCmdExe {
|
||||
.build());
|
||||
}
|
||||
|
||||
private String buildWarningContent(ViolationTypeEnum violationType) {
|
||||
private String buildWarningContent(Long userId, ViolationTypeEnum violationType) {
|
||||
// 获取用户区域信息
|
||||
boolean isArabic = isArabicRegion(userId);
|
||||
|
||||
switch (violationType) {
|
||||
case USER_NICKNAME:
|
||||
return "Your username is in violation of the rules. Please correct the current username immediately.";
|
||||
return isArabic ?
|
||||
"اسم المستخدم الخاص بك ينتهك القواعد. يرجى تصحيح اسم المستخدم الحالي على الفور." :
|
||||
"Your username is in violation of the rules. Please correct the current username immediately.";
|
||||
case USER_AVATAR:
|
||||
return "Your user profile picture is in violation of the rules. Please correct your current user profile picture immediately.";
|
||||
return isArabic ?
|
||||
"صورة ملفك الشخصي تنتهك القواعد. يرجى تصحيح صورة ملفك الشخصي الحالية على الفور." :
|
||||
"Your user profile picture is in violation of the rules. Please correct your current user profile picture immediately.";
|
||||
default:
|
||||
return "Your information violates the rules. Please correct it immediately.";
|
||||
return isArabic ?
|
||||
"معلوماتك تنتهك القواعد. يرجى تصحيحها على الفور." :
|
||||
"Your information violates the rules. Please correct it immediately.";
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isArabicRegion(Long userId) {
|
||||
try {
|
||||
return "ar".equalsIgnoreCase(userRegionGateway.getRegionConfigByUserId(userId).getRegionName());
|
||||
} catch (Exception e) {
|
||||
log.warn("Failed to get user region, userId={}", userId, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user