code: public Observable<Boolean> handleMessage(final ChatMessage message) {
  
          String sender = message.getSentBy();
  
          Observable<Boolean> replaceMessages = persistenceController.updateStoreWithNewMessage(message, noConversationListener);
  
          if (!TextUtils.isEmpty(sender) && !sender.equals(getProfileId())) {
  
              final Set<String> ids = new HashSet<>();
              ids.add(message.getMessageId());
  
              return Observable.zip(replaceMessages, markDelivered(message.getConversationId(), ids), (saved, result) -> saved && result.isSuccessful());
  
          } else {
  
              return replaceMessages;
          }
      }
docs: Handle incomming message. Replace temporary message with received one and mark as delivered.
  
  @param message Message to save and mark delivered.
  @return Observable with a result.