2024-03-20 05:44:50 +01:00
|
|
|
use axum::{extract::{Path, State}, http::StatusCode, Json};
|
2024-03-20 08:56:35 +01:00
|
|
|
use sea_orm::EntityTrait;
|
2024-03-20 05:44:50 +01:00
|
|
|
|
2024-03-20 08:56:35 +01:00
|
|
|
use crate::{activitystream::Base, model::activity, server::Context};
|
2024-03-20 05:44:50 +01:00
|
|
|
|
|
|
|
|
2024-03-20 08:56:35 +01:00
|
|
|
pub async fn view(State(ctx) : State<Context>, Path(id): Path<String>) -> Result<Json<serde_json::Value>, StatusCode> {
|
2024-03-20 09:42:25 +01:00
|
|
|
match activity::Entity::find_by_id(ctx.aid(id)).one(ctx.db()).await {
|
2024-03-20 05:44:50 +01:00
|
|
|
Ok(Some(activity)) => Ok(Json(activity.underlying_json_object())),
|
|
|
|
Ok(None) => Err(StatusCode::NOT_FOUND),
|
|
|
|
Err(e) => {
|
|
|
|
tracing::error!("error querying for activity: {e}");
|
|
|
|
Err(StatusCode::INTERNAL_SERVER_ERROR)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|