diff --git a/build.gradle b/build.gradle index 7f046d8..859e80a 100644 --- a/build.gradle +++ b/build.gradle @@ -138,7 +138,7 @@ subprojects { entry 'slf4j-simple' } - dependency 'ch.dissem.msgpack:msgpack:1.0.0' + dependency 'ch.dissem.msgpack:msgpack:2.0.0' dependency 'org.bouncycastle:bcprov-jdk15on:1.57' dependency 'com.madgag.spongycastle:prov:1.56.0.0' dependency 'org.apache.commons:commons-lang3:3.6' diff --git a/core/src/main/kotlin/ch/dissem/bitmessage/DefaultMessageListener.kt b/core/src/main/kotlin/ch/dissem/bitmessage/DefaultMessageListener.kt index ad32bf9..c7c5efe 100644 --- a/core/src/main/kotlin/ch/dissem/bitmessage/DefaultMessageListener.kt +++ b/core/src/main/kotlin/ch/dissem/bitmessage/DefaultMessageListener.kt @@ -156,8 +156,10 @@ open class DefaultMessageListener( } msg.inventoryVector = iv - labeler.setLabels(msg) try { + ctx.messageRepository.save(msg) + // We might need the ID here, so we need to add the labels and save it again + labeler.setLabels(msg) ctx.messageRepository.save(msg) listener.receive(msg) diff --git a/core/src/main/kotlin/ch/dissem/bitmessage/ports/DefaultLabeler.kt b/core/src/main/kotlin/ch/dissem/bitmessage/ports/DefaultLabeler.kt index 32ed6fa..01d54d6 100644 --- a/core/src/main/kotlin/ch/dissem/bitmessage/ports/DefaultLabeler.kt +++ b/core/src/main/kotlin/ch/dissem/bitmessage/ports/DefaultLabeler.kt @@ -35,7 +35,7 @@ open class DefaultLabeler : Labeler, InternalContext.ContextHolder { msg.status = RECEIVED val labelsToAdd = if (msg.type == BROADCAST) { - ctx.messageRepository.getLabels(Label.Type.INBOX, Label.Type.BROADCAST, Label.Type.UNREAD) + ctx.messageRepository.getLabels(Label.Type.BROADCAST, Label.Type.UNREAD) } else { ctx.messageRepository.getLabels(Label.Type.INBOX, Label.Type.UNREAD) } @@ -89,7 +89,7 @@ open class DefaultLabeler : Labeler, InternalContext.ContextHolder { } override fun delete(msg: Plaintext) { - val labelsToRemove = msg.labels.filterNot { it.type == Label.Type.TRASH } + val labelsToRemove = msg.labels.toSet() msg.labels.clear() val labelsToAdd = ctx.messageRepository.getLabels(Label.Type.TRASH) msg.addLabels(labelsToAdd)