Skip to content

Commit

Permalink
Added missing fields to Instance entity. (#217)
Browse files Browse the repository at this point in the history
* Added missing fields to Instance entity.

Added the missing fields to the InstanceV1 entity. Also moved some
Instance-specific classes into the Instance class (as nested data
class). Added code samples.

* Code review fixes

Moved Rule class into separate entity, renamed some data classes related
to the Instance entity.

* Fix code review findings

* Added test for reading config section in instance entity

---------

Co-authored-by: André Gasser <andre.gasser2@swisscom.com>
  • Loading branch information
andregasser and André Gasser authored Jun 6, 2023
1 parent c2bea0f commit fb59ffe
Show file tree
Hide file tree
Showing 8 changed files with 411 additions and 46 deletions.
194 changes: 190 additions & 4 deletions bigbone/src/main/kotlin/social/bigbone/api/entity/Instance.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ data class Instance(
* URLs of interest for clients apps.
*/
@SerializedName("urls")
val urls: InstanceUrls? = null,
val urls: Urls? = null,

/**
* Statistics about how much information the instance contains.
*/
@SerializedName("stats")
val stats: InstanceStats? = null,
val stats: Stats? = null,

/**
* Banner image for the website.
Expand Down Expand Up @@ -85,9 +85,195 @@ data class Instance(
@SerializedName("invites_enabled")
val invitesEnabled: Boolean = false,

/**
* Configured values and limits for this website.
*/
@SerializedName("configuration")
val configuration: Configuration? = null,

/**
* A user that can be contacted, as an alternative to email.
*/
@SerializedName("contact_account")
val contactAccount: Account? = null
)
val contactAccount: Account? = null,

/**
* An itemized list of rules for this website.
*/
@SerializedName("rules")
val rules: List<Rule>? = null
) {
/**
* URLs of interest for clients apps.
* @see <a href="https://docs.joinmastodon.org/entities/V1_Instance/">Mastodon API V1::Instance</a>
*/
data class Urls(
/**
* The Websockets URL for connecting to the streaming API.
*/
@SerializedName("streaming_api")
val streamingApi: String = ""
)

/**
* Statistics about how much information the instance contains.
* @see <a href="https://docs.joinmastodon.org/entities/V1_Instance/">Mastodon API V1::Instance</a>
*/
data class Stats(
/**
* Total users on this instance.
*/
@SerializedName("user_count")
val userCount: Long = 0,

/**
* Total statuses on this instance.
*/
@SerializedName("status_count")
val statusCount: Long = 0,

/**
* Total domains discovered by this instance.
*/
@SerializedName("domain_count")
val domainCount: Long = 0
)

/**
* Configured values and limits for this website.
* @see <a href="https://docs.joinmastodon.org/entities/V1_Instance/">Mastodon API V1::Instance</a>
*/
data class Configuration(
/**
* Limits related to accounts.
*/
@SerializedName("accounts")
val accounts: Accounts? = null,

/**
* Limits related to authoring statuses.
*/
@SerializedName("statuses")
val statuses: Statuses? = null,

/**
* Hints for which attachments will be accepted.
*/
@SerializedName("media_attachments")
val mediaAttachments: MediaAttachments? = null,

/**
* Limits related to polls.
*/
@SerializedName("polls")
val polls: Polls? = null
) {
/**
* Limits related to accounts.
* @see <a href="https://docs.joinmastodon.org/entities/V1_Instance/">Mastodon API V1::Instance</a>
*/
data class Accounts(
/**
* The maximum number of featured tags allowed for each account.
*/
@SerializedName("max_featured_tags")
val maxFeaturedTags: Int = 0
)

/**
* Limits related to authoring statuses.
* @see <a href="https://docs.joinmastodon.org/entities/V1_Instance/">Mastodon API V1::Instance</a>
*/
data class Statuses(
/**
* The maximum number of allowed characters per status.
*/
@SerializedName("max_characters")
val maxCharacters: Int = 0,

/**
* The maximum number of media attachments that can be added to a status.
*/
@SerializedName("max_media_attachments")
val maxMediaAttachments: Int = 0,

/**
* Each URL in a status will be assumed to be exactly this many characters.
*/
@SerializedName("characters_reserved_per_url")
val charactersReservedPerUrl: Int = 0
)

/**
* Hints for which attachments will be accepted.
* @see <a href="https://docs.joinmastodon.org/entities/V1_Instance/">Mastodon API V1::Instance</a>
*/
data class MediaAttachments(
/**
* Contains MIME types that can be uploaded.
*/
@SerializedName("supported_mime_types")
val supportedMimeTypes: List<String> = emptyList(),

/**
* The maximum size of any uploaded image, in bytes.
*/
@SerializedName("image_size_limit")
val imageSizeLimit: Int = 0,

/**
* The maximum number of pixels (width times height) for image uploads.
*/
@SerializedName("image_matrix_limit")
val imageMatrixLimit: Int = 0,

/**
* The maximum size of any uploaded video, in bytes.
*/
@SerializedName("video_size_limit")
val videoSizeLimit: Int = 0,

/**
* The maximum frame rate for any uploaded video.
*/
@SerializedName("video_frame_rate_limit")
val videoFrameRateLimit: Int = 0,

/**
* The maximum number of pixels (width times height) for video uploads.
*/
@SerializedName("video_matrix_limit")
val videoMatrixLimit: Int = 0
)

/**
* Limits related to polls.
* @see <a href="https://docs.joinmastodon.org/entities/V1_Instance/">Mastodon API V1::Instance</a>
*/
data class Polls(
/**
* Each poll is allowed to have up to this many options.
*/
@SerializedName("max_options")
val maxOptions: Int = 0,

/**
* Each poll option is allowed to have this many characters.
*/
@SerializedName("max_characters_per_option")
val maxCharactersPerOption: Int = 0,

/**
* The shortest allowed poll duration, in seconds.
*/
@SerializedName("min_expiration")
val minExpiration: Int = 0,

/**
* The longest allowed poll duration, in seconds.
*/
@SerializedName("max_expiration")
val maxExpiration: Int = 0
)
}
}
27 changes: 0 additions & 27 deletions bigbone/src/main/kotlin/social/bigbone/api/entity/InstanceStats.kt

This file was deleted.

15 changes: 0 additions & 15 deletions bigbone/src/main/kotlin/social/bigbone/api/entity/InstanceUrls.kt

This file was deleted.

21 changes: 21 additions & 0 deletions bigbone/src/main/kotlin/social/bigbone/api/entity/Rule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package social.bigbone.api.entity

import com.google.gson.annotations.SerializedName

/**
* Represents a rule that server users should follow.
* @see <a href="https://docs.joinmastodon.org/entities/Rule/">Mastodon API Rule</a>
*/
data class Rule(
/**
* An identifier for the rule.
*/
@SerializedName("id")
val id: String = "0",

/**
* The rule to be followed.
*/
@SerializedName("text")
val text: String = ""
)
Loading

0 comments on commit fb59ffe

Please sign in to comment.