forked from hackers-pub/android
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModels.kt
More file actions
359 lines (317 loc) · 7.5 KB
/
Copy pathModels.kt
File metadata and controls
359 lines (317 loc) · 7.5 KB
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
package pub.hackers.android.domain.model
import androidx.compose.runtime.Immutable
import java.time.Instant
@Immutable
data class Actor(
val id: String,
val name: String?,
val handle: String,
val avatarUrl: String,
val bio: String? = null
)
@Immutable
data class ActorField(
val name: String,
val value: String
)
@Immutable
data class AccountLink(
val name: String,
val handle: String?,
val icon: String,
val url: String,
val verified: String?
)
@Immutable
data class Media(
val url: String,
val thumbnailUrl: String?,
val alt: String?,
val height: Int?,
val width: Int?,
val mediaType: String? = null
) {
val isVideo: Boolean get() = mediaType?.startsWith("video/") == true
}
@Immutable
data class UploadedMedium(
val relayId: String,
val uuid: String,
val url: String,
val width: Int,
val height: Int
)
@Immutable
data class NoteMediumAttachment(
val mediumId: String,
val alt: String
)
@Immutable
data class EngagementStats(
val replies: Int,
val reactions: Int,
val shares: Int,
val quotes: Int
)
@Immutable
data class PostLinkImage(
val url: String,
val alt: String?,
val width: Int?,
val height: Int?
)
@Immutable
data class PostLink(
val title: String?,
val description: String?,
val url: String,
val siteName: String?,
val author: String?,
val image: PostLinkImage?,
val creator: Actor?
)
@Immutable
data class Post(
val id: String,
val typename: String,
val name: String?,
val published: Instant,
val summary: String?,
val sensitive: Boolean = false,
val content: String,
val excerpt: String,
val url: String?,
val iri: String? = null,
val viewerHasShared: Boolean,
val viewerHasBookmarked: Boolean = false,
val viewerCanQuote: Boolean = true,
val actor: Actor,
val media: List<Media>,
val link: PostLink? = null,
val engagementStats: EngagementStats,
val mentions: List<String>,
val lastSharer: Actor? = null,
val sharersCount: Int = 0,
val sharedPost: Post? = null,
val replyTarget: Post? = null,
val quotedPost: Post? = null,
val visibility: PostVisibility = PostVisibility.PUBLIC,
val quotePolicy: QuotePolicy = QuotePolicy.EVERYONE,
val reactionGroups: List<ReactionGroup> = emptyList()
)
enum class PostVisibility {
PUBLIC, UNLISTED, FOLLOWERS, DIRECT, NONE
}
enum class QuotePolicy {
EVERYONE, FOLLOWERS, SELF
}
@Immutable
data class NotificationPost(
val id: String,
val content: String
)
sealed class Notification {
abstract val id: String
abstract val uuid: String
abstract val created: Instant
abstract val actors: List<Actor>
@Immutable
data class Follow(
override val id: String,
override val uuid: String,
override val created: Instant,
override val actors: List<Actor>
) : Notification()
@Immutable
data class Mention(
override val id: String,
override val uuid: String,
override val created: Instant,
override val actors: List<Actor>,
val post: NotificationPost?
) : Notification()
@Immutable
data class Reply(
override val id: String,
override val uuid: String,
override val created: Instant,
override val actors: List<Actor>,
val post: NotificationPost?
) : Notification()
@Immutable
data class Quote(
override val id: String,
override val uuid: String,
override val created: Instant,
override val actors: List<Actor>,
val post: NotificationPost?
) : Notification()
@Immutable
data class QuotedPostUpdated(
override val id: String,
override val uuid: String,
override val created: Instant,
override val actors: List<Actor>,
val post: NotificationPost?
) : Notification()
@Immutable
data class Share(
override val id: String,
override val uuid: String,
override val created: Instant,
override val actors: List<Actor>,
val post: NotificationPost?
) : Notification()
@Immutable
data class SharedPostUpdated(
override val id: String,
override val uuid: String,
override val created: Instant,
override val actors: List<Actor>,
val post: NotificationPost?
) : Notification()
@Immutable
data class React(
override val id: String,
override val uuid: String,
override val created: Instant,
override val actors: List<Actor>,
val emoji: String?,
val customEmoji: CustomEmoji?,
val post: NotificationPost?
) : Notification()
}
@Immutable
data class CustomEmoji(
val id: String,
val name: String,
val imageUrl: String
)
@Immutable
data class ReactionGroup(
val emoji: String?,
val customEmoji: CustomEmoji?,
val count: Int,
val reactors: List<Actor>,
val viewerHasReacted: Boolean = false
)
@Immutable
data class Viewer(
val id: String,
val username: String,
val name: String,
val bio: String,
val avatarUrl: String,
val handle: String
)
@Immutable
data class LoginChallenge(
val token: String
)
@Immutable
data class Session(
val id: String,
val account: Account
)
@Immutable
data class Account(
val id: String,
val username: String,
val name: String,
val avatarUrl: String,
val handle: String
)
@Immutable
data class Passkey(
val id: String,
val name: String,
val created: String,
val lastUsed: String?
)
@Immutable
data class PasskeyRegistrationResult(
val verified: Boolean,
val passkey: Passkey?
)
@Immutable
data class TimelineResult(
val posts: List<Post>,
val hasNextPage: Boolean,
val endCursor: String?,
val hasPreviousPage: Boolean = false,
val startCursor: String? = null,
)
@Immutable
data class NotificationsResult(
val notifications: List<Notification>,
val hasNextPage: Boolean,
val endCursor: String?
)
@Immutable
data class PostDetailResult(
val post: Post,
val reactionGroups: List<ReactionGroup>,
val replies: List<Post>,
val hasMoreReplies: Boolean,
val repliesEndCursor: String?,
val toc: List<TocItem> = emptyList(),
)
@Immutable
data class TocItem(
val id: String,
val level: Int,
val title: String,
val children: List<TocItem>,
)
@Immutable
data class SharesResult(
val actors: List<Actor>,
val hasNextPage: Boolean,
val endCursor: String?
)
@Immutable
data class QuotesResult(
val posts: List<Post>,
val hasNextPage: Boolean,
val endCursor: String?
)
@Immutable
data class ArticleDraft(
val id: String,
val title: String,
val content: String,
val tags: List<String>,
val created: Instant,
val updated: Instant
)
@Immutable
data class PublishedArticle(
val id: String,
val name: String?,
val url: String?
)
@Immutable
data class ProfileResult(
val actor: Actor,
val bio: String?,
val fields: List<ActorField> = emptyList(),
val accountLinks: List<AccountLink> = emptyList(),
val isViewer: Boolean = false,
val viewerFollows: Boolean = false,
val followsViewer: Boolean = false,
val viewerBlocks: Boolean = false
)
@Immutable
data class EditableAccount(
val id: String,
val name: String,
val bio: String,
val avatarUrl: String,
val handle: String,
val links: List<EditableAccountLink>
)
@Immutable
data class EditableAccountLink(
val name: String,
val url: String
)