mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
oops
This commit is contained in:
parent
698f01ab9c
commit
c4f820e114
2 changed files with 26 additions and 2 deletions
|
|
@ -1,5 +1,9 @@
|
|||
use crate::{ApiContext, auth::AuthState, error::fail};
|
||||
use axum::{Extension, extract::State, response::Json};
|
||||
use axum::{
|
||||
Extension,
|
||||
extract::{Path, State},
|
||||
response::Json,
|
||||
};
|
||||
use fred::interfaces::*;
|
||||
use libpk::state::ShardState;
|
||||
use pk_macros::api_endpoint;
|
||||
|
|
@ -201,7 +205,9 @@ pub enum DashViewRequest {
|
|||
name: Option<String>,
|
||||
value: Option<String>,
|
||||
},
|
||||
Remove { id: String },
|
||||
Remove {
|
||||
id: String,
|
||||
},
|
||||
}
|
||||
|
||||
#[api_endpoint]
|
||||
|
|
@ -294,3 +300,20 @@ pub async fn dash_views(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[api_endpoint]
|
||||
pub async fn dash_view(State(ctx): State<ApiContext>, Path(id): Path<String>) -> Json<Value> {
|
||||
match sqlx::query_as::<Postgres, PKDashView>("select * from dash_views where id = $1")
|
||||
.bind(id)
|
||||
.fetch_optional(&ctx.db)
|
||||
.await
|
||||
{
|
||||
Ok(val) => {
|
||||
let Some(val) = val else {
|
||||
return Err(crate::error::GENERIC_BAD_REQUEST);
|
||||
};
|
||||
Ok(Json(val.to_json()))
|
||||
}
|
||||
Err(err) => fail!(?err, "failed to query dash views"),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,6 +124,7 @@ fn router(ctx: ApiContext) -> Router {
|
|||
.route("/private/discord/callback2", post(endpoints::private::discord_callback))
|
||||
.route("/private/discord/shard_state", get(endpoints::private::discord_state))
|
||||
.route("/private/dash_views", post(endpoints::private::dash_views))
|
||||
.route("/private/dash_view/{id}", get(endpoints::private::dash_view))
|
||||
.route("/private/stats", get(endpoints::private::meta))
|
||||
|
||||
.route("/v2/systems/{system_id}/oembed.json", get(rproxy))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue