Conversation conversation = new Conversation(dataFile, messagesFile, encryptionKey); conversation.setState(LEGACY_PENDING); conversation.setConversationToken(legacyConversationToken);
private Conversation loadConversation(ConversationMetadataItem item) throws SerializerException, ConversationLoadException { checkConversationQueue(); // logged-in conversations should use an encryption key which was received from the backend. EncryptionKey conversationEncryptionKey = encryptionKey; if (LOGGED_IN.equals(item.getConversationState())) { conversationEncryptionKey = item.getConversationEncryptionKey(); if (conversationEncryptionKey == null) { throw new ConversationLoadException("Missing conversation encryption key"); } } // TODO: use same serialization logic across the project final Conversation conversation = new Conversation(item.getDataFile(), item.getMessagesFile(), conversationEncryptionKey); conversation.setState(item.getConversationState()); // set the state same as the item's state conversation.setUserId(item.getUserId()); conversation.setConversationToken(item.getConversationToken()); // TODO: this would be overwritten by the next call // try to migrate legacy conversation first boolean migrated = conversation.migrateConversationData(); // if failed - load from encrypted data if (!migrated) { conversation.loadConversationData(); } // check inconsistency conversation.checkInternalConsistency(); return conversation; }