1
0
Fork 0
forked from alemi/upub

fix!: instance counters as i64

This commit is contained in:
əlemi 2024-05-28 03:10:30 +02:00
parent e0273d5155
commit 935dceacfc
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 14 additions and 4 deletions

View file

@ -108,8 +108,8 @@ impl MigrationTrait for Migration {
.col(ColumnDef::new(Instances::Version).string().null())
.col(ColumnDef::new(Instances::Icon).string().null())
.col(ColumnDef::new(Instances::DownSince).date_time().null())
.col(ColumnDef::new(Instances::Users).integer().null())
.col(ColumnDef::new(Instances::Posts).integer().null())
.col(ColumnDef::new(Instances::Users).big_integer().null())
.col(ColumnDef::new(Instances::Posts).big_integer().null())
.col(ColumnDef::new(Instances::Published).date_time().not_null().default(Expr::current_timestamp()))
.col(ColumnDef::new(Instances::Updated).date_time().not_null().default(Expr::current_timestamp()))
.to_owned()

View file

@ -1,3 +1,4 @@
use nodeinfo::NodeInfoOwned;
use sea_orm::{entity::prelude::*, QuerySelect, SelectColumns};
use crate::errors::UpubError;
@ -14,8 +15,8 @@ pub struct Model {
pub version: Option<String>,
pub icon: Option<String>,
pub down_since: Option<ChronoDateTimeUtc>,
pub users: Option<i32>,
pub posts: Option<i32>,
pub users: Option<i64>,
pub posts: Option<i64>,
pub published: ChronoDateTimeUtc,
pub updated: ChronoDateTimeUtc,
}
@ -57,4 +58,13 @@ impl Entity {
.await?
.ok_or_else(UpubError::not_found)
}
pub async fn nodeinfo(domain: &str) -> crate::Result<NodeInfoOwned> {
Ok(
reqwest::get(format!("https://{domain}/nodeinfo/2.0.json"))
.await?
.json()
.await?
)
}
}