summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRanfdev <ranfdev@gmail.com>2020-06-25 12:37:47 +0200
committerPaul Woolcock <paul@woolcock.us>2020-09-25 12:08:07 -0400
commit4afb3c3d7405c496857415920afd04d2db01c987 (patch)
tree35c058182d0f7b0a4466c6cd37c2002b675ae1c4
parent632a00f13793f35fbb7f873c694ec8939e0c7ab2 (diff)
added methods returning pages for timelines home, local, federated, hashtag
-rw-r--r--src/lib.rs7
-rw-r--r--src/mastodon_client.rs10
2 files changed, 11 insertions, 6 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 747ebe6..4345abf 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -212,6 +212,8 @@ impl<H: HttpSend> MastodonClient<H> for Mastodon<H> {
(get) domain_blocks: "domain_blocks" => String,
(get) follow_requests: "follow_requests" => Account,
(get) get_home_timeline: "timelines/home" => Status,
+ (get) get_local_timeline: "timelines/public?local=true" => Status,
+ (get) get_federated_timeline: "timelines/public?local=false" => Status,
(get) get_emojis: "custom_emojis" => Emoji,
(get) mutes: "mutes" => Account,
(get) notifications: "notifications" => Notification,
@@ -236,7 +238,6 @@ impl<H: HttpSend> MastodonClient<H> for Mastodon<H> {
(post (id: &str,)) authorize_follow_request: "accounts/follow_requests/authorize" => Empty,
(post (id: &str,)) reject_follow_request: "accounts/follow_requests/reject" => Empty,
(get (q: &'a str, resolve: bool,)) search: "search" => SearchResult,
- (get (local: bool,)) get_public_timeline: "timelines/public" => Vec<Status>,
(post (uri: Cow<'static, str>,)) follows: "follows" => Account,
(post multipart (file: Cow<'static, str>,)) media: "media" => Attachment,
(post) clear_notifications: "notifications/clear" => Empty,
@@ -335,7 +336,7 @@ impl<H: HttpSend> MastodonClient<H> for Mastodon<H> {
/// Get timeline filtered by a hashtag(eg. `#coffee`) either locally or
/// federated.
- fn get_tagged_timeline(&self, hashtag: String, local: bool) -> Result<Vec<Status>> {
+ fn get_hashtag_timeline(&self, hashtag: &str, local: bool) -> Result<Page<Status, H>> {
let base = "/api/v1/timelines/tag/";
let url = if local {
self.route(&format!("{}{}?local=1", base, hashtag))
@@ -343,7 +344,7 @@ impl<H: HttpSend> MastodonClient<H> for Mastodon<H> {
self.route(&format!("{}{}", base, hashtag))
};
- self.get(url)
+ Page::new(self, self.send(self.client.get(&url))?)
}
/// Get statuses of a single account by id. Optionally only with pictures
diff --git a/src/mastodon_client.rs b/src/mastodon_client.rs
index e338e96..f65eda7 100644
--- a/src/mastodon_client.rs
+++ b/src/mastodon_client.rs
@@ -196,12 +196,16 @@ pub trait MastodonClient<H: HttpSend = HttpSender> {
fn new_status(&self, status: NewStatus) -> Result<Status> {
unimplemented!("This method was not implemented");
}
- /// GET /api/v1/timelines/public
- fn get_public_timeline(&self, local: bool) -> Result<Vec<Status>> {
+/// GET /api/v1/timelines/public?local=true
+ fn get_local_timeline(&self) -> Result<Page<Status, H>> {
+ unimplemented!("This method was not implemented");
+ }
+/// GET /api/v1/timelines/public?local=false
+ fn get_federated_timeline(&self) -> Result<Page<Status, H>> {
unimplemented!("This method was not implemented");
}
/// GET /api/v1/timelines/tag/:hashtag
- fn get_tagged_timeline(&self, hashtag: String, local: bool) -> Result<Vec<Status>> {
+ fn get_hashtag_timeline(&self, hashtag: &str, local: bool) -> Result<Page<Status, H>> {
unimplemented!("This method was not implemented");
}
/// GET /api/v1/accounts/:id/statuses