public Mono<HandleHandleGroupJoinRequestResult> authAndHandleJoinRequest(
            @NotNull Long requesterId,
            @NotNull Long joinRequestId,
            @NotNull @ValidResponseAction ResponseAction action,
            @Nullable String responseReason) {
        try {
            Validator.notNull(requesterId, "requesterId");
            Validator.notNull(joinRequestId, "joinRequestId");
            Validator.notNull(action, "action");
            DataValidator.validResponseAction(action);
            Validator.maxLength(responseReason, "responseReason", maxResponseReasonLength);
        } catch (ResponseException e) {
            return Mono.error(e);
        }
        return groupJoinRequestRepository.findById(joinRequestId)
                // If the requester is not authorized to the join request,
                // they should not know the status of the join request from the error code.
                // So we should not tell if the join request exists or not.
                .switchIfEmpty(Mono.error(ResponseException.get(
                        ResponseStatusCode.NOT_GROUP_OWNER_OR_MANAGER_TO_UPDATE_GROUP_JOIN_REQUEST)))
                .flatMap(joinRequest ->
                // If the requester is not authorized to the join request,
                // they should not know the status of the join request from the error code.
                // So we check whether the requester is authorized first.
                groupMemberService.isOwnerOrManager(requesterId, joinRequest.getGroupId(), false)
                        .flatMap(isOwnerOrManager -> {
                            if (!isOwnerOrManager) {
                                return Mono.error(ResponseException.get(
                                        ResponseStatusCode.NOT_GROUP_OWNER_OR_MANAGER_TO_UPDATE_GROUP_JOIN_REQUEST));
                            }
                            RequestStatus status = joinRequest.getStatus();
                            if (status == RequestStatus.PENDING) {
                                if (groupJoinRequestRepository
                                        .isExpired(joinRequest.getCreationDate()
                                                .getTime())) {
                                    return Mono.error(ResponseException.get(
                                            ResponseStatusCode.UPDATE_NON_PENDING_GROUP_JOIN_REQUEST,
                                            "The join request is under the status "
                                                    + RequestStatus.EXPIRED));
                                }
                            } else {
                                return Mono.error(ResponseException.get(
                                        ResponseStatusCode.UPDATE_NON_PENDING_GROUP_JOIN_REQUEST,
                                        "The join request is under the status "
                                                + status));
                            }
                            return switch (action) {
                                case ACCEPT -> groupJoinRequestRepository
                                        .inTransaction(session -> updatePendingJoinRequestStatus(
                                                joinRequest.getGroupId(),
                                                joinRequestId,
                                                RequestStatus.ACCEPTED,
                                                requesterId,
                                                responseReason,
                                                session)
                                                .then(groupMemberService
                                                        .addGroupMember(joinRequest.getGroupId(),
                                                                joinRequest.getRequesterId(),
                                                                GroupMemberRole.MEMBER,
                                                                null,
                                                                null,
                                                                null,
                                                                session)
                                                        .thenReturn(
                                                                new HandleHandleGroupJoinRequestResult(
                                                                        joinRequest,
                                                                        true))
                                                        .onErrorResume(DuplicateKeyException.class,
                                                                e -> Mono.just(
                                                                        new HandleHandleGroupJoinRequestResult(
                                                                                joinRequest,
                                                                                false)))))
                                        .retryWhen(TRANSACTION_RETRY);
                                case IGNORE ->
                                    updatePendingJoinRequestStatus(joinRequest.getGroupId(),
                                            joinRequestId,
                                            RequestStatus.IGNORED,
                                            requesterId,
                                            responseReason,
                                            null)
                                            .thenReturn(new HandleHandleGroupJoinRequestResult(
                                                    joinRequest,
                                                    false));
                                case DECLINE ->
                                    updatePendingJoinRequestStatus(joinRequest.getGroupId(),
                                            joinRequestId,
                                            RequestStatus.DECLINED,
                                            requesterId,
                                            responseReason,
                                            null)
                                            .thenReturn(new HandleHandleGroupJoinRequestResult(
                                                    joinRequest,
                                                    false));
                                default -> Mono.error(
                                        ResponseException.get(ResponseStatusCode.ILLEGAL_ARGUMENT,
                                                "The response action must not be UNRECOGNIZED"));
                            };
                        }));
    }
@return requester ID, group ID, and status
turms-service/src/main/java/im/turms/service/domain/group/service/GroupJoinRequestService.java