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

commonMain.com.atproto.moderation.createReport.kt Maven / Gradle / Ivy

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

package com.atproto.moderation

import com.atproto.admin.RepoRef
import com.atproto.repo.StrongRef
import kotlin.Long
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.Did
import sh.christian.ozone.api.model.Timestamp
import sh.christian.ozone.api.runtime.valueClassSerializer

@Serializable
public sealed interface CreateReportRequestSubjectUnion {
  public class AdminRepoRefSerializer : KSerializer by valueClassSerializer(
    serialName = "com.atproto.admin.defs#repoRef",
    constructor = ::AdminRepoRef,
    valueProvider = AdminRepoRef::value,
    valueSerializerProvider = { RepoRef.serializer() },
  )

  @Serializable(with = AdminRepoRefSerializer::class)
  @JvmInline
  @SerialName("com.atproto.admin.defs#repoRef")
  public value class AdminRepoRef(
    public val `value`: RepoRef,
  ) : CreateReportRequestSubjectUnion

  public class RepoStrongRefSerializer : KSerializer by valueClassSerializer(
    serialName = "com.atproto.repo.strongRef",
    constructor = ::RepoStrongRef,
    valueProvider = RepoStrongRef::value,
    valueSerializerProvider = { StrongRef.serializer() },
  )

  @Serializable(with = RepoStrongRefSerializer::class)
  @JvmInline
  @SerialName("com.atproto.repo.strongRef")
  public value class RepoStrongRef(
    public val `value`: StrongRef,
  ) : CreateReportRequestSubjectUnion
}

@Serializable
public sealed interface CreateReportResponseSubjectUnion {
  public class AdminRepoRefSerializer : KSerializer by valueClassSerializer(
    serialName = "com.atproto.admin.defs#repoRef",
    constructor = ::AdminRepoRef,
    valueProvider = AdminRepoRef::value,
    valueSerializerProvider = { RepoRef.serializer() },
  )

  @Serializable(with = AdminRepoRefSerializer::class)
  @JvmInline
  @SerialName("com.atproto.admin.defs#repoRef")
  public value class AdminRepoRef(
    public val `value`: RepoRef,
  ) : CreateReportResponseSubjectUnion

  public class RepoStrongRefSerializer : KSerializer by valueClassSerializer(
    serialName = "com.atproto.repo.strongRef",
    constructor = ::RepoStrongRef,
    valueProvider = RepoStrongRef::value,
    valueSerializerProvider = { StrongRef.serializer() },
  )

  @Serializable(with = RepoStrongRefSerializer::class)
  @JvmInline
  @SerialName("com.atproto.repo.strongRef")
  public value class RepoStrongRef(
    public val `value`: StrongRef,
  ) : CreateReportResponseSubjectUnion
}

/**
 * @param reasonType Indicates the broad category of violation the report is for.
 * @param reason Additional context about the content and violation.
 */
@Serializable
public data class CreateReportRequest(
  /**
   * Indicates the broad category of violation the report is for.
   */
  public val reasonType: Token,
  /**
   * Additional context about the content and violation.
   */
  public val reason: String? = null,
  public val subject: CreateReportRequestSubjectUnion,
) {
  init {
    require(reason == null || reason.count() <= 20_000) {
      "reason.count() must be <= 20_000, but was ${reason?.count()}"
    }
  }
}

@Serializable
public data class CreateReportResponse(
  public val id: Long,
  public val reasonType: Token,
  public val reason: String? = null,
  public val subject: CreateReportResponseSubjectUnion,
  public val reportedBy: Did,
  public val createdAt: Timestamp,
) {
  init {
    require(reason == null || reason.count() <= 20_000) {
      "reason.count() must be <= 20_000, but was ${reason?.count()}"
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy