fix: ownerships
This commit is contained in:
parent
0261f87306
commit
d5c5d341e8
1 changed files with 11 additions and 10 deletions
|
@ -2,10 +2,11 @@ use axum::{extract::{Path, State}, http::StatusCode, Json};
|
||||||
use mastodon_async_entities::account::{Account, AccountId};
|
use mastodon_async_entities::account::{Account, AccountId};
|
||||||
use sea_orm::EntityTrait;
|
use sea_orm::EntityTrait;
|
||||||
|
|
||||||
use crate::{model, server::Context};
|
use crate::{model, server::{auth::AuthIdentity, Context}};
|
||||||
|
|
||||||
pub async fn view(
|
pub async fn view(
|
||||||
State(ctx): State<Context>,
|
State(ctx): State<Context>,
|
||||||
|
AuthIdentity(_auth): AuthIdentity,
|
||||||
Path(id): Path<String>
|
Path(id): Path<String>
|
||||||
) -> Result<Json<Account>, StatusCode> {
|
) -> Result<Json<Account>, StatusCode> {
|
||||||
match model::user::Entity::find_by_id(ctx.uid(id))
|
match model::user::Entity::find_by_id(ctx.uid(id))
|
||||||
|
@ -13,29 +14,29 @@ pub async fn view(
|
||||||
.one(ctx.db())
|
.one(ctx.db())
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Err(e) => Err(StatusCode::INTERNAL_SERVER_ERROR),
|
Err(_e) => Err(StatusCode::INTERNAL_SERVER_ERROR),
|
||||||
Ok(None) => Err(StatusCode::NOT_FOUND),
|
Ok(None) => Err(StatusCode::NOT_FOUND),
|
||||||
Ok(Some((x, None))) => Err(StatusCode::NOT_IMPLEMENTED), // TODO remote user
|
Ok(Some((_x, None))) => Err(StatusCode::NOT_IMPLEMENTED), // TODO remote user
|
||||||
Ok(Some((x, Some(cfg)))) => Ok(Json(Account {
|
Ok(Some((x, Some(cfg)))) => Ok(Json(Account {
|
||||||
acct: x.preferred_username,
|
acct: x.preferred_username.clone(),
|
||||||
avatar: x.icon.unwrap_or_default(),
|
avatar: x.icon.as_deref().unwrap_or("").to_string(),
|
||||||
avatar_static: x.icon.unwrap_or_default(),
|
avatar_static: x.icon.unwrap_or_default(),
|
||||||
created_at: time::OffsetDateTime::from_unix_timestamp(x.created.timestamp()),
|
created_at: time::OffsetDateTime::from_unix_timestamp(x.created.timestamp()).unwrap(),
|
||||||
display_name: x.name.unwrap_or_default(),
|
display_name: x.name.unwrap_or_default(),
|
||||||
// TODO hide these maybe
|
// TODO hide these maybe
|
||||||
followers_count: x.followers_count as u64,
|
followers_count: x.followers_count as u64,
|
||||||
following_count: x.following_count as u64,
|
following_count: x.following_count as u64,
|
||||||
header: x.image.unwrap_or_default(),
|
header: x.image.as_deref().unwrap_or("").to_string(),
|
||||||
header_static: x.image.unwrap_or_default(),
|
header_static: x.image.unwrap_or_default(),
|
||||||
id: AccountId::new(x.id),
|
id: AccountId::new(x.id.clone()),
|
||||||
locked: !cfg.accept_follow_requests,
|
locked: !cfg.accept_follow_requests,
|
||||||
note: x.summary.unwrap_or_default(),
|
note: x.summary.unwrap_or_default(),
|
||||||
statuses_count: 0,
|
statuses_count: 0, // TODO keep track in each user
|
||||||
url: x.id,
|
url: x.id,
|
||||||
username: x.preferred_username,
|
username: x.preferred_username,
|
||||||
source: None,
|
source: None,
|
||||||
moved: None,
|
moved: None,
|
||||||
fields: None,
|
fields: None, // TODO user fields
|
||||||
bot: None,
|
bot: None,
|
||||||
})),
|
})),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue