Add /api/v1/{status_id}/thread API endpoint
This commit is contained in:
parent
9fd6724819
commit
23b44ce0db
3 changed files with 44 additions and 0 deletions
|
@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- Added OAuth authorization page.
|
- Added OAuth authorization page.
|
||||||
- Support `authorization_code` OAuth grant type.
|
- Support `authorization_code` OAuth grant type.
|
||||||
- Documented `http_cors_allowlist` configuration parameter.
|
- Documented `http_cors_allowlist` configuration parameter.
|
||||||
|
- Added `/api/v1/{status_id}/thread` API endpoint (replaces `/api/v1/{status_id}/context`).
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|
|
@ -943,6 +943,22 @@ paths:
|
||||||
description: Post does not belong to user
|
description: Post does not belong to user
|
||||||
404:
|
404:
|
||||||
description: Post not found
|
description: Post not found
|
||||||
|
/api/v1/statuses/{status_id}/thread:
|
||||||
|
get:
|
||||||
|
summary: Get thread that contains given post.
|
||||||
|
parameters:
|
||||||
|
- $ref: '#/components/parameters/status_id'
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: Successful operation.
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/Status'
|
||||||
|
404:
|
||||||
|
description: Post not found
|
||||||
/api/v1/statuses/{status_id}/favourite:
|
/api/v1/statuses/{status_id}/favourite:
|
||||||
post:
|
post:
|
||||||
summary: Add post to your favourites list
|
summary: Add post to your favourites list
|
||||||
|
|
|
@ -305,6 +305,32 @@ async fn get_context(
|
||||||
Ok(HttpResponse::Ok().json(statuses))
|
Ok(HttpResponse::Ok().json(statuses))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[get("/{status_id}/thread")]
|
||||||
|
async fn get_thread_view(
|
||||||
|
auth: Option<BearerAuth>,
|
||||||
|
config: web::Data<Config>,
|
||||||
|
db_pool: web::Data<DbPool>,
|
||||||
|
status_id: web::Path<Uuid>,
|
||||||
|
) -> Result<HttpResponse, HttpError> {
|
||||||
|
let db_client = &**get_database_client(&db_pool).await?;
|
||||||
|
let maybe_current_user = match auth {
|
||||||
|
Some(auth) => Some(get_current_user(db_client, auth.token()).await?),
|
||||||
|
None => None,
|
||||||
|
};
|
||||||
|
let posts = get_thread(
|
||||||
|
db_client,
|
||||||
|
&status_id,
|
||||||
|
maybe_current_user.as_ref().map(|user| &user.id),
|
||||||
|
).await?;
|
||||||
|
let statuses = build_status_list(
|
||||||
|
db_client,
|
||||||
|
&config.instance_url(),
|
||||||
|
maybe_current_user.as_ref(),
|
||||||
|
posts,
|
||||||
|
).await?;
|
||||||
|
Ok(HttpResponse::Ok().json(statuses))
|
||||||
|
}
|
||||||
|
|
||||||
#[post("/{status_id}/favourite")]
|
#[post("/{status_id}/favourite")]
|
||||||
async fn favourite(
|
async fn favourite(
|
||||||
auth: BearerAuth,
|
auth: BearerAuth,
|
||||||
|
@ -597,6 +623,7 @@ pub fn status_api_scope() -> Scope {
|
||||||
.service(get_status)
|
.service(get_status)
|
||||||
.service(delete_status)
|
.service(delete_status)
|
||||||
.service(get_context)
|
.service(get_context)
|
||||||
|
.service(get_thread_view)
|
||||||
.service(favourite)
|
.service(favourite)
|
||||||
.service(unfavourite)
|
.service(unfavourite)
|
||||||
.service(reblog)
|
.service(reblog)
|
||||||
|
|
Loading…
Reference in a new issue