Skip to content

Commit

Permalink
Add more models
Browse files Browse the repository at this point in the history
 * CanonicalEmailBlock
 * Cohort
 * Dimension
 * DomainAllow
 * DomainBlock
  • Loading branch information
wingio committed Dec 18, 2023
1 parent 206582b commit 67c2675
Show file tree
Hide file tree
Showing 6 changed files with 173 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ public typealias URL = String

public typealias HTML = String

public typealias Language = String
public typealias Language = String

public typealias SHA256 = String
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package xyz.wingio.fediapi.software.mastodon.model.admin

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import xyz.wingio.fediapi.SHA256

/**
* Represents a canonical email block (hashed).
*
* @param id The ID of the email block in the database.
* @param canonicalEmailHash The SHA256 hash of the canonical email address.
*/
@Serializable
public data class CanonicalEmailBlock(
val id: String,
@SerialName("canonical_email_hash") val canonicalEmailHash: SHA256
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package xyz.wingio.fediapi.software.mastodon.model.admin

import kotlinx.datetime.Instant
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/**
* Represents a retention metric.
*
* @param period The timestamp for the start of the period, at midnight.
* @param frequency The size of the bucket for the returned data.
* @param data Retention data for users who registered during the given period.
*/
@Serializable
public data class Cohort(
val period: Instant,
val frequency: Frequency,
val data: List<Data>
) {

@Serializable
public enum class Frequency {
/**
* Daily buckets
*/
@SerialName("day") DAILY,

/**
* Monthly buckets
*/
@SerialName("month") MONTHLY,
}

/**
* Data for users who registered during a given period.
*
* @param date The timestamp for the start of the bucket, at midnight.
* @param rate The percentage rate of users who registered in the specified [period] and were active for the given [date] bucket.
* @param value How many users registered in the specified [period] and were active for the given [date] bucket.
*/
@Serializable
public data class Data(
val date: Instant,
val rate: Float,
val value: Int
)

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package xyz.wingio.fediapi.software.mastodon.model.admin

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/**
* Represents qualitative data about the server.
*
* @param key The unique keystring for the requested dimension.
* @param data The data available for the requested dimension.
*/
@Serializable
public data class Dimension(
val key: String,
val data: List<Data>
) {

/**
* Data available for a given dimension
*
* @param key The unique keystring for this data item.
* @param humanKey A human-readable key for this data item.
* @param value The value for this data item.
* @param unit The units associated with this data item’s value, if applicable.
* @param humanValue A human-readable formatted value for this data item.
*/
@Serializable
public data class Data(
val key: String,
@SerialName("human_key") val humanKey: String,
val value: String,
val unit: String? = null,
@SerialName("human_value") val humanValue: String? = null
)

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package xyz.wingio.fediapi.software.mastodon.model.admin

import kotlinx.datetime.Instant
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/**
* Represents a domain allowed to federate.
*
* @param id The ID of the [DomainAllow] in the database.
* @param domain The domain that is allowed to federate.
* @param createdAt When the domain was allowed to federate.
*/
@Serializable
public data class DomainAllow(
val id: String,
val domain: String,
@SerialName("created_at") val createdAt: Instant
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package xyz.wingio.fediapi.software.mastodon.model.admin

import kotlinx.datetime.Instant
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/**
* Represents a domain limited from federating.
*
* @param id The ID of the [DomainBlock] in the database.
* @param domain The domain that is not allowed to federate.
* @param createdAt When the domain was blocked from federating.
* @param severity The policy to be applied by this domain block.
* @param rejectMedia Whether to reject media attachments from this domain
* @param rejectReports Whether to reject reports from this domain
* @param privateComment Reason for why this domain is blocked
* @param publicComment Publicly shown reason for this block
* @param obfuscate Whether to obfuscate public displays of this domain block
*/
@Serializable
public data class DomainBlock(
val id: String,
val domain: String,
@SerialName("created_at") val createdAt: Instant,
val severity: Severity,
@SerialName("reject_media") val rejectMedia: Boolean,
@SerialName("reject_reports") val rejectReports: Boolean,
@SerialName("private_comment") val privateComment: String?,
@SerialName("public_comment") val publicComment: String?,
val obfuscate: Boolean
) {

public enum class Severity {
/**
* Account statuses from this domain will be hidden by default
*/
@SerialName("silence") SILENCE,

/**
* All incoming data from this domain will be rejected
*/
@SerialName("suspend") SUSPEND,

/**
* Do nothing. Allows for rejecting media or reports
*/
@SerialName("noop") NOOP
}

}

0 comments on commit 67c2675

Please sign in to comment.