From 2ac7fa0588b5e7efb7797d0194ec40d3cd45c423 Mon Sep 17 00:00:00 2001 From: alemi Date: Sun, 24 Mar 2024 04:05:09 +0100 Subject: [PATCH] chore: split inbox/outbox, added forgotten mods --- src/activitypub/inbox.rs | 20 ++++++++++++++++++++ src/activitypub/mod.rs | 9 ++------- src/activitypub/outbox.rs | 0 src/migrations/mod.rs | 2 ++ src/model/mod.rs | 2 ++ 5 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 src/activitypub/inbox.rs create mode 100644 src/activitypub/outbox.rs diff --git a/src/activitypub/inbox.rs b/src/activitypub/inbox.rs new file mode 100644 index 00000000..612aa6b4 --- /dev/null +++ b/src/activitypub/inbox.rs @@ -0,0 +1,20 @@ +use axum::{extract::State, http::StatusCode, Json}; +use sea_orm::{EntityTrait, QueryOrder, QuerySelect}; + +use crate::{model, server::Context}; + +use super::JsonLD; + + +pub async fn get(State(ctx) : State, Json(_object): Json) -> Result, StatusCode> { + match model::activity::Entity::find() + .order_by(model::activity::Column::Published, sea_orm::Order::Desc) + .limit(20) + .all(ctx.db()) + .await + { + Ok(x) => todo!(), + Err(_e) => Err(StatusCode::INTERNAL_SERVER_ERROR), + } +} + diff --git a/src/activitypub/mod.rs b/src/activitypub/mod.rs index d5723200..f9efe530 100644 --- a/src/activitypub/mod.rs +++ b/src/activitypub/mod.rs @@ -1,4 +1,6 @@ pub mod user; +pub mod inbox; +pub mod outbox; pub mod object; pub mod activity; pub mod well_known; @@ -53,10 +55,3 @@ pub async fn view(State(ctx): State) -> Result, )) } -pub async fn inbox(State(_ctx) : State, Json(_object): Json) -> Result, StatusCode> { - todo!() -} - -pub async fn outbox(State(_db): State) -> Result, StatusCode> { - todo!() -} diff --git a/src/activitypub/outbox.rs b/src/activitypub/outbox.rs new file mode 100644 index 00000000..e69de29b diff --git a/src/migrations/mod.rs b/src/migrations/mod.rs index e4964f1c..4bec1c0b 100644 --- a/src/migrations/mod.rs +++ b/src/migrations/mod.rs @@ -6,6 +6,7 @@ mod m20240322_000002_add_likes_shares; mod m20240322_000003_add_indexes; mod m20240323_000001_add_user_configs; mod m20240323_000002_add_simple_credentials; +mod m20240324_000001_add_addressing; pub struct Migrator; @@ -19,6 +20,7 @@ impl MigratorTrait for Migrator { Box::new(m20240322_000003_add_indexes::Migration), Box::new(m20240323_000001_add_user_configs::Migration), Box::new(m20240323_000002_add_simple_credentials::Migration), + Box::new(m20240324_000001_add_addressing::Migration), ] } } diff --git a/src/model/mod.rs b/src/model/mod.rs index 58943848..2313225f 100644 --- a/src/model/mod.rs +++ b/src/model/mod.rs @@ -4,9 +4,11 @@ pub mod user; pub mod config; pub mod relation; +pub mod addressing; pub mod share; pub mod like; pub mod credential; +pub mod session; pub mod faker;