1
1
package social.bigbone.rx
2
2
3
- import io.reactivex.rxjava3.core.Completable
4
3
import io.reactivex.rxjava3.core.Single
5
4
import social.bigbone.MastodonClient
6
5
import social.bigbone.api.Pageable
7
6
import social.bigbone.api.Range
8
7
import social.bigbone.api.entity.Account
9
8
import social.bigbone.api.entity.Context
10
- import social.bigbone.api.entity.PreviewCard
9
+ import social.bigbone.api.entity.ScheduledStatus
11
10
import social.bigbone.api.entity.Status
11
+ import social.bigbone.api.entity.Translation
12
12
import social.bigbone.api.method.StatusMethods
13
13
14
14
/* *
@@ -41,17 +41,19 @@ class RxStatusMethods(client: MastodonClient) {
41
41
}
42
42
}
43
43
44
- fun getCard (statusId : String ): Single <PreviewCard > {
44
+ @JvmOverloads
45
+ fun translateStatus (statusId : String , language : String? = null): Single <Translation > {
45
46
return Single .create {
46
47
try {
47
- val context = statusMethods.getCard (statusId)
48
- it.onSuccess(context .execute())
48
+ val translation = statusMethods.translateStatus (statusId, language )
49
+ it.onSuccess(translation .execute())
49
50
} catch (e: Throwable ) {
50
51
it.onError(e)
51
52
}
52
53
}
53
54
}
54
55
56
+ @JvmOverloads
55
57
fun getRebloggedBy (statusId : String , range : Range = Range ()): Single <Pageable <Account >> {
56
58
return Single .create {
57
59
try {
@@ -63,7 +65,7 @@ class RxStatusMethods(client: MastodonClient) {
63
65
}
64
66
}
65
67
66
- // GET /api/v1/favourited_by
68
+ @JvmOverloads
67
69
fun getFavouritedBy (statusId : String , range : Range = Range ()): Single <Pageable <Account >> {
68
70
return Single .create {
69
71
try {
@@ -75,39 +77,133 @@ class RxStatusMethods(client: MastodonClient) {
75
77
}
76
78
}
77
79
80
+ @JvmOverloads
78
81
fun postStatus (
79
82
status : String ,
80
83
inReplyToId : String? = null,
81
84
mediaIds : List <String >? = null,
82
85
sensitive : Boolean = false,
83
86
spoilerText : String? = null,
84
- visibility : Status .Visibility = Status .Visibility .Public
87
+ visibility : Status .Visibility = Status .Visibility .Public ,
88
+ language : String? = null
85
89
): Single <Status > {
86
90
return Single .create {
87
91
try {
88
- val result = statusMethods.postStatus(status, inReplyToId, mediaIds, sensitive, spoilerText, visibility)
92
+ val result = statusMethods.postStatus(status, inReplyToId, mediaIds, sensitive, spoilerText, visibility, language )
89
93
it.onSuccess(result.execute())
90
94
} catch (e: Throwable ) {
91
95
it.onError(e)
92
96
}
93
97
}
94
98
}
95
99
96
- fun deleteStatus (statusId : String ): Completable {
97
- return Completable .create {
100
+ @JvmOverloads
101
+ fun postPoll (
102
+ status : String ,
103
+ pollOptions : List <String >,
104
+ pollExpiresIn : Int ,
105
+ pollMultiple : Boolean = false,
106
+ pollHideTotals : Boolean = false,
107
+ inReplyToId : String? = null,
108
+ sensitive : Boolean = false,
109
+ spoilerText : String? = null,
110
+ visibility : Status .Visibility = Status .Visibility .Public ,
111
+ language : String? = null
112
+ ): Single <Status > {
113
+ return Single .create {
98
114
try {
99
- statusMethods.deleteStatus(statusId)
100
- it.onComplete()
115
+ val result = statusMethods.postPoll(
116
+ status,
117
+ pollOptions,
118
+ pollExpiresIn,
119
+ pollMultiple,
120
+ pollHideTotals,
121
+ inReplyToId,
122
+ sensitive,
123
+ spoilerText,
124
+ visibility,
125
+ language
126
+ )
127
+ it.onSuccess(result.execute())
101
128
} catch (e: Throwable ) {
102
129
it.onError(e)
103
130
}
104
131
}
105
132
}
106
133
107
- fun reblogStatus (statusId : String ): Single <Status > {
134
+ @JvmOverloads
135
+ fun scheduleStatus (
136
+ status : String ,
137
+ inReplyToId : String? = null,
138
+ mediaIds : List <String >? = null,
139
+ sensitive : Boolean = false,
140
+ spoilerText : String? = null,
141
+ visibility : Status .Visibility = Status .Visibility .Public ,
142
+ language : String? = null,
143
+ scheduledAt : String
144
+ ): Single <ScheduledStatus > {
108
145
return Single .create {
109
146
try {
110
- val status = statusMethods.reblogStatus(statusId)
147
+ val result = statusMethods.scheduleStatus(status, inReplyToId, mediaIds, sensitive, spoilerText, visibility, language, scheduledAt)
148
+ it.onSuccess(result.execute())
149
+ } catch (e: Throwable ) {
150
+ it.onError(e)
151
+ }
152
+ }
153
+ }
154
+
155
+ @JvmOverloads
156
+ fun schedulePoll (
157
+ status : String ,
158
+ pollOptions : List <String >,
159
+ pollExpiresIn : Int ,
160
+ pollMultiple : Boolean = false,
161
+ pollHideTotals : Boolean = false,
162
+ inReplyToId : String? = null,
163
+ sensitive : Boolean = false,
164
+ spoilerText : String? = null,
165
+ visibility : Status .Visibility = Status .Visibility .Public ,
166
+ language : String? = null,
167
+ scheduledAt : String
168
+ ): Single <ScheduledStatus > {
169
+ return Single .create {
170
+ try {
171
+ val result = statusMethods.schedulePoll(
172
+ status,
173
+ pollOptions,
174
+ pollExpiresIn,
175
+ pollMultiple,
176
+ pollHideTotals,
177
+ inReplyToId,
178
+ sensitive,
179
+ spoilerText,
180
+ visibility,
181
+ language,
182
+ scheduledAt
183
+ )
184
+ it.onSuccess(result.execute())
185
+ } catch (e: Throwable ) {
186
+ it.onError(e)
187
+ }
188
+ }
189
+ }
190
+
191
+ fun deleteStatus (statusId : String ): Single <Status > {
192
+ return Single .create {
193
+ try {
194
+ val status = statusMethods.deleteStatus(statusId)
195
+ it.onSuccess(status.execute())
196
+ } catch (e: Throwable ) {
197
+ it.onError(e)
198
+ }
199
+ }
200
+ }
201
+
202
+ @JvmOverloads
203
+ fun reblogStatus (statusId : String , visibility : Status .Visibility = Status .Visibility .Public ): Single <Status > {
204
+ return Single .create {
205
+ try {
206
+ val status = statusMethods.reblogStatus(statusId, visibility)
111
207
it.onSuccess(status.execute())
112
208
} catch (e: Throwable ) {
113
209
it.onError(e)
@@ -147,4 +243,70 @@ class RxStatusMethods(client: MastodonClient) {
147
243
}
148
244
}
149
245
}
246
+
247
+ fun bookmarkStatus (statusId : String ): Single <Status > {
248
+ return Single .create {
249
+ try {
250
+ val status = statusMethods.bookmarkStatus(statusId)
251
+ it.onSuccess(status.execute())
252
+ } catch (e: Throwable ) {
253
+ it.onError(e)
254
+ }
255
+ }
256
+ }
257
+
258
+ fun unbookmarkStatus (statusId : String ): Single <Status > {
259
+ return Single .create {
260
+ try {
261
+ val status = statusMethods.unbookmarkStatus(statusId)
262
+ it.onSuccess(status.execute())
263
+ } catch (e: Throwable ) {
264
+ it.onError(e)
265
+ }
266
+ }
267
+ }
268
+
269
+ fun muteConversation (statusId : String ): Single <Status > {
270
+ return Single .create {
271
+ try {
272
+ val status = statusMethods.muteConversation(statusId)
273
+ it.onSuccess(status.execute())
274
+ } catch (e: Throwable ) {
275
+ it.onError(e)
276
+ }
277
+ }
278
+ }
279
+
280
+ fun unmuteConversation (statusId : String ): Single <Status > {
281
+ return Single .create {
282
+ try {
283
+ val status = statusMethods.unmuteConversation(statusId)
284
+ it.onSuccess(status.execute())
285
+ } catch (e: Throwable ) {
286
+ it.onError(e)
287
+ }
288
+ }
289
+ }
290
+
291
+ fun pinStatus (statusId : String ): Single <Status > {
292
+ return Single .create {
293
+ try {
294
+ val status = statusMethods.pinStatus(statusId)
295
+ it.onSuccess(status.execute())
296
+ } catch (e: Throwable ) {
297
+ it.onError(e)
298
+ }
299
+ }
300
+ }
301
+
302
+ fun unpinStatus (statusId : String ): Single <Status > {
303
+ return Single .create {
304
+ try {
305
+ val status = statusMethods.unpinStatus(statusId)
306
+ it.onSuccess(status.execute())
307
+ } catch (e: Throwable ) {
308
+ it.onError(e)
309
+ }
310
+ }
311
+ }
150
312
}
0 commit comments