Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
commonMain.app.bsky.feed.post.kt Maven / Gradle / Ivy
@file:Suppress("DEPRECATION")
package app.bsky.feed
import app.bsky.richtext.Facet
import kotlin.Deprecated
import kotlin.String
import kotlin.Suppress
import kotlin.collections.List
import kotlin.jvm.JvmInline
import kotlinx.serialization.KSerializer
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import sh.christian.ozone.api.Language
import sh.christian.ozone.api.model.JsonContent
import sh.christian.ozone.api.model.Timestamp
import sh.christian.ozone.api.runtime.valueClassSerializer
@Serializable
public sealed interface PostEmbedUnion {
public class ImagesSerializer : KSerializer by valueClassSerializer(
serialName = "app.bsky.embed.images",
constructor = ::Images,
valueProvider = Images::value,
valueSerializerProvider = { app.bsky.embed.Images.serializer() },
)
@JvmInline
@Serializable(with = ImagesSerializer::class)
@SerialName("app.bsky.embed.images")
public value class Images(
public val `value`: app.bsky.embed.Images,
) : PostEmbedUnion
public class VideoSerializer : KSerializer by valueClassSerializer(
serialName = "app.bsky.embed.video",
constructor = ::Video,
valueProvider = Video::value,
valueSerializerProvider = { app.bsky.embed.Video.serializer() },
)
@JvmInline
@Serializable(with = VideoSerializer::class)
@SerialName("app.bsky.embed.video")
public value class Video(
public val `value`: app.bsky.embed.Video,
) : PostEmbedUnion
public class ExternalSerializer : KSerializer by valueClassSerializer(
serialName = "app.bsky.embed.external",
constructor = ::External,
valueProvider = External::value,
valueSerializerProvider = { app.bsky.embed.External.serializer() },
)
@JvmInline
@Serializable(with = ExternalSerializer::class)
@SerialName("app.bsky.embed.external")
public value class External(
public val `value`: app.bsky.embed.External,
) : PostEmbedUnion
public class RecordSerializer : KSerializer by valueClassSerializer(
serialName = "app.bsky.embed.record",
constructor = ::Record,
valueProvider = Record::value,
valueSerializerProvider = { app.bsky.embed.Record.serializer() },
)
@JvmInline
@Serializable(with = RecordSerializer::class)
@SerialName("app.bsky.embed.record")
public value class Record(
public val `value`: app.bsky.embed.Record,
) : PostEmbedUnion
public class RecordWithMediaSerializer : KSerializer by valueClassSerializer(
serialName = "app.bsky.embed.recordWithMedia",
constructor = ::RecordWithMedia,
valueProvider = RecordWithMedia::value,
valueSerializerProvider = { app.bsky.embed.RecordWithMedia.serializer() },
)
@JvmInline
@Serializable(with = RecordWithMediaSerializer::class)
@SerialName("app.bsky.embed.recordWithMedia")
public value class RecordWithMedia(
public val `value`: app.bsky.embed.RecordWithMedia,
) : PostEmbedUnion
@JvmInline
@Serializable
public value class Unknown(
public val `value`: JsonContent,
) : PostEmbedUnion
}
@Serializable
public sealed interface PostLabelsUnion {
public class SelfLabelsSerializer : KSerializer by valueClassSerializer(
serialName = "com.atproto.label.defs#selfLabels",
constructor = ::SelfLabels,
valueProvider = SelfLabels::value,
valueSerializerProvider = { com.atproto.label.SelfLabels.serializer() },
)
@JvmInline
@Serializable(with = SelfLabelsSerializer::class)
@SerialName("com.atproto.label.defs#selfLabels")
public value class SelfLabels(
public val `value`: com.atproto.label.SelfLabels,
) : PostLabelsUnion
@JvmInline
@Serializable
public value class Unknown(
public val `value`: JsonContent,
) : PostLabelsUnion
}
/**
* @param text The primary post content. May be an empty string, if there are embeds.
* @param facets Annotations of text (mentions, URLs, hashtags, etc)
* @param langs Indicates human language of post primary text content.
* @param labels Self-label values for this post. Effectively content warnings.
* @param tags Additional hashtags, in addition to any included in post text and facets.
* @param createdAt Client-declared timestamp when this post was originally created.
*/
@Serializable
public data class Post(
/**
* The primary post content. May be an empty string, if there are embeds.
*/
public val text: String,
@Deprecated("DEPRECATED: replaced by app.bsky.richtext.facet.")
public val entities: List = emptyList(),
/**
* Annotations of text (mentions, URLs, hashtags, etc)
*/
public val facets: List = emptyList(),
public val reply: PostReplyRef? = null,
public val embed: PostEmbedUnion? = null,
/**
* Indicates human language of post primary text content.
*/
public val langs: List = emptyList(),
/**
* Self-label values for this post. Effectively content warnings.
*/
public val labels: PostLabelsUnion? = null,
/**
* Additional hashtags, in addition to any included in post text and facets.
*/
public val tags: List = emptyList(),
/**
* Client-declared timestamp when this post was originally created.
*/
public val createdAt: Timestamp,
) {
init {
require(text.count() <= 3_000) {
"text.count() must be <= 3_000, but was ${text.count()}"
}
require(langs.count() <= 3) {
"langs.count() must be <= 3, but was ${langs.count()}"
}
require(tags.count() <= 8) {
"tags.count() must be <= 8, but was ${tags.count()}"
}
require(tags.count() <= 640) {
"tags.count() must be <= 640, but was ${tags.count()}"
}
}
}