🚀 Improve performance
This commit is contained in:
@ -65,7 +65,7 @@ class Plaintext private constructor(
|
||||
val message: ByteArray,
|
||||
val ackData: ByteArray?,
|
||||
ackMessage: Lazy<ObjectMessage?> = lazy { Factory.createAck(from, ackData, ttl) },
|
||||
val conversationId: UUID = UUID.randomUUID(),
|
||||
var conversationId: UUID = UUID.randomUUID(),
|
||||
var inventoryVector: InventoryVector? = null,
|
||||
var signature: ByteArray? = null,
|
||||
sent: Long? = null,
|
||||
|
@ -109,8 +109,8 @@ abstract class AbstractMessageRepository : MessageRepository, InternalContext.Co
|
||||
return find("iv IN (SELECT child FROM Message_Parent WHERE parent=X'${Strings.hex(parent.inventoryVector!!.hash)}')")
|
||||
}
|
||||
|
||||
override fun getConversation(conversationId: UUID): List<Plaintext> {
|
||||
return find("conversation=X'${conversationId.toString().replace("-", "")}'")
|
||||
override fun getConversation(conversationId: UUID, offset: Int, limit: Int): List<Plaintext> {
|
||||
return find("conversation=X'${conversationId.toString().replace("-", "")}'", offset, limit)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -68,5 +68,5 @@ interface MessageRepository {
|
||||
* *
|
||||
* @return all messages with the given conversation ID
|
||||
*/
|
||||
fun getConversation(conversationId: UUID): Collection<Plaintext>
|
||||
fun getConversation(conversationId: UUID, offset: Int = 0, limit: Int = 0): Collection<Plaintext>
|
||||
}
|
||||
|
@ -33,8 +33,9 @@ class ConversationService(private val messageRepository: MessageRepository) {
|
||||
|
||||
private val SUBJECT_PREFIX = Pattern.compile("^(re|fwd?):\\s*", CASE_INSENSITIVE)
|
||||
|
||||
fun findConversations(label: Label?, offset: Int = 0, limit: Int = 0) = messageRepository.findConversations(label, offset, limit)
|
||||
.map { getConversation(it) }
|
||||
fun findConversations(label: Label?, offset: Int = 0, limit: Int = 0, conversationLimit: Int = 10) =
|
||||
messageRepository.findConversations(label, offset, limit)
|
||||
.map { getConversation(it, conversationLimit) }
|
||||
|
||||
/**
|
||||
* Retrieve the whole conversation from one single message. If the message isn't part
|
||||
@ -62,8 +63,8 @@ class ConversationService(private val messageRepository: MessageRepository) {
|
||||
return result
|
||||
}
|
||||
|
||||
fun getConversation(conversationId: UUID): Conversation {
|
||||
val messages = sorted(messageRepository.getConversation(conversationId))
|
||||
fun getConversation(conversationId: UUID, limit: Int = 0): Conversation {
|
||||
val messages = sorted(messageRepository.getConversation(conversationId, 0, limit))
|
||||
val map = HashMap<InventoryVector, Plaintext>(messages.size)
|
||||
for (message in messages) {
|
||||
message.inventoryVector?.let {
|
||||
|
Reference in New Issue
Block a user