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

commonMain.app.bsky.feed.FeedViewPost.kt Maven / Gradle / Ivy

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

package app.bsky.feed

import kotlin.String
import kotlin.Suppress
import kotlin.jvm.JvmInline
import kotlinx.serialization.KSerializer
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import sh.christian.ozone.api.runtime.valueClassSerializer

@Serializable
public sealed interface FeedViewPostReasonUnion {
  public class ReasonRepostSerializer : KSerializer by valueClassSerializer(
    serialName = "app.bsky.feed.defs#reasonRepost",
    constructor = ::ReasonRepost,
    valueProvider = ReasonRepost::value,
    valueSerializerProvider = { app.bsky.feed.ReasonRepost.serializer() },
  )

  @Serializable(with = ReasonRepostSerializer::class)
  @JvmInline
  @SerialName("app.bsky.feed.defs#reasonRepost")
  public value class ReasonRepost(
    public val `value`: app.bsky.feed.ReasonRepost,
  ) : FeedViewPostReasonUnion

  public class ReasonPinSerializer : KSerializer by valueClassSerializer(
    serialName = "app.bsky.feed.defs#reasonPin",
    constructor = ::ReasonPin,
    valueProvider = ReasonPin::value,
    valueSerializerProvider = { app.bsky.feed.ReasonPin.serializer() },
  )

  @Serializable(with = ReasonPinSerializer::class)
  @JvmInline
  @SerialName("app.bsky.feed.defs#reasonPin")
  public value class ReasonPin(
    public val `value`: app.bsky.feed.ReasonPin,
  ) : FeedViewPostReasonUnion
}

/**
 * @param feedContext Context provided by feed generator that may be passed back alongside
 * interactions.
 */
@Serializable
public data class FeedViewPost(
  public val post: PostView,
  public val reply: ReplyRef? = null,
  public val reason: FeedViewPostReasonUnion? = null,
  /**
   * Context provided by feed generator that may be passed back alongside interactions.
   */
  public val feedContext: String? = null,
) {
  init {
    require(feedContext == null || feedContext.count() <= 2_000) {
      "feedContext.count() must be <= 2_000, but was ${feedContext?.count()}"
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy