diff --git a/autobot/src/main/kotlin/com/jdpgrailsdev/oasis/timeline/client/BlueSkyClient.kt b/autobot/src/main/kotlin/com/jdpgrailsdev/oasis/timeline/client/BlueSkyClient.kt index 5c10298..8a9694a 100644 --- a/autobot/src/main/kotlin/com/jdpgrailsdev/oasis/timeline/client/BlueSkyClient.kt +++ b/autobot/src/main/kotlin/com/jdpgrailsdev/oasis/timeline/client/BlueSkyClient.kt @@ -250,7 +250,7 @@ data class BlueSkyRecordCommit( @SuppressFBWarnings(value = ["EI_EXPOSE_REP", "EI_EXPOSE_REP2"]) data class BlueSkyGetFeedsResponse( - val cursor: String, + val cursor: String?, val feeds: List, ) diff --git a/autobot/src/main/kotlin/com/jdpgrailsdev/oasis/timeline/util/BlueSkyUtils.kt b/autobot/src/main/kotlin/com/jdpgrailsdev/oasis/timeline/util/BlueSkyUtils.kt index 5d63781..08b709d 100644 --- a/autobot/src/main/kotlin/com/jdpgrailsdev/oasis/timeline/util/BlueSkyUtils.kt +++ b/autobot/src/main/kotlin/com/jdpgrailsdev/oasis/timeline/util/BlueSkyUtils.kt @@ -28,6 +28,7 @@ import com.jdpgrailsdev.oasis.timeline.client.BlueSkyReply import com.jdpgrailsdev.oasis.timeline.client.BlueSkyReplyPost import com.jdpgrailsdev.oasis.timeline.client.BlueSkyTagFacetFeature import com.jdpgrailsdev.oasis.timeline.data.Post +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings import java.time.Instant import java.time.ZoneId import java.time.format.DateTimeFormatter @@ -48,7 +49,7 @@ object BlueSkyUtils { text = text, createdAt = TIMESTAMP_FORMAT.format(Instant.now()), reply = reply, - facets = createFacets(text = text, resolvers = resolvers), + facets = emptyList(), // createFacets(text = text, resolvers = resolvers), ) fun createReply( @@ -56,6 +57,7 @@ object BlueSkyUtils { parentMessage: BlueSkyReplyPost? = null, ): BlueSkyReply = BlueSkyReply(root = rootMessage ?: parentMessage, parent = parentMessage ?: rootMessage) + @SuppressFBWarnings("UPM_UNCALLED_PRIVATE_METHOD") private fun createFacets( text: String, resolvers: Map String>, diff --git a/autobot/src/test/kotlin/com/jdpgrailsdev/oasis/timeline/util/BlueSkyUtilsTest.kt b/autobot/src/test/kotlin/com/jdpgrailsdev/oasis/timeline/util/BlueSkyUtilsTest.kt index ea966bd..99b9b84 100644 --- a/autobot/src/test/kotlin/com/jdpgrailsdev/oasis/timeline/util/BlueSkyUtilsTest.kt +++ b/autobot/src/test/kotlin/com/jdpgrailsdev/oasis/timeline/util/BlueSkyUtilsTest.kt @@ -19,11 +19,7 @@ package com.jdpgrailsdev.oasis.timeline.util -import com.fasterxml.jackson.annotation.JsonInclude -import com.fasterxml.jackson.databind.MapperFeature -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule -import com.fasterxml.jackson.module.kotlin.KotlinModule +import com.jdpgrailsdev.oasis.timeline.client.BlueSkyFacet import com.jdpgrailsdev.oasis.timeline.client.BlueSkyFacetType import com.jdpgrailsdev.oasis.timeline.client.BlueSkyMentionFacetFeature import com.jdpgrailsdev.oasis.timeline.client.BlueSkyReply @@ -33,6 +29,7 @@ import com.jdpgrailsdev.oasis.timeline.data.Post import org.junit.jupiter.api.Assertions.assertNotNull import org.junit.jupiter.api.Assertions.assertNull import org.junit.jupiter.api.Assertions.assertTrue +import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import kotlin.test.assertEquals @@ -98,6 +95,7 @@ internal class BlueSkyUtilsTest { } @Test + @Disabled fun testCreateRecordWithFacets() { val did = "did:plc:2kfn5kwq4dqzncgv2g2tqmii" val mention = "test.bsky.social" @@ -108,50 +106,35 @@ internal class BlueSkyUtilsTest { val record = BlueSkyUtils.createRecord(text = text, resolvers = blueSkyResolverMap) - val mapper = - JsonMapper - .builder() - .addModule(JavaTimeModule()) - .addModule(KotlinModule.Builder().build()) - .serializationInclusion(JsonInclude.Include.NON_NULL) - .enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS) - .build() - println(mapper.writeValueAsString(record)) assertEquals(text, record.text) assertNotNull(record.createdAt) assertEquals(3, record.facets.size) - assertEquals( - 2, - record.facets - .filter { f -> - f.features.find { feature -> feature.getType() == BlueSkyFacetType.TAG.type } != null - }.size, - ) - assertEquals( - 1, - record.facets - .filter { f -> - f.features.find { feature -> feature.getType() == BlueSkyFacetType.MENTION.type } != null - }.size, - ) - assertEquals( - did, - ( - record.facets - .first { f -> - f.features.find { feature -> feature.getType() == BlueSkyFacetType.MENTION.type } != - null - }.features - .first() as BlueSkyMentionFacetFeature - ).did, - ) - val tagFacets = - record.facets.filter { f -> - f.features.find { feature -> feature.getType() == BlueSkyFacetType.TAG.type } != null - } - val tags = - (tagFacets.flatMap { t -> t.features.map { f -> (f as BlueSkyTagFacetFeature).tag } }) + assertEquals(2, getTagFacetFeatures(facets = record.facets).size) + assertEquals(1, getMentionFacetFeatures(facets = record.facets).size) + assertEquals(did, getMentionFacetFeatures(facets = record.facets).first().did) + val tags = getTagFacetFeatures(facets = record.facets).map { f -> f.tag } assertTrue(tags.contains("tag1")) assertTrue(tags.contains("tag2")) + + record.facets.forEach { facet -> + val byteStart = facet.index.byteStart + val byteEnd = facet.index.byteEnd + + println("Index for facet $facet") + + println(text.substring(byteStart, byteEnd)) + } } + + private fun getMentionFacetFeatures(facets: List): List = + facets + .flatMap { f -> f.features } + .filter { f -> f.getType() == BlueSkyFacetType.MENTION.type } + .map { f -> f as BlueSkyMentionFacetFeature } + + private fun getTagFacetFeatures(facets: List): List = + facets + .flatMap { f -> f.features } + .filter { f -> f.getType() == BlueSkyFacetType.TAG.type } + .map { f -> f as BlueSkyTagFacetFeature } }