-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- EmailDomainBlock - IpBlock - Measure - Report
- Loading branch information
Showing
6 changed files
with
185 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...rc/commonMain/kotlin/xyz/wingio/fediapi/software/mastodon/model/admin/EmailDomainBlock.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package xyz.wingio.fediapi.software.mastodon.model.admin | ||
|
||
import kotlinx.datetime.Instant | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
/** | ||
* Represents an email domain that cannot be used to sign up. | ||
* | ||
* @param id The ID of the [EmailDomainBlock] in the database. | ||
* @param domain The email domain that is not allowed to be used for signups. | ||
* @param createdAt When the email domain was disallowed from signups. | ||
* @param history Usage statistics for given days (typically the past week). | ||
*/ | ||
@Serializable | ||
public data class EmailDomainBlock( | ||
val id: String, | ||
val domain: String, | ||
@SerialName("created_at") val createdAt: Instant, | ||
val history: History | ||
) { | ||
|
||
/** | ||
* Usage statistics for an [EmailDomainBlock] | ||
* | ||
* @param day UNIX timestamp on midnight of the given day. | ||
* @param accounts The counted accounts signup attempts using that email domain within that day. | ||
* @param uses The counted IP signup attempts of that email domain within that day. | ||
*/ | ||
@Serializable | ||
public data class History( | ||
val day: String? = null, | ||
val accounts: String? = null, | ||
val uses: String? = null | ||
) | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
fediapi/src/commonMain/kotlin/xyz/wingio/fediapi/software/mastodon/model/admin/IpBlock.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package xyz.wingio.fediapi.software.mastodon.model.admin | ||
|
||
import kotlinx.datetime.Instant | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
/** | ||
* Represents an IP address range that cannot be used to sign up. | ||
* | ||
* @param id The ID of the [DomainBlock] in the database. | ||
* @param ip The IP address range that is not allowed to federate. | ||
* @param severity The associated policy with this IP block. | ||
* @param comment The recorded reason for this IP block. | ||
* @param createdAt When the IP block was created. | ||
* @param expiresAt When the IP block will expire. | ||
*/ | ||
@Serializable | ||
public data class IpBlock( | ||
val id: String, | ||
val ip: String, | ||
val severity: Severity, | ||
val comment: String, | ||
@SerialName("created_at") val createdAt: Instant, | ||
@SerialName("expires_at") val expiresAt: Instant? | ||
) { | ||
|
||
@Serializable | ||
public enum class Severity { | ||
/** | ||
* Any signup from this IP range will create a pending account | ||
*/ | ||
@SerialName("sign_up_requires_approval") SIGNUP_REQUIRES_APPROVAL, | ||
|
||
/** | ||
* Any signup from this IP range will be rejected | ||
*/ | ||
@SerialName("sign_up_block") SIGNUP_BLOCKED, | ||
|
||
/** | ||
* Any activity from this IP range will be rejected entirely | ||
*/ | ||
@SerialName("no_access") NO_ACCESS | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
fediapi/src/commonMain/kotlin/xyz/wingio/fediapi/software/mastodon/model/admin/Measure.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package xyz.wingio.fediapi.software.mastodon.model.admin | ||
|
||
import kotlinx.datetime.Instant | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
/** | ||
* Represents quantitative data about the server. | ||
* | ||
* @param key The unique keystring for the requested measure. | ||
* @param unit The units associated with this data item’s value, if applicable. | ||
* @param total The numeric total associated with the requested measure. | ||
* @param humanValue A human-readable formatted value for this data item. | ||
* @param previousTotal The numeric total associated with the requested measure, in the previous period. Previous period is calculated by subtracting the startAt and endAt dates, then offsetting both start and end dates backwards by the length of the time period. | ||
* @param data The data available for the requested measure, split into daily buckets. | ||
*/ | ||
@Serializable | ||
public data class Measure( | ||
val key: String, | ||
val unit: String?, | ||
val total: String, | ||
@SerialName("human_value") val humanValue: String? = null, | ||
@SerialName("previous_total") val previousTotal: String? = null, | ||
val data: List<Data> | ||
) { | ||
|
||
/** | ||
* The data available for a single day | ||
* | ||
* @param date Midnight on the requested day in the time period. | ||
* @param value The numeric value for the requested measure. | ||
*/ | ||
@Serializable | ||
public data class Data( | ||
val date: Instant, | ||
val value: String, | ||
) | ||
|
||
} |
61 changes: 61 additions & 0 deletions
61
fediapi/src/commonMain/kotlin/xyz/wingio/fediapi/software/mastodon/model/admin/Report.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package xyz.wingio.fediapi.software.mastodon.model.admin | ||
|
||
import kotlinx.datetime.Instant | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
/** | ||
* Admin-level information about a filed report. | ||
* | ||
* @param id The ID of the report in the database. | ||
* @param actionTaken Whether an action was taken to resolve this report. | ||
* @param actionTakenAt When an action was taken, if this report is currently resolved. | ||
* @param category The category under which the report is classified. | ||
* @param comment An optional reason for reporting. | ||
* @param forwarded Whether a report was forwarded to a remote instance. | ||
* @param createdAt The time the report was filed. | ||
* @param updatedAt The time of last action on this report. | ||
* @param account The account which filed the report. | ||
* @param targetAccount The account being reported. | ||
* @param assignedAccount The account of the moderator assigned to this report. | ||
* @param actionTakenByAccount The account of the moderator who handled the report. | ||
* @param statuses Statuses attached to the report, for context. | ||
* @param rules Rules attached to the report, for context. | ||
*/ | ||
@Serializable | ||
public data class Report( | ||
val id: String, | ||
@SerialName("action_taken") val actionTaken: Boolean, | ||
@SerialName("action_taken_at") val actionTakenAt: Instant?, | ||
val category: Category, | ||
val comment: String, | ||
val forwarded: Boolean, | ||
@SerialName("created_at") val createdAt: Instant, | ||
@SerialName("updated_at") val updatedAt: Instant, | ||
val account: AdminAccount, | ||
@SerialName("target_account") val targetAccount: AdminAccount, | ||
@SerialName("assigned_account") val assignedAccount: AdminAccount?, | ||
@SerialName("action_taken_by_account") val actionTakenByAccount: AdminAccount?, | ||
val statuses: List<String>, // TODO: Model | ||
val rules: List<String> // TODO: Model | ||
) { | ||
|
||
@Serializable | ||
public enum class Category { | ||
/** | ||
* Malicious, fake, or repetitive content | ||
*/ | ||
@SerialName("spam") SPAM, | ||
|
||
/** | ||
* Violates one or more specific [rules] | ||
*/ | ||
@SerialName("violation") VIOLATION, | ||
|
||
/** | ||
* The default (catch-all) category | ||
*/ | ||
@SerialName("other") OTHER | ||
} | ||
|
||
} |