~vpzom/lotide

c9aa53785ef33f529e99363e1e9293bcafb3047d — Colin Reeder a month ago ec5a5d4
Add site table and description
A migrations/20200809141326_site/down.sql => migrations/20200809141326_site/down.sql +1 -0
@@ 0,0 1,1 @@
DROP TABLE site;

A migrations/20200809141326_site/up.sql => migrations/20200809141326_site/up.sql +8 -0
@@ 0,0 1,8 @@
BEGIN;
	CREATE TABLE site (
		local BOOLEAN PRIMARY KEY DEFAULT (TRUE) CHECK (local),
		description TEXT NOT NULL DEFAULT ('')
	);

	INSERT INTO site DEFAULT VALUES;
COMMIT;

M src/routes/api/mod.rs => src/routes/api/mod.rs +9 -1
@@ 435,10 435,18 @@ async fn route_unstable_nodeinfo_20_get(

async fn route_unstable_instance_get(
    _: (),
    _ctx: Arc<crate::RouteContext>,
    ctx: Arc<crate::RouteContext>,
    _req: hyper::Request<hyper::Body>,
) -> Result<hyper::Response<hyper::Body>, crate::Error> {
    let db = ctx.db_pool.get().await?;

    let row = db
        .query_one("SELECT description FROM site WHERE local = TRUE", &[])
        .await?;
    let description: &str = row.get(0);

    let body = serde_json::json!({
        "description": description,
        "software": {
            "name": "lotide",
            "version": env!("CARGO_PKG_VERSION"),