Skip to content

Commit e777265

Browse files
committed
add InstanceMetadataPresenter
1 parent 87ed976 commit e777265

File tree

8 files changed

+720
-342
lines changed

8 files changed

+720
-342
lines changed

shared/src/commonMain/kotlin/dev/dimension/flare/data/network/mastodon/api/model/MastodonInstanceElement.kt

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,84 @@ internal data class InstanceData(
3838
val configuration: Configuration? = null,
3939
val registrations: Registrations? = null,
4040
val contact: Contact? = null,
41+
val icon: List<Icon>? = null,
42+
@SerialName("api_versions")
43+
val apiVersions: APIVersions? = null,
44+
val rules: List<Rule>? = null,
45+
)
46+
47+
@Serializable
48+
internal data class Rule(
49+
val id: String? = null,
50+
val text: String? = null,
51+
val hint: String? = null,
52+
)
53+
54+
@Serializable
55+
internal data class Icon(
56+
val src: String? = null,
57+
val size: String? = null,
58+
)
59+
60+
@Serializable
61+
internal data class APIVersions(
62+
val mastodon: Long? = null,
4163
)
4264

4365
@Serializable
4466
internal data class Configuration(
4567
val urls: Urls? = null,
68+
val vapid: Vapid? = null,
4669
val accounts: Accounts? = null,
4770
val statuses: Statuses? = null,
4871
@SerialName("media_attachments")
72+
val mediaAttachments: MediaAttachments? = null,
73+
val polls: Polls? = null,
4974
val translation: Translation? = null,
5075
)
5176

77+
@Serializable
78+
internal data class MediaAttachments(
79+
@SerialName("description_limit")
80+
val descriptionLimit: Long? = null,
81+
@SerialName("image_matrix_limit")
82+
val imageMatrixLimit: Long? = null,
83+
@SerialName("image_size_limit")
84+
val imageSizeLimit: Long? = null,
85+
@SerialName("supported_mime_types")
86+
val supportedMIMETypes: List<String>? = null,
87+
@SerialName("video_frame_rate_limit")
88+
val videoFrameRateLimit: Long? = null,
89+
@SerialName("video_matrix_limit")
90+
val videoMatrixLimit: Long? = null,
91+
@SerialName("video_size_limit")
92+
val videoSizeLimit: Long? = null,
93+
)
94+
95+
@Serializable
96+
internal data class Polls(
97+
@SerialName("max_options")
98+
val maxOptions: Long? = null,
99+
@SerialName("max_characters_per_option")
100+
val maxCharactersPerOption: Long? = null,
101+
@SerialName("min_expiration")
102+
val minExpiration: Long? = null,
103+
@SerialName("max_expiration")
104+
val maxExpiration: Long? = null,
105+
)
106+
107+
@Serializable
108+
internal data class Vapid(
109+
@SerialName("public_key")
110+
val publicKey: String? = null,
111+
)
112+
52113
@Serializable
53114
internal data class Accounts(
54115
@SerialName("max_featured_tags")
55116
val maxFeaturedTags: Long? = null,
117+
@SerialName("max_pinned_statuses")
118+
val maxPinnedStatuses: Long? = null,
56119
)
57120

