From bbcc46d0ee9c02947ecbce25c6892699c81950ba Mon Sep 17 00:00:00 2001 From: alemi Date: Thu, 6 Jun 2024 02:21:01 +0200 Subject: [PATCH] fix(cli): traits come from core again --- upub/cli/Cargo.toml | 1 - upub/cli/src/fetch.rs | 4 ++-- upub/cli/src/fix.rs | 2 +- upub/cli/src/lib.rs | 4 ++-- upub/cli/src/register.rs | 4 ++-- upub/cli/src/relay.rs | 5 ++--- upub/cli/src/update.rs | 7 +++---- 7 files changed, 12 insertions(+), 15 deletions(-) diff --git a/upub/cli/Cargo.toml b/upub/cli/Cargo.toml index 2884a7d6..ec11cdfd 100644 --- a/upub/cli/Cargo.toml +++ b/upub/cli/Cargo.toml @@ -13,7 +13,6 @@ readme = "README.md" [dependencies] apb = { path = "../../apb/" } upub = { path = "../core" } -upub-processor = { path = "../processor/" } tracing = "0.1" serde_json = "1" sha256 = "1.5" diff --git a/upub/cli/src/fetch.rs b/upub/cli/src/fetch.rs index ef994566..5f89fe2e 100644 --- a/upub/cli/src/fetch.rs +++ b/upub/cli/src/fetch.rs @@ -1,5 +1,5 @@ use sea_orm::EntityTrait; -use upub_processor::{fetch::{Fetchable, PullError}, normalize::{AP, Normalizer}}; +use upub::traits::{fetch::{Fetchable, PullError}, Normalizer}; pub async fn fetch(ctx: upub::Context, uri: String, save: bool) -> Result<(), PullError> { use apb::Base; @@ -15,7 +15,7 @@ pub async fn fetch(ctx: upub::Context, uri: String, save: bool) -> Result<(), Pu match obj.base_type() { Ok(apb::BaseType::Object(apb::ObjectType::Actor(_))) => { upub::model::actor::Entity::insert( - AP::actor_q(&obj).unwrap() + upub::AP::actor_q(&obj).unwrap() ).exec(ctx.db()).await.unwrap(); }, Ok(apb::BaseType::Object(apb::ObjectType::Activity(_))) => { diff --git a/upub/cli/src/fix.rs b/upub/cli/src/fix.rs index a782a127..d7b8394a 100644 --- a/upub/cli/src/fix.rs +++ b/upub/cli/src/fix.rs @@ -1,6 +1,6 @@ use sea_orm::EntityTrait; -pub async fn fix(ctx: upub::Context, likes: bool, shares: bool, replies: bool) -> upub::Result<()> { +pub async fn fix(ctx: upub::Context, likes: bool, shares: bool, replies: bool) -> Result<(), sea_orm::DbErr> { use futures::TryStreamExt; let db = ctx.db(); diff --git a/upub/cli/src/lib.rs b/upub/cli/src/lib.rs index a8f9009a..7fe394f5 100644 --- a/upub/cli/src/lib.rs +++ b/upub/cli/src/lib.rs @@ -93,12 +93,12 @@ pub enum CliCommand { } } -pub async fn run(ctx: upub::Context, command: CliCommand) -> upub::Result<()> { +pub async fn run(ctx: upub::Context, command: CliCommand) -> Result<(), Box> { match command { CliCommand::Faker { count } => Ok(faker(ctx, count as i64).await?), CliCommand::Fetch { uri, save } => - Ok(fetch(ctx, uri, save).await.map_err(|_e| upub::Error::internal_server_error())?), + Ok(fetch(ctx, uri, save).await?), CliCommand::Relay { actor, accept } => Ok(relay(ctx, actor, accept).await?), CliCommand::Fix { likes, shares, replies } => diff --git a/upub/cli/src/register.rs b/upub/cli/src/register.rs index 9ef54b09..607664b5 100644 --- a/upub/cli/src/register.rs +++ b/upub/cli/src/register.rs @@ -1,4 +1,4 @@ -use upub::server::admin::Administrable; +use upub::traits::Administrable; pub async fn register( ctx: upub::Context, @@ -8,7 +8,7 @@ pub async fn register( summary: Option, avatar_url: Option, banner_url: Option, -) -> upub::Result<()> { +) -> Result<(), sea_orm::DbErr> { ctx.register_user( username.clone(), password, diff --git a/upub/cli/src/relay.rs b/upub/cli/src/relay.rs index c2a672e7..30eb4ca9 100644 --- a/upub/cli/src/relay.rs +++ b/upub/cli/src/relay.rs @@ -1,8 +1,7 @@ use sea_orm::{ActiveValue::{Set, NotSet}, ColumnTrait, EntityTrait, QueryFilter, QueryOrder}; +use upub::traits::Addresser; -use upub_processor::address::Addresser; - -pub async fn relay(ctx: upub::Context, actor: String, accept: bool) -> upub::Result<()> { +pub async fn relay(ctx: upub::Context, actor: String, accept: bool) -> Result<(), sea_orm::DbErr> { let aid = ctx.aid(&uuid::Uuid::new_v4().to_string()); let mut activity_model = upub::model::activity::ActiveModel { diff --git a/upub/cli/src/update.rs b/upub/cli/src/update.rs index cac556a3..adf30e40 100644 --- a/upub/cli/src/update.rs +++ b/upub/cli/src/update.rs @@ -1,9 +1,8 @@ use futures::TryStreamExt; use sea_orm::{ActiveValue::Set, ColumnTrait, EntityTrait, QueryFilter}; +use upub::traits::Fetcher; -use upub_processor::{fetch::Fetcher, normalize::AP}; - -pub async fn update_users(ctx: upub::Context, days: i64) -> upub::Result<()> { +pub async fn update_users(ctx: upub::Context, days: i64) -> Result<(), sea_orm::DbErr> { let mut count = 0; let mut insertions = Vec::new(); @@ -19,7 +18,7 @@ pub async fn update_users(ctx: upub::Context, days: i64) -> upub::Result<()> { match ctx.pull(&user.id).await.map(|x| x.actor()) { Err(e) => tracing::warn!("could not update user {}: {e}", user.id), Ok(Err(e)) => tracing::warn!("could not update user {}: {e}", user.id), - Ok(Ok(doc)) => match AP::actor_q(&doc) { + Ok(Ok(doc)) => match upub::AP::actor_q(&doc) { Ok(mut u) => { u.internal = Set(user.internal); u.updated = Set(chrono::Utc::now());