@@ -381,7 +381,7 @@ class WebAppInterface(val act: MainActivity, val webView: WebView) {
381381
382382 // get bytes from the decoded entry
383383 val entryBytes = decodedEntry?.let {it.getBytes()}
384- Log .d(" entryBytes " , entryBytes.toString())
384+ Log .d(" entryBytes1 " , entryBytes.toString())
385385
386386 // decrypt the bytes to get the clear text
387387 val clear = entryBytes?.let { act.idStore.identity.decryptPrivateMessage(it) }
@@ -643,26 +643,34 @@ class WebAppInterface(val act: MainActivity, val webView: WebView) {
643643 val lastSeq = userFeed?.state?.max_seq
644644 if (lastSeq != null ) {
645645 for (i in lastSeq downTo 1 ) {
646- var entry = userFeed.read_content(lastSeq )
646+ var entry = userFeed.read_content(i )
647647 // decode the entry using Bipf decode
648648 val decodedEntry = entry?.let { Bipf .decode(it) }
649649 Log .d(" decodedEntry" , decodedEntry.toString())
650650
651- // get bytes from the decoded entry
652- val entryBytes = decodedEntry?.let {it.getBytes()}
653- Log .d(" entryBytes" , entryBytes.toString())
654-
655- // decrypt the bytes to get the clear text
656- val clear = entryBytes?.let { act.idStore.identity.decryptPrivateMessage(it) }
657- Log .d(" clear" , clear.toString())
658-
659- val entryType = clear?.let { getFromEntry(it, 0 ) }
660- if (entryType == " TRT" ) {
661- if (clear is ByteArray ) {
662- val contactID = getFromEntry(clear, 2 )
663- val trustLevel = getFromEntry(clear, 3 )
664- if (contactID != null && trustLevel != null ) {
665- contactsTrustLevel[contactID.toString()] = trustLevel.toString().toInt()
651+ if (decodedEntry != null ) {
652+ if (decodedEntry.isBytes()) {
653+ // get bytes from the decoded entry
654+ val entryBytes = decodedEntry?.let {it.getBytes()}
655+ Log .d(" entryBytes2" , entryBytes.toString())
656+
657+ // decrypt the bytes to get the clear text
658+ val clear = entryBytes?.let { act.idStore.identity.decryptPrivateMessage(it) }
659+ Log .d(" clear" , clear.toString())
660+
661+ val entryType = clear?.let { getFromEntry(it, 0 ) }
662+ if (entryType == " TRT" ) {
663+ if (clear is ByteArray ) {
664+ val contactID = getFromEntry(clear, 2 )
665+ val trustLevel = getFromEntry(clear, 3 )
666+ if (contactID != null && trustLevel != null ) {
667+ // check if the contact is already in the dictionary
668+ if (! contactsTrustLevel.containsKey(contactID.toString())) {
669+ // if the contact is not in the dictionary, add the contact to the dictionary
670+ contactsTrustLevel[contactID.toString()] = trustLevel.toString().toInt()
671+ }
672+ }
673+ }
666674 }
667675 }
668676 }
0 commit comments