All Downloads are FREE. Search and download functionalities are using the official Maven repository.
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.jvm.JvmInline
import kotlinx.collections.immutable.persistentListOf
import kotlinx.serialization.KSerializer
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import sh.christian.ozone.api.Language
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 PostEmbedUnion {
public class ImagesSerializer : KSerializer by valueClassSerializer(
serialName = "app.bsky.embed.images",
constructor = ::Images,
valueProvider = Images::value,
valueSerializerProvider = { app.bsky.embed.Images.serializer() },
)
@Serializable(with = ImagesSerializer::class)
@JvmInline
@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() },
)
@Serializable(with = VideoSerializer::class)
@JvmInline
@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() },
)
@Serializable(with = ExternalSerializer::class)
@JvmInline
@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() },
)
@Serializable(with = RecordSerializer::class)
@JvmInline
@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() },
)
@Serializable(with = RecordWithMediaSerializer::class)
@JvmInline
@SerialName("app.bsky.embed.recordWithMedia")
public value class RecordWithMedia(
public val `value`: app.bsky.embed.RecordWithMedia,
) : 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() },
)
@Serializable(with = SelfLabelsSerializer::class)
@JvmInline
@SerialName("com.atproto.label.defs#selfLabels")
public value class SelfLabels(
public val `value`: com.atproto.label.SelfLabels,
) : 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: ReadOnlyList = persistentListOf(),
/**
* Annotations of text (mentions, URLs, hashtags, etc)
*/
public val facets: ReadOnlyList = persistentListOf(),
public val reply: PostReplyRef? = null,
public val embed: PostEmbedUnion? = null,
/**
* Indicates human language of post primary text content.
*/
public val langs: ReadOnlyList = persistentListOf(),
/**
* 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: ReadOnlyList = persistentListOf(),
/**
* 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()}"
}
}
}