Improved the labeler and bumped the msgpack library to 2.0.0

This commit is contained in:
Christian Basler 2017-09-23 08:22:34 +02:00
parent bf0c946c52
commit ece9cd8667
3 changed files with 6 additions and 4 deletions

View File

@ -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'

View File

@ -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)

View File

@ -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)