Add a bunch of "old" methods to be able to still use java code

This commit is contained in:
Lakoja 2023-09-11 22:19:34 +02:00
commit 4f865ec95f
4 changed files with 148 additions and 43 deletions

View file

@ -88,6 +88,50 @@ class TimelineCases @Inject constructor(
}
}
fun reblogOld(statusId: String, reblog: Boolean): Single<Status> {
val call = if (reblog) {
mastodonApi.reblogStatusOld(statusId)
} else {
mastodonApi.unreblogStatusOld(statusId)
}
return call.doAfterSuccess {
eventHub.dispatchOld(ReblogEvent(statusId, reblog))
}
}
fun favouriteOld(statusId: String, favourite: Boolean): Single<Status> {
val call = if (favourite) {
mastodonApi.favouriteStatusOld(statusId)
} else {
mastodonApi.unfavouriteStatusOld(statusId)
}
return call.doAfterSuccess {
eventHub.dispatchOld(FavoriteEvent(statusId, favourite))
}
}
fun bookmarkOld(statusId: String, bookmark: Boolean): Single<Status> {
val call = if (bookmark) {
mastodonApi.bookmarkStatusOld(statusId)
} else {
mastodonApi.unbookmarkStatusOld(statusId)
}
return call.doAfterSuccess {
eventHub.dispatchOld(BookmarkEvent(statusId, bookmark))
}
}
fun muteConversationOld(statusId: String, mute: Boolean): Single<Status> {
val call = if (mute) {
mastodonApi.muteConversationOld(statusId)
} else {
mastodonApi.unmuteConversationOld(statusId)
}
return call.doAfterSuccess {
eventHub.dispatchOld(MuteConversationEvent(statusId, mute))
}
}
suspend fun mute(statusId: String, notifications: Boolean, duration: Int?) {
try {
mastodonApi.muteAccount(statusId, notifications, duration)
@ -136,6 +180,16 @@ class TimelineCases @Inject constructor(
}
}
fun voteInPollOld(statusId: String, pollId: String, choices: List<Int>): Single<Poll> {
if (choices.isEmpty()) {
return Single.error(IllegalStateException())
}
return mastodonApi.voteInPollOld(pollId, choices).doAfterSuccess {
eventHub.dispatchOld(PollVoteEvent(statusId, it))
}
}
fun acceptFollowRequest(accountId: String): Single<Relationship> {
return mastodonApi.authorizeFollowRequest(accountId)
}