提下麦克风校验优化
This commit is contained in:
parent
2056775fff
commit
85e8973b43
@ -5,6 +5,7 @@ import com.red.circle.framework.core.response.CommonErrorCode;
|
||||
import com.red.circle.framework.core.response.ResponseErrorCode;
|
||||
import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
|
||||
import com.red.circle.other.app.dto.cmd.room.KickOffMicrophoneCmd;
|
||||
import com.red.circle.other.domain.enums.VipAbilityType;
|
||||
import com.red.circle.other.domain.gateway.props.PropsNobleVipGateway;
|
||||
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
|
||||
import com.red.circle.other.infra.database.mongo.entity.sys.ApiOperationLog;
|
||||
@ -42,10 +43,7 @@ public class KickOffMicrophoneCmdExe {
|
||||
private final RoomMemberService roomMemberService;
|
||||
private final UserProfileGateway userProfileGateway;
|
||||
private final AdministratorService administratorService;
|
||||
private final PropsNobleVipGateway propsNobleVipGateway;
|
||||
private final ApiOperationLogService apiOperationLogService;
|
||||
private final UserProfileAppConvertor userProfileAppConvertor;
|
||||
private final PropsVipActualEquityService propsVipActualEquityService;
|
||||
|
||||
public boolean execute(KickOffMicrophoneCmd cmd) {
|
||||
apiOperationLogService.add(
|
||||
@ -74,30 +72,14 @@ public class KickOffMicrophoneCmdExe {
|
||||
ResponseAssert.isFalse(UserErrorCode.NOT_OPERATION_ME,
|
||||
Objects.equals(cmd.getKickUserId(), cmd.requiredReqUserId()));
|
||||
|
||||
boolean kickUserIsSystemAdmin = administratorService.existsAdmin(cmd.getKickUserId());
|
||||
|
||||
if (kickUserIsSystemAdmin) {
|
||||
log.warn("[KickOffMicrophone] Not kick super administrator {}", JacksonUtils.toJson(cmd));
|
||||
// 被踢用户是系统管理员,不允许踢
|
||||
if (administratorService.existsAdmin(cmd.getKickUserId())) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
boolean reqUserIsSystemAdmin = administratorService.existsAdmin(cmd.requiredReqUserId());
|
||||
|
||||
// 允许踢除超级管理员外的任何人
|
||||
if (reqUserIsSystemAdmin) {
|
||||
//发送踢人广播
|
||||
sendKickMsg(cmd, String
|
||||
.format("[KickOffMicrophone]%s: %s 踢 %s",
|
||||
cmd.requireReqSysOriginEnum(),
|
||||
cmd.requiredReqUserId(),
|
||||
cmd.getKickUserId()));
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
// 是否无法将VIP5用户移出房间: true 无法移出
|
||||
if (Boolean.TRUE.equals(notKickOutRoom(cmd.getKickUserId()))) {
|
||||
log.info("[KickOffMicrophone] Can't kick VIP 5 out of the room");
|
||||
ResponseAssert.failure(CommonErrorCode.INSUFFICIENT_PERMISSION,"Insufficient permission");
|
||||
// 被踢用户开启了防踢权限
|
||||
if (userProfileGateway.getUserVipAbility(cmd.getKickUserId(), VipAbilityType.KICK_PREVENTION)) {
|
||||
ResponseAssert.failure(CommonErrorCode.INSUFFICIENT_PERMISSION, "Insufficient permission");
|
||||
}
|
||||
|
||||
Map<Long, RoomUserRolesEnum> rolesMapping = roomMemberService
|
||||
@ -105,8 +87,6 @@ public class KickOffMicrophoneCmdExe {
|
||||
Set.of(cmd.getKickUserId(), cmd.requiredReqUserId()));
|
||||
|
||||
if (CollectionUtils.isEmpty(rolesMapping)) {
|
||||
log.warn("[KickOffMicrophone] Query roles error {},{}", rolesMapping,
|
||||
JacksonUtils.toJson(cmd));
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
@ -114,23 +94,14 @@ public class KickOffMicrophoneCmdExe {
|
||||
RoomUserRolesEnum kickUserRoles = rolesMapping.get(cmd.getKickUserId());
|
||||
|
||||
if (!isHavePermission(operationUserRoles)) {
|
||||
log.warn("[KickOffMicrophone] OperationUserRoles not have permission {},[{} -> {}]",
|
||||
JacksonUtils.toJson(cmd),
|
||||
operationUserRoles, kickUserRoles);
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
if (Objects.equals(RoomUserRolesEnum.HOMEOWNER, kickUserRoles)) {
|
||||
log.warn("[KickOffMicrophone] KickUserRoles is Homeowner {},[{} -> {}]",
|
||||
JacksonUtils.toJson(cmd),
|
||||
operationUserRoles, kickUserRoles);
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
if (Objects.equals(operationUserRoles, kickUserRoles)) {
|
||||
log.warn("[KickOffMicrophone] Not have permission;Equal rights {},[{} -> {}]",
|
||||
JacksonUtils.toJson(cmd),
|
||||
operationUserRoles, kickUserRoles);
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
@ -164,42 +135,4 @@ public class KickOffMicrophoneCmdExe {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 不能被剔除房间
|
||||
*
|
||||
* @return true:无法移除 false:允许移除
|
||||
*/
|
||||
private Boolean notKickOutRoom(Long userId) {
|
||||
|
||||
UserProfileDTO userProfile = userProfileAppConvertor.toUserProfileDTO(
|
||||
userProfileGateway.getByUserId(userId));
|
||||
ResponseAssert.notNull(UserErrorCode.USER_INFO_NOT_FOUND, userProfile);
|
||||
Long wearNobleVipSourceId = getWearNobleVipSourceId(userProfile);
|
||||
|
||||
if (Objects.isNull(wearNobleVipSourceId)) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
if (!propsVipActualEquityService.existsNotExpiredPropsId(wearNobleVipSourceId)) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
PropsNobleVipAbilityDTO vipAbilities = propsNobleVipGateway.getAbilityDTO(
|
||||
wearNobleVipSourceId);
|
||||
if (Objects.isNull(vipAbilities)) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
return Objects.equals(vipAbilities.getVipType(), NobleVipEnum.KING.name()) ||
|
||||
Objects.equals(vipAbilities.getVipType(), NobleVipEnum.EMPEROR.name());
|
||||
}
|
||||
|
||||
private Long getWearNobleVipSourceId(UserProfileDTO userProfile) {
|
||||
return userProfile.filterProps(
|
||||
props -> Objects.nonNull(props.getPropsResources()) && PropsCommodityType.NOBLE_VIP.eq(
|
||||
props.getPropsResources().getType())).stream().findFirst()
|
||||
.map(props -> props.getPropsResources().getId())
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user