From 2a22a0bedd3aef3b58dfc7d9cc9426493a24f398 Mon Sep 17 00:00:00 2001 From: silverpill Date: Thu, 7 Jul 2022 14:56:01 +0000 Subject: [PATCH] Add exclude_replies query parameter to /accounts/:id/statuses API method --- docs/openapi.yaml | 7 +++++++ src/mastodon_api/accounts/types.rs | 5 +++++ src/mastodon_api/accounts/views.rs | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/openapi.yaml b/docs/openapi.yaml index eb2c890..3792e8d 100644 --- a/docs/openapi.yaml +++ b/docs/openapi.yaml @@ -199,6 +199,13 @@ paths: summary: Posts created by the given actor. parameters: - $ref: '#/components/parameters/account_id' + - name: exclude_replies + in: query + description: Exclude replies from results. + required: false + schema: + type: boolean + default: true - name: max_id in: query description: Return results older than this ID. diff --git a/src/mastodon_api/accounts/types.rs b/src/mastodon_api/accounts/types.rs index e18d593..d5fee6e 100644 --- a/src/mastodon_api/accounts/types.rs +++ b/src/mastodon_api/accounts/types.rs @@ -282,8 +282,13 @@ pub struct FollowData { fn default_page_size() -> i64 { 20 } +fn default_exclude_replies() -> bool { true } + #[derive(Deserialize)] pub struct StatusListQueryParams { + #[serde(default = "default_exclude_replies")] + pub exclude_replies: bool, + #[serde(default)] pub pinned: bool, diff --git a/src/mastodon_api/accounts/views.rs b/src/mastodon_api/accounts/views.rs index 2dd46d4..95f182a 100644 --- a/src/mastodon_api/accounts/views.rs +++ b/src/mastodon_api/accounts/views.rs @@ -430,7 +430,7 @@ async fn get_account_statuses( db_client, &profile.id, maybe_current_user.as_ref().map(|user| &user.id), - false, + !query_params.exclude_replies, true, query_params.max_id, query_params.limit,