All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.chat.bsky.convo.MessageView.kt Maven / Gradle / Ivy

The newest version!
@file:Suppress("DEPRECATION")

package chat.bsky.convo

import app.bsky.embed.RecordView
import app.bsky.richtext.Facet
import kotlin.String
import kotlin.Suppress
import kotlin.jvm.JvmInline
import kotlinx.collections.immutable.persistentListOf
import kotlinx.serialization.KSerializer
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import sh.christian.ozone.api.model.ReadOnlyList
import sh.christian.ozone.api.model.Timestamp
import sh.christian.ozone.api.runtime.valueClassSerializer

@Serializable
public sealed interface MessageViewEmbedUnion {
  public class ViewSerializer : KSerializer by valueClassSerializer(
    serialName = "app.bsky.embed.record#view",
    constructor = ::View,
    valueProvider = View::value,
    valueSerializerProvider = { RecordView.serializer() },
  )

  @Serializable(with = ViewSerializer::class)
  @JvmInline
  @SerialName("app.bsky.embed.record#view")
  public value class View(
    public val `value`: RecordView,
  ) : MessageViewEmbedUnion
}

/**
 * @param facets Annotations of text (mentions, URLs, hashtags, etc)
 */
@Serializable
public data class MessageView(
  public val id: String,
  public val rev: String,
  public val text: String,
  /**
   * Annotations of text (mentions, URLs, hashtags, etc)
   */
  public val facets: ReadOnlyList = persistentListOf(),
  public val embed: MessageViewEmbedUnion? = null,
  public val sender: MessageViewSender,
  public val sentAt: Timestamp,
) {
  init {
    require(text.count() <= 10_000) {
      "text.count() must be <= 10_000, but was ${text.count()}"
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy