Merge pull request #1317 from Linkid/mastodon_pin_unpin
Mastodon: add pin / unpin toots
This commit is contained in:
commit
ea37aee5a5
|
@ -69,4 +69,10 @@ public interface StatusesResources {
|
|||
|
||||
@POST("/v1/statuses/{id}/unfavourite")
|
||||
Status unfavouriteStatus(@Path("id") String id) throws MicroBlogException;
|
||||
|
||||
@POST("/v1/statuses/{id}/pin")
|
||||
Status pinStatus(@Path("id") String id) throws MicroBlogException;
|
||||
|
||||
@POST("/v1/statuses/{id}/unpin")
|
||||
Status unpinStatus(@Path("id") String id) throws MicroBlogException;
|
||||
}
|
||||
|
|
|
@ -103,6 +103,11 @@ public class Status {
|
|||
*/
|
||||
@JsonField(name = "sensitive")
|
||||
boolean sensitive;
|
||||
/**
|
||||
* Whether the authenticated user has pinned the status
|
||||
*/
|
||||
@JsonField(name = "pinned")
|
||||
boolean pinned;
|
||||
/**
|
||||
* If not empty, warning text that should be displayed before the actual content
|
||||
*/
|
||||
|
@ -194,6 +199,10 @@ public class Status {
|
|||
return sensitive;
|
||||
}
|
||||
|
||||
public boolean isPinned() {
|
||||
return pinned;
|
||||
}
|
||||
|
||||
public String getSpoilerText() {
|
||||
return spoilerText;
|
||||
}
|
||||
|
@ -251,6 +260,7 @@ public class Status {
|
|||
", reblogged=" + reblogged +
|
||||
", favourited=" + favourited +
|
||||
", sensitive=" + sensitive +
|
||||
", pinned=" + pinned +
|
||||
", spoilerText='" + spoilerText + '\'' +
|
||||
", visibility='" + visibility + '\'' +
|
||||
", mediaAttachments=" + Arrays.toString(mediaAttachments) +
|
||||
|
|
|
@ -22,8 +22,12 @@ package org.mariotaku.twidere.task.status
|
|||
import android.content.Context
|
||||
import android.widget.Toast
|
||||
import org.mariotaku.microblog.library.MicroBlog
|
||||
import org.mariotaku.microblog.library.MicroBlogException
|
||||
import org.mariotaku.microblog.library.mastodon.Mastodon
|
||||
import org.mariotaku.microblog.library.twitter.model.PinTweetResult
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.annotation.AccountType
|
||||
import org.mariotaku.twidere.exception.APINotSupportedException
|
||||
import org.mariotaku.twidere.extension.model.newMicroBlogInstance
|
||||
import org.mariotaku.twidere.model.AccountDetails
|
||||
import org.mariotaku.twidere.model.UserKey
|
||||
|
@ -37,10 +41,21 @@ import org.mariotaku.twidere.task.AbsAccountRequestTask
|
|||
class PinStatusTask(context: Context, accountKey: UserKey, val id: String) : AbsAccountRequestTask<Any?,
|
||||
PinTweetResult, Any?>(context, accountKey) {
|
||||
|
||||
@Throws(MicroBlogException::class)
|
||||
override fun onExecute(account: AccountDetails, params: Any?): PinTweetResult {
|
||||
when (account.type) {
|
||||
AccountType.MASTODON -> {
|
||||
val mastodon = account.newMicroBlogInstance(context, Mastodon::class.java)
|
||||
return mastodon.pinStatus(id)
|
||||
}
|
||||
AccountType.TWITTER -> {
|
||||
val twitter = account.newMicroBlogInstance(context, MicroBlog::class.java)
|
||||
return twitter.pinTweet(id)
|
||||
}
|
||||
else -> {
|
||||
throw APINotSupportedException(account.type)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSucceed(callback: Any?, result: PinTweetResult) {
|
||||
super.onSucceed(callback, result)
|
||||
|
|
|
@ -22,6 +22,8 @@ package org.mariotaku.twidere.task.status
|
|||
import android.content.Context
|
||||
import android.widget.Toast
|
||||
import org.mariotaku.microblog.library.MicroBlog
|
||||
import org.mariotaku.microblog.library.MicroBlogException
|
||||
import org.mariotaku.microblog.library.mastodon.Mastodon
|
||||
import org.mariotaku.microblog.library.twitter.model.PinTweetResult
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.extension.model.newMicroBlogInstance
|
||||
|
@ -29,6 +31,8 @@ import org.mariotaku.twidere.model.AccountDetails
|
|||
import org.mariotaku.twidere.model.UserKey
|
||||
import org.mariotaku.twidere.model.event.StatusPinEvent
|
||||
import org.mariotaku.twidere.task.AbsAccountRequestTask
|
||||
import org.mariotaku.twidere.annotation.AccountType
|
||||
import org.mariotaku.twidere.exception.APINotSupportedException
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2017/4/28.
|
||||
|
@ -37,10 +41,21 @@ import org.mariotaku.twidere.task.AbsAccountRequestTask
|
|||
class UnpinStatusTask(context: Context, accountKey: UserKey, val id: String) : AbsAccountRequestTask<Any?,
|
||||
PinTweetResult, Any?>(context, accountKey) {
|
||||
|
||||
@Throws(MicroBlogException::class)
|
||||
override fun onExecute(account: AccountDetails, params: Any?): PinTweetResult {
|
||||
when (account.type) {
|
||||
AccountType.MASTODON -> {
|
||||
val mastodon = account.newMicroBlogInstance(context, Mastodon::class.java)
|
||||
return mastodon.unpinStatus(id)
|
||||
}
|
||||
AccountType.TWITTER -> {
|
||||
val twitter = account.newMicroBlogInstance(context, MicroBlog::class.java)
|
||||
return twitter.unpinTweet(id)
|
||||
}
|
||||
else -> {
|
||||
throw APINotSupportedException(account.type)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSucceed(callback: Any?, result: PinTweetResult) {
|
||||
super.onSucceed(callback, result)
|
||||
|
|
Loading…
Reference in New Issue