|
1 /* |
|
2 Copyright 2017-2018 Mikael Berthe |
|
3 Copyright 2017 Ollivier Robert |
|
4 |
|
5 Licensed under the MIT license. Please see the LICENSE file is this directory. |
|
6 */ |
|
7 |
|
8 package madon |
|
9 |
|
10 import ( |
|
11 "time" |
|
12 ) |
|
13 |
|
14 // MastodonDate is a custom type for the timestamps returned by some API calls |
|
15 type MastodonDate struct { |
|
16 time.Time |
|
17 } |
|
18 |
|
19 // Client contains data for a madon client application |
|
20 type Client struct { |
|
21 Name string // Name of the client |
|
22 ID string // Application ID |
|
23 Secret string // Application secret |
|
24 APIBase string // API prefix URL |
|
25 InstanceURL string // Instance base URL |
|
26 |
|
27 UserToken *UserToken // User token |
|
28 } |
|
29 |
|
30 /* |
|
31 Entities - Everything manipulated/returned by the API |
|
32 */ |
|
33 |
|
34 // DomainName is a domain name string, as returned by the domain_blocks API |
|
35 type DomainName string |
|
36 |
|
37 // InstancePeer is a peer name, as returned by the instance/peers API |
|
38 type InstancePeer string |
|
39 |
|
40 // Account represents a Mastodon account entity |
|
41 type Account struct { |
|
42 ID int64 `json:"id,string"` |
|
43 Username string `json:"username"` |
|
44 Acct string `json:"acct"` |
|
45 DisplayName string `json:"display_name"` |
|
46 Note string `json:"note"` |
|
47 URL string `json:"url"` |
|
48 Avatar string `json:"avatar"` |
|
49 AvatarStatic string `json:"avatar_static"` |
|
50 Header string `json:"header"` |
|
51 HeaderStatic string `json:"header_static"` |
|
52 Locked bool `json:"locked"` |
|
53 CreatedAt time.Time `json:"created_at"` |
|
54 FollowersCount int64 `json:"followers_count"` |
|
55 FollowingCount int64 `json:"following_count"` |
|
56 StatusesCount int64 `json:"statuses_count"` |
|
57 Moved *Account `json:"moved"` |
|
58 Bot bool `json:"bot"` |
|
59 Emojis []Emoji `json:"emojis"` |
|
60 Fields *[]Field `json:"fields"` |
|
61 Source *SourceParams `json:"source"` |
|
62 } |
|
63 |
|
64 // Application represents a Mastodon application entity |
|
65 type Application struct { |
|
66 Name string `json:"name"` |
|
67 Website string `json:"website"` |
|
68 } |
|
69 |
|
70 // Attachment represents a Mastodon media attachment entity |
|
71 type Attachment struct { |
|
72 ID int64 `json:"id,string"` |
|
73 Type string `json:"type"` |
|
74 URL string `json:"url"` |
|
75 RemoteURL *string `json:"remote_url"` |
|
76 PreviewURL string `json:"preview_url"` |
|
77 TextURL *string `json:"text_url"` |
|
78 Meta *struct { |
|
79 Original struct { |
|
80 Size string `json:"size"` |
|
81 Aspect float64 `json:"aspect"` |
|
82 Width int `json:"width"` |
|
83 Height int `json:"height"` |
|
84 } `json:"original"` |
|
85 Small struct { |
|
86 Size string `json:"size"` |
|
87 Aspect float64 `json:"aspect"` |
|
88 Width int `json:"width"` |
|
89 Height int `json:"height"` |
|
90 } `json:"small"` |
|
91 } `json:"meta"` |
|
92 Description *string `json:"description"` |
|
93 } |
|
94 |
|
95 // Card represents a Mastodon preview card entity |
|
96 type Card struct { |
|
97 URL string `json:"url"` |
|
98 Title string `json:"title"` |
|
99 Description string `json:"description"` |
|
100 Image string `json:"image"` |
|
101 Type *string `json:"type"` |
|
102 AuthorName *string `json:"author_name"` |
|
103 AuthorURL *string `json:"author_url"` |
|
104 ProviderName *string `json:"provider_name"` |
|
105 ProviderURL *string `json:"provider_url"` |
|
106 EmbedURL *string `json:"embed_url"` |
|
107 HTML *string `json:"html"` |
|
108 Width *int `json:"width"` |
|
109 Height *int `json:"height"` |
|
110 } |
|
111 |
|
112 // Context represents a Mastodon context entity |
|
113 type Context struct { |
|
114 Ancestors []Status `json:"ancestors"` |
|
115 Descendants []Status `json:"descendants"` |
|
116 } |
|
117 |
|
118 // Emoji represents a Mastodon emoji entity |
|
119 type Emoji struct { |
|
120 ShortCode string `json:"shortcode"` |
|
121 URL string `json:"url"` |
|
122 StaticURL string `json:"static_url"` |
|
123 VisibleInPicker bool `json:"visible_in_picker"` |
|
124 } |
|
125 |
|
126 // Error represents a Mastodon error entity |
|
127 type Error struct { |
|
128 Text string `json:"error"` |
|
129 } |
|
130 |
|
131 // Instance represents a Mastodon instance entity |
|
132 type Instance struct { |
|
133 URI string `json:"uri"` |
|
134 Title string `json:"title"` |
|
135 Description string `json:"description"` |
|
136 Email string `json:"email"` |
|
137 Version string `json:"version"` |
|
138 |
|
139 URLs struct { |
|
140 SteamingAPI string `json:"streaming_api"` |
|
141 } `json:"urls"` |
|
142 Stats struct { |
|
143 UserCount int64 `json:"user_count"` |
|
144 StatusCount int64 `json:"status_count"` |
|
145 DomainCount int64 `json:"domain_count"` |
|
146 } `json:"stats"` |
|
147 Thumbnail *string `json:"thumbnail"` |
|
148 Languages []string `json:"languages"` |
|
149 ContactAccount *Account `json:"contact_account"` |
|
150 } |
|
151 |
|
152 // List represents a Mastodon list entity |
|
153 type List struct { |
|
154 ID int64 `json:"id,string"` |
|
155 Title string `json:"title"` |
|
156 } |
|
157 |
|
158 // Mention represents a Mastodon mention entity |
|
159 type Mention struct { |
|
160 ID int64 `json:"id,string"` |
|
161 URL string `json:"url"` |
|
162 Username string `json:"username"` |
|
163 Acct string `json:"acct"` |
|
164 } |
|
165 |
|
166 // Notification represents a Mastodon notification entity |
|
167 type Notification struct { |
|
168 ID int64 `json:"id,string"` |
|
169 Type string `json:"type"` |
|
170 CreatedAt time.Time `json:"created_at"` |
|
171 Account *Account `json:"account"` |
|
172 Status *Status `json:"status"` |
|
173 } |
|
174 |
|
175 // Relationship represents a Mastodon relationship entity |
|
176 type Relationship struct { |
|
177 ID int64 `json:"id,string"` |
|
178 Following bool `json:"following"` |
|
179 //ShowingReblogs bool `json:"showing_reblogs"` // Incoherent type |
|
180 FollowedBy bool `json:"followed_by"` |
|
181 Blocking bool `json:"blocking"` |
|
182 Muting bool `json:"muting"` |
|
183 Requested bool `json:"requested"` |
|
184 DomainBlocking bool `jsin:"domain_blocking"` |
|
185 MutingNotifications bool `json:"muting_notifications"` |
|
186 ShowingReblogs bool `json:"showing_reblogs"` |
|
187 Endorsed bool `json:"endorsed"` |
|
188 } |
|
189 |
|
190 // Report represents a Mastodon report entity |
|
191 type Report struct { |
|
192 ID int64 `json:"id,string"` |
|
193 ActionTaken string `json:"action_taken"` |
|
194 } |
|
195 |
|
196 // Results represents a Mastodon search results entity |
|
197 type Results struct { |
|
198 Accounts []Account `json:"accounts"` |
|
199 Statuses []Status `json:"statuses"` |
|
200 Hashtags []Tag `json:"hashtags"` |
|
201 } |
|
202 |
|
203 // Status represents a Mastodon status entity |
|
204 type Status struct { |
|
205 ID int64 `json:"id,string"` |
|
206 URI string `json:"uri"` |
|
207 URL string `json:"url"` |
|
208 Account *Account `json:"account"` |
|
209 InReplyToID *int64 `json:"in_reply_to_id,string"` |
|
210 InReplyToAccountID *int64 `json:"in_reply_to_account_id,string"` |
|
211 Reblog *Status `json:"reblog"` |
|
212 Content string `json:"content"` |
|
213 CreatedAt time.Time `json:"created_at"` |
|
214 ReblogsCount int64 `json:"reblogs_count"` |
|
215 FavouritesCount int64 `json:"favourites_count"` |
|
216 RepliesCount int64 `json:"replies_count"` |
|
217 Reblogged bool `json:"reblogged"` |
|
218 Favourited bool `json:"favourited"` |
|
219 Muted bool `json:"muted"` |
|
220 Pinned bool `json:"pinned"` |
|
221 Sensitive bool `json:"sensitive"` |
|
222 SpoilerText string `json:"spoiler_text"` |
|
223 Visibility string `json:"visibility"` |
|
224 MediaAttachments []Attachment `json:"media_attachments"` |
|
225 Mentions []Mention `json:"mentions"` |
|
226 Tags []Tag `json:"tags"` |
|
227 Emojis []Emoji `json:"emojis"` |
|
228 Application *Application `json:"application"` |
|
229 Language *string `json:"language"` |
|
230 } |
|
231 |
|
232 // Tag represents a Mastodon tag entity |
|
233 type Tag struct { |
|
234 Name string `json:"name"` |
|
235 URL string `json:"url"` |
|
236 History []struct { |
|
237 Day MastodonDate `json:"day"` |
|
238 Uses int64 `json:"uses,string"` |
|
239 Accounts int64 `json:"accounts,string"` |
|
240 } `json:"history"` |
|
241 } |
|
242 |
|
243 // WeekActivity represents a Mastodon instance activity "week" entity |
|
244 type WeekActivity struct { |
|
245 Week MastodonDate `json:"week"` |
|
246 Statuses int64 `json:"statuses,string"` |
|
247 Logins int64 `json:"logins,string"` |
|
248 Registrations int64 `json:"registrations,string"` |
|
249 } |
|
250 |
|
251 // Field is a single field structure |
|
252 // (Used for the verify_credentials endpoint) |
|
253 type Field struct { |
|
254 Name string `json:"name"` |
|
255 Value string `json:"value"` |
|
256 } |
|
257 |
|
258 // SourceParams is a source params structure |
|
259 type SourceParams struct { // Used for verify_credentials |
|
260 Privacy *string `json:"privacy,omitempty"` |
|
261 Language *string `json:"language,omitempty"` |
|
262 Sensitive *bool `json:"sensitive,omitempty"` |
|
263 Note *string `json:"note,omitempty"` |
|
264 Fields *[]Field `json:"fields,omitempty"` |
|
265 } |