-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(api_apub): update openapi docs (#71)
* refactor(api_apub): add notice openapi docs * refactor(api_apub): add user_* openapi docs * refactor(apub): split structs * refactor(api_apub): strict user_* types * fix(apub/collection): fix total pages
- Loading branch information
Showing
13 changed files
with
266 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use activitypub_federation::kinds::collection::OrderedCollectionType; | ||
use hatsu_utils::AppError; | ||
use serde::{Deserialize, Serialize}; | ||
use url::Url; | ||
use utoipa::ToSchema; | ||
|
||
use crate::collections::generate_collection_page_url; | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize, ToSchema)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct Collection { | ||
#[serde(rename = "type")] | ||
pub kind: OrderedCollectionType, | ||
// example: https://hatsu.local/users/example.com/collection | ||
pub id: Url, | ||
// example: https://hatsu.local/users/example.com/collection?page=1 | ||
pub first: Url, | ||
// example: https://hatsu.local/users/example.com/collection?page=64 | ||
pub last: Url, | ||
// collection count | ||
pub total_items: u64, | ||
} | ||
|
||
impl Collection { | ||
pub fn new(collection_id: &Url, total_items: u64, total_pages: u64) -> Result<Self, AppError> { | ||
Ok(Self { | ||
kind: OrderedCollectionType::OrderedCollection, | ||
id: collection_id.clone(), | ||
first: generate_collection_page_url(collection_id, 1)?, | ||
last: generate_collection_page_url(collection_id, match total_pages { | ||
page if page > 0 => page, | ||
_ => 1, | ||
})?, | ||
total_items, | ||
}) | ||
} | ||
} |
Oops, something went wrong.