private Mono<Void> saveAndSendMessage0(
            boolean auth,
            boolean send,
            @Nullable Boolean persist,
            @Nullable Long senderId,
            @Nullable DeviceType senderDeviceType,
            @Nullable byte[] senderIp,
            @Nullable Long messageId,
            @NotNull Boolean isGroupMessage,
            @NotNull Boolean isSystemMessage,
            @Nullable String text,
            @Nullable List<byte[]> records,
            @NotNull Long targetId,
            @Nullable @Min(0) Integer burnAfter,
            @Nullable Long referenceId,
            @Nullable Long preMessageId) {
        try {
            Validator.notNull(isGroupMessage, "isGroupMessage");
            Validator.notNull(isSystemMessage, "isSystemMessage");
            Validator.notNull(targetId, "targetId");
            Validator.min(burnAfter, "burnAfter", 0);
            Validator.throwIfAllFalsy("text and records cannot be both null", text, records);
            Validator.maxLength(text, "text", maxTextLimit);
            validRecordsLength(records);
        } catch (ResponseException e) {
            return Mono.error(e);
        }
        if (senderId == null) {
            if (isSystemMessage) {
                senderId = ADMIN_REQUESTER_ID;
            } else {
                return Mono.error(ResponseException.get(ILLEGAL_ARGUMENT,
                        "senderId must not be null for user messages"));
            }
        }
        Date deliveryDate = new Date();
        Mono<MessageAndRecipientIds> saveMono;
        if (auth) {
            saveMono = referenceId == null
                    ? authAndSaveMessage(send,
                            persist,
                            messageId,
                            senderId,
                            senderIp,
                            targetId,
                            isGroupMessage,
                            isSystemMessage,
                            text,
                            records,
                            burnAfter,
                            deliveryDate,
                            null,
                            preMessageId)
                    : authAndCloneAndSaveMessage(send,
                            senderId,
                            senderIp,
                            referenceId,
                            isGroupMessage,
                            isSystemMessage,
                            targetId);
        } else {
            saveMono = referenceId == null
                    ? saveMessage(send,
                            persist,
                            messageId,
                            senderId,
                            senderIp,
                            targetId,
                            isGroupMessage,
                            isSystemMessage,
                            text,
                            records,
                            burnAfter,
                            deliveryDate,
                            null,
                            preMessageId)
                    : cloneAndSaveMessage(send,
                            senderId,
                            senderIp,
                            referenceId,
                            isGroupMessage,
                            isSystemMessage,
                            targetId);
        }
        return saveMono.doOnNext(pair -> {
            Message message = pair.message();
            sentMessageCounter.increment();
            Long msgId = message == null
                    ? null
                    : message.getId();
            if (msgId != null && sentMessageCache != null) {
                cacheSentMessage(message);
            }
            if (send) {
                // No need to let the client wait to send notifications to recipients
                Set<Long> recipientIds = pair.recipientIds();
                sendMessage(message, recipientIds, senderDeviceType).subscribe(null,
                        t -> LOGGER.error("Failed to send the message ({}) to the recipients: {}",
                                msgId,
                                recipientIds,
                                t));
            }
        })
                .then();
    }
@return {@link reactor.core.publisher.MonoEmpty} if {@link MessageProperties#persistMessage}
        is false and no recipient.
        <p>
        {@link MessageAndRecipientIds#message} is null if
        {@link MessageProperties#persistMessage} is false.
turms-service/src/main/java/im/turms/service/domain/message/service/MessageService.java