58121
@Serializable
@@ -77,6 +140,11 @@ internal data class Translation(
77140
internal data class Urls(
78141
val streaming: String? = null,
79142
val status: String? = null,
143+
val about: String? = null,
144+
@SerialName("privacy_policy")
145+
val privacyPolicy: String? = null,
146+
@SerialName("terms_of_service")
147+
val termsOfService: String? = null,
80148
)
81149

82150
@Serializable
@@ -100,6 +168,12 @@ internal data class Registrations(
100168
val enabled: Boolean? = null,
101169
@SerialName("approval_required")
102170
val approvalRequired: Boolean? = null,
171+
@SerialName("reason_required")
172+
val reasonRequired: Boolean? = null,
173+
val message: String? = null,
174+
@SerialName("min_age")
175+
val minAge: String? = null,
176+
val url: String? = null,
103177
)
104178

105179
@Serializable

shared/src/commonMain/kotlin/dev/dimension/flare/data/network/misskey/MisskeyService.kt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ import io.ktor.http.contentLength
3131

3232
private fun config(
3333
baseUrl: String,
34-
accessToken: String,
34+
accessToken: String?,
3535
) = ktorfit(
3636
baseUrl = baseUrl,
3737
config = {
38-
install(MisskeyAuthorizationPlugin) {
39-
token = accessToken
38+
if (accessToken != null) {
39+
install(MisskeyAuthorizationPlugin) {
40+
token = accessToken
41+
}
4042
}
4143
install(DefaultRequest) {
4244
if (contentLength() != 0L) {
@@ -48,7 +50,7 @@ private fun config(
4850

4951
internal class MisskeyService(
5052
private val baseUrl: String,
51-
private val token: String,
53+
private val token: String?,
5254
) : UsersApi by config(baseUrl, token).createUsersApi(),
5355
MetaApi by config(baseUrl, token).createMetaApi(),
5456
NotesApi by config(baseUrl, token).createNotesApi(),
@@ -74,7 +76,9 @@ internal class MisskeyService(
7476
},
7577
)
7678
append("isSensitive", sensitive)
77-
append("i", token)
79+
if (token != null) {
80+
append("i", token)
81+
}
7882
},
7983
)
8084
return driveFilesCreate(

shared/src/commonMain/kotlin/dev/dimension/flare/data/network/misskey/api/model/Meta200Response.kt

Lines changed: 127 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -18,47 +18,133 @@ package dev.dimension.flare.data.network.misskey.api.model
1818
import kotlinx.serialization.SerialName
1919
import kotlinx.serialization.Serializable
2020

21-
/**
22-
* *
23-
* @param maintainerName * @param maintainerEmail * @param version * @param name * @param uri * @param description * @param langs * @param tosUrl * @param repositoryUrl * @param feedbackUrl * @param defaultDarkTheme * @param defaultLightTheme * @param disableRegistration * @param cacheRemoteFiles * @param cacheRemoteSensitiveFiles * @param emailRequiredForSignup * @param enableHcaptcha * @param hcaptchaSiteKey * @param enableRecaptcha * @param recaptchaSiteKey * @param enableTurnstile * @param turnstileSiteKey * @param swPublickey * @param mascotImageUrl * @param bannerUrl * @param serverErrorImageUrl * @param infoImageUrl * @param notFoundImageUrl * @param iconUrl * @param maxNoteTextLength * @param ads * @param requireSetup * @param enableEmail * @param enableServiceWorker * @param translatorAvailable * @param proxyAccountName * @param mediaProxy * @param features */
2421
@Serializable
2522
internal data class Meta200Response(
26-
@SerialName(value = "maintainerName") val maintainerName: kotlin.String? = null,
27-
@SerialName(value = "maintainerEmail") val maintainerEmail: kotlin.String? = null,
28-
@SerialName(value = "version") val version: kotlin.String,
29-
@SerialName(value = "name") val name: kotlin.String,
30-
@SerialName(value = "uri") val uri: kotlin.String,
31-
@SerialName(value = "description") val description: kotlin.String? = null,
32-
@SerialName(value = "langs") val langs: kotlin.collections.List<kotlin.String>,
33-
@SerialName(value = "tosUrl") val tosUrl: kotlin.String? = null,
34-
@SerialName(value = "repositoryUrl") val repositoryUrl: kotlin.String = "https://github.com/misskey-dev/misskey",
35-
@SerialName(value = "feedbackUrl") val feedbackUrl: kotlin.String = "https://github.com/misskey-dev/misskey/issues/new",
36-
@SerialName(value = "defaultDarkTheme") val defaultDarkTheme: kotlin.String? = null,
37-
@SerialName(value = "defaultLightTheme") val defaultLightTheme: kotlin.String? = null,
38-
@SerialName(value = "disableRegistration") val disableRegistration: kotlin.Boolean,
39-
@SerialName(value = "cacheRemoteFiles") val cacheRemoteFiles: kotlin.Boolean,
40-
@SerialName(value = "cacheRemoteSensitiveFiles") val cacheRemoteSensitiveFiles: kotlin.Boolean,
41-
@SerialName(value = "emailRequiredForSignup") val emailRequiredForSignup: kotlin.Boolean,
42-
@SerialName(value = "enableHcaptcha") val enableHcaptcha: kotlin.Boolean,
43-
@SerialName(value = "hcaptchaSiteKey") val hcaptchaSiteKey: kotlin.String? = null,
44-
@SerialName(value = "enableRecaptcha") val enableRecaptcha: kotlin.Boolean? = null,
45-
@SerialName(value = "recaptchaSiteKey") val recaptchaSiteKey: kotlin.String? = null,
46-
@SerialName(value = "enableTurnstile") val enableTurnstile: kotlin.Boolean,
47-
@SerialName(value = "turnstileSiteKey") val turnstileSiteKey: kotlin.String? = null,
48-
@SerialName(value = "swPublickey") val swPublickey: kotlin.String? = null,
49-
@SerialName(value = "mascotImageUrl") val mascotImageUrl: kotlin.String = "/assets/ai.png",
50-
@SerialName(value = "bannerUrl") val bannerUrl: kotlin.String,
51-
@SerialName(value = "serverErrorImageUrl") val serverErrorImageUrl: kotlin.String? = null,
52-
@SerialName(value = "infoImageUrl") val infoImageUrl: kotlin.String? = null,
53-
@SerialName(value = "notFoundImageUrl") val notFoundImageUrl: kotlin.String? = null,
54-
@SerialName(value = "iconUrl") val iconUrl: kotlin.String? = null,
55-
@SerialName(value = "maxNoteTextLength") val maxNoteTextLength: kotlin.Double,
56-
@SerialName(value = "ads") val ads: kotlin.collections.List<Meta200ResponseAdsInner>,
57-
@SerialName(value = "requireSetup") val requireSetup: kotlin.Boolean,
58-
@SerialName(value = "enableEmail") val enableEmail: kotlin.Boolean,
59-
@SerialName(value = "enableServiceWorker") val enableServiceWorker: kotlin.Boolean,
60-
@SerialName(value = "translatorAvailable") val translatorAvailable: kotlin.Boolean,
61-
@SerialName(value = "proxyAccountName") val proxyAccountName: kotlin.String? = null,
62-
@SerialName(value = "mediaProxy") val mediaProxy: kotlin.String,
63-
@SerialName(value = "features") val features: Meta200ResponseFeatures? = null,
23+
val maintainerName: String? = null,
24+
val maintainerEmail: String? = null,
25+
val version: String? = null,
26+
val name: String? = null,
27+
val shortName: String? = null,
28+
val uri: String? = null,
29+
val description: String? = null,
30+
val langs: List<String>? = null,
31+
@SerialName("tosUrl")
32+
val tosURL: String? = null,
33+
@SerialName("repositoryUrl")
34+
val repositoryURL: String? = null,
35+
@SerialName("feedbackUrl")
36+
val feedbackURL: String? = null,
37+
@SerialName("impressumUrl")
38+
val impressumURL: String? = null,
39+
@SerialName("privacyPolicyUrl")
40+
val privacyPolicyURL: String? = null,
41+
val disableRegistration: Boolean? = null,
42+
val emailRequiredForSignup: Boolean? = null,
43+
val enableHcaptcha: Boolean? = null,
44+
val hcaptchaSiteKey: String? = null,
45+
val enableMcaptcha: Boolean? = null,
46+
val mcaptchaSiteKey: String? = null,
47+
@SerialName("mcaptchaInstanceUrl")
48+
val mcaptchaInstanceURL: String? = null,
49+
val enableRecaptcha: Boolean? = null,
50+
val recaptchaSiteKey: String? = null,
51+
val enableTurnstile: Boolean? = null,
52+
val turnstileSiteKey: String? = null,
53+
@SerialName("googleAnalyticsId")
54+
val googleAnalyticsID: String? = null,
55+
val swPublickey: String? = null,
56+
val themeColor: String? = null,
57+
@SerialName("mascotImageUrl")
58+
val mascotImageURL: String? = null,
59+
@SerialName("bannerUrl")
60+
val bannerURL: String? = null,
61+
@SerialName("infoImageUrl")
62+
val infoImageURL: String? = null,
63+
@SerialName("serverErrorImageUrl")
64+
val serverErrorImageURL: String? = null,
65+
@SerialName("notFoundImageUrl")
66+
val notFoundImageURL: String? = null,
67+
@SerialName("iconUrl")
68+
val iconURL: String? = null,
69+
@SerialName("backgroundImageUrl")
70+
val backgroundImageURL: String? = null,
71+
@SerialName("logoImageUrl")
72+
val logoImageURL: String? = null,
73+
val maxNoteTextLength: Long? = null,
74+
val defaultLightTheme: String? = null,
75+
val defaultDarkTheme: String? = null,
76+
val ads: List<Ad>? = null,
77+
val wellKnownWebsites: List<String>? = null,
78+
val notesPerOneAd: Long? = null,
79+
val enableEmail: Boolean? = null,
80+
val enableServiceWorker: Boolean? = null,
81+
val translatorAvailable: Boolean? = null,
82+
val serverRules: List<String>? = null,
83+
val policies: Policies? = null,
84+
val mediaProxy: String? = null,
85+
@SerialName("enableUrlPreview")
86+
val enableURLPreview: Boolean? = null,
87+
val enableSkebStatus: Boolean? = null,
88+
val cacheRemoteFiles: Boolean? = null,
89+
val cacheRemoteSensitiveFiles: Boolean? = null,
90+
val requireSetup: Boolean? = null,
91+
val proxyAccountName: String? = null,
92+
val features: Map<String, Boolean>? = null,
93+
)
94+
95+
@Serializable
96+
internal data class Ad(
97+
val id: String? = null,
98+
val url: String? = null,
99+
val place: String? = null,
100+
val ratio: Long? = null,
101+
@SerialName("imageUrl")
102+
val imageURL: String? = null,
103+
val dayOfWeek: Long? = null,
104+
)
105+
106+
@Serializable
107+
internal data class Policies(
108+
val gtlAvailable: Boolean? = null,
109+
val ltlAvailable: Boolean? = null,
110+
val canPublicNote: Boolean? = null,
111+
val canScheduleNote: Boolean? = null,
112+
val scheduleNoteLimit: Long? = null,
113+
val scheduleNoteMaxDays: Long? = null,
114+
val canInitiateConversation: Boolean? = null,
115+
val canCreateContent: Boolean? = null,
116+
val canUpdateContent: Boolean? = null,
117+
val canDeleteContent: Boolean? = null,
118+
val canPurgeAccount: Boolean? = null,
119+
val canUpdateAvatar: Boolean? = null,
120+
val canUpdateBanner: Boolean? = null,
121+
val mentionLimit: Long? = null,
122+
val canInvite: Boolean? = null,
123+
val inviteLimit: Long? = null,
124+
val inviteLimitCycle: Long? = null,
125+
val inviteExpirationTime: Long? = null,
126+
val canManageCustomEmojis: Boolean? = null,
127+
val canManageAvatarDecorations: Boolean? = null,
128+
val canSearchNotes: Boolean? = null,
129+
val canUseTranslator: Boolean? = null,
130+
val canUseDriveFileInSoundSettings: Boolean? = null,
131+
val canUseReaction: Boolean? = null,
132+
val canHideAds: Boolean? = null,
133+
@SerialName("driveCapacityMb")
134+
val driveCapacityMB: Long? = null,
135+
val alwaysMarkNsfw: Boolean? = null,
136+
val skipNsfwDetection: Boolean? = null,
137+
val pinLimit: Long? = null,
138+
val antennaLimit: Long? = null,
139+
val antennaNotesLimit: Long? = null,
140+
val wordMuteLimit: Long? = null,
141+
val webhookLimit: Long? = null,
142+
val clipLimit: Long? = null,
143+
val noteEachClipsLimit: Long? = null,
144+
val userListLimit: Long? = null,
145+
val userEachUserListsLimit: Long? = null,
146+
val rateLimitFactor: Long? = null,
147+
val avatarDecorationLimit: Long? = null,
148+
val mutualLinkSectionLimit: Long? = null,
149+
val mutualLinkLimit: Long? = null,
64150
)

0 commit comments

Comments
 (0)