-
Notifications
You must be signed in to change notification settings - Fork 0
/
MastodonInstance.swift
145 lines (115 loc) · 3.23 KB
/
MastodonInstance.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
//
// MastodonInstance.swift
// Mastodon
//
// Created by Nathan Wale on 1/11/2023.
//
import Foundation
///
/// A Mastodon Instance (or server)
///
struct MastodonInstance: Codable
{
/// Domain name of the instance
let domain: String
/// Name of the instance
let title: String
/// Version of Mastodon installed
let version: String
/// Location of the source code for the software running this instance
/// (This is a requirement of the AGPL license)
let sourceUrl: URL
/// Description of the instance
let description: String
/// Usage data for this Instance
let usage: Usage
/// Thumbnail image for this Instance
let thumbnail: Thumbnail
/// Primary languages of this Instance, as a list of two-letter codes
let languages: [String]
/// Configuration for this instance
let configuration: MastodonInstanceConfiguration
/// Registration information about this instance
let registrations: Registrations
/// Contact information for this instance
let contact: Contact
/// Rules for this instance
let rules: [Rule]
}
// MARK: - inner types
extension MastodonInstance
{
///
/// Usage data for an Instance
///
struct Usage: Codable
{
/// User stats
let users: Users
/// User stats for an instance
struct Users: Codable
{
/// Number of active users in the past 4 weeks
let activeMonth: Int
}
}
///
/// Thumbnail image for an Instance
///
struct Thumbnail: Codable
{
/// Location of thumbnail image
let url: URL
/// Blurhash of thumbnail
let blurhash: String?
/// Different thumbnail resolutions
let versions: Versions?
/// Different thumbnail resolutions
struct Versions: Codable
{
/// 1⨉ resolution
let singleResolution: URL?
/// 2⨉ resolution
let doubleResolution: URL?
enum CodingKeys: String, CodingKey
{
case singleResolution = "@1x"
case doubleResolution = "@2x"
}
}
}
///
/// Info about registration for an Instance
///
struct Registrations: Codable
{
/// Are registrations currently enabled?
let enabled: Bool
/// Is moderator approval required to register?
let approvalRequired: Bool
/// Message to be shown when registrations are closed
let message: String?
/// Undocumented `url` paramater. Optional
let url: URL?
}
///
/// Contact information for an Instance
///
struct Contact: Codable
{
/// Email address for this instance
let email: String
/// A Mastodon account that can be contacted about this instance
let account: MastodonAccount
}
///
/// A Rule regarding an Instance
///
struct Rule: Codable, Identifiable
{
/// Identifier
let id: String
/// Description of the rule
let text: String
}
}