Add /api/v1/accounts/{account_id}/aliases API endpoint
This commit is contained in:
parent
baec22272d
commit
82b6c4e7cf
3 changed files with 42 additions and 0 deletions
|
@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
- Add empty `spoiler_text` property to Mastodon API Status object.
|
||||
- Added `error` and `error_description` fields to Mastodon API error responses.
|
||||
- Store information about failed activity deliveries in database.
|
||||
- Added `/api/v1/accounts/{account_id}/aliases` API endpoint.
|
||||
|
||||
### Changed
|
||||
|
||||
|
|
|
@ -544,6 +544,23 @@ paths:
|
|||
$ref: '#/components/schemas/Subscription'
|
||||
404:
|
||||
description: Profile not found
|
||||
/api/v1/accounts/{account_id}/aliases:
|
||||
get:
|
||||
summary: Get actor's aliases.
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/account_id'
|
||||
responses:
|
||||
200:
|
||||
description: Successful operation
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
description: Profile list
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Account'
|
||||
404:
|
||||
description: Profile not found
|
||||
/api/v1/accounts/{account_id}/follow:
|
||||
post:
|
||||
summary: Follow the given actor.
|
||||
|
|
|
@ -67,6 +67,7 @@ use crate::mastodon_api::{
|
|||
};
|
||||
use crate::models::{
|
||||
posts::queries::get_posts_by_author,
|
||||
profiles::helpers::find_aliases,
|
||||
profiles::queries::{
|
||||
get_profile_by_acct,
|
||||
get_profile_by_id,
|
||||
|
@ -797,6 +798,28 @@ async fn get_account_subscribers(
|
|||
Ok(HttpResponse::Ok().json(subscriptions))
|
||||
}
|
||||
|
||||
#[get("/{account_id}/aliases")]
|
||||
async fn get_account_aliases(
|
||||
connection_info: ConnectionInfo,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
account_id: web::Path<Uuid>,
|
||||
) -> Result<HttpResponse, MastodonError> {
|
||||
let db_client = &**get_database_client(&db_pool).await?;
|
||||
let profile = get_profile_by_id(db_client, &account_id).await?;
|
||||
let aliases = find_aliases(db_client, &profile).await?;
|
||||
let base_url = get_request_base_url(connection_info);
|
||||
let instance_url = config.instance_url();
|
||||
let accounts: Vec<Account> = aliases.into_iter()
|
||||
.map(|profile| Account::from_profile(
|
||||
&base_url,
|
||||
&instance_url,
|
||||
profile,
|
||||
))
|
||||
.collect();
|
||||
Ok(HttpResponse::Ok().json(accounts))
|
||||
}
|
||||
|
||||
pub fn account_api_scope() -> Scope {
|
||||
web::scope("/api/v1/accounts")
|
||||
// Routes without account ID
|
||||
|
@ -819,4 +842,5 @@ pub fn account_api_scope() -> Scope {
|
|||
.service(get_account_followers)
|
||||
.service(get_account_following)
|
||||
.service(get_account_subscribers)
|
||||
.service(get_account_aliases)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue