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

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

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

package app.bsky.feed

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.AtUri
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 ThreadgateAllowUnion {
  public class MentionRuleSerializer : KSerializer by valueClassSerializer(
    serialName = "app.bsky.feed.threadgate#mentionRule",
    constructor = ::MentionRule,
    valueProvider = MentionRule::value,
    valueSerializerProvider = { ThreadgateMentionRule.serializer() },
  )

  @Serializable(with = MentionRuleSerializer::class)
  @JvmInline
  @SerialName("app.bsky.feed.threadgate#mentionRule")
  public value class MentionRule(
    public val `value`: ThreadgateMentionRule,
  ) : ThreadgateAllowUnion

  public class FollowingRuleSerializer : KSerializer by valueClassSerializer(
    serialName = "app.bsky.feed.threadgate#followingRule",
    constructor = ::FollowingRule,
    valueProvider = FollowingRule::value,
    valueSerializerProvider = { ThreadgateFollowingRule.serializer() },
  )

  @Serializable(with = FollowingRuleSerializer::class)
  @JvmInline
  @SerialName("app.bsky.feed.threadgate#followingRule")
  public value class FollowingRule(
    public val `value`: ThreadgateFollowingRule,
  ) : ThreadgateAllowUnion

  public class ListRuleSerializer : KSerializer by valueClassSerializer(
    serialName = "app.bsky.feed.threadgate#listRule",
    constructor = ::ListRule,
    valueProvider = ListRule::value,
    valueSerializerProvider = { ThreadgateListRule.serializer() },
  )

  @Serializable(with = ListRuleSerializer::class)
  @JvmInline
  @SerialName("app.bsky.feed.threadgate#listRule")
  public value class ListRule(
    public val `value`: ThreadgateListRule,
  ) : ThreadgateAllowUnion
}

/**
 * @param post Reference (AT-URI) to the post record.
 * @param hiddenReplies List of hidden reply URIs.
 */
@Serializable
public data class Threadgate(
  /**
   * Reference (AT-URI) to the post record.
   */
  public val post: AtUri,
  public val allow: ReadOnlyList = persistentListOf(),
  public val createdAt: Timestamp,
  /**
   * List of hidden reply URIs.
   */
  public val hiddenReplies: ReadOnlyList = persistentListOf(),
) {
  init {
    require(allow.count() <= 5) {
      "allow.count() must be <= 5, but was ${allow.count()}"
    }
    require(hiddenReplies.count() <= 50) {
      "hiddenReplies.count() must be <= 50, but was ${hiddenReplies.count()}"
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy