chore: clippy warns, async_trait fixes
This commit is contained in:
parent
0934cdaad4
commit
174ef4198d
12 changed files with 20 additions and 4 deletions
|
@ -1,5 +1,5 @@
|
|||
use sea_orm::{EntityTrait, TransactionTrait};
|
||||
use upub::traits::{fetch::{Fetchable, RequestError}, Addresser, Fetcher, Normalizer};
|
||||
use upub::traits::{fetch::RequestError, Addresser, Fetcher, Normalizer};
|
||||
|
||||
pub async fn fetch(ctx: upub::Context, uri: String, save: bool, actor: Option<String>) -> Result<(), RequestError> {
|
||||
use apb::Base;
|
||||
|
@ -48,11 +48,11 @@ pub async fn fetch(ctx: upub::Context, uri: String, save: bool, actor: Option<St
|
|||
},
|
||||
Ok(apb::BaseType::Object(apb::ObjectType::Activity(_))) => {
|
||||
let act = ctx.insert_activity(obj, &tx).await?;
|
||||
ctx.address((Some(&act), None), &tx).await?;
|
||||
ctx.address(Some(&act), None, &tx).await?;
|
||||
},
|
||||
Ok(apb::BaseType::Object(apb::ObjectType::Note)) => {
|
||||
let obj = ctx.insert_object(obj, &tx).await?;
|
||||
ctx.address((None, Some(&obj)), &tx).await?;
|
||||
ctx.address(None, Some(&obj), &tx).await?;
|
||||
},
|
||||
Ok(apb::BaseType::Object(t)) => tracing::warn!("not implemented: {:?}", t),
|
||||
Ok(apb::BaseType::Link(_)) => tracing::error!("fetched another link?"),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use sea_orm::{ConnectionTrait, PaginatorTrait};
|
||||
|
||||
|
||||
#[allow(async_fn_in_trait)]
|
||||
pub trait AnyQuery {
|
||||
async fn any(self, db: &impl ConnectionTrait) -> Result<bool, sea_orm::DbErr>;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ use std::collections::{hash_map::Entry, HashMap};
|
|||
use sea_orm::{ConnectionTrait, DbErr, EntityTrait, FromQueryResult, ModelTrait, QueryFilter};
|
||||
use super::RichActivity;
|
||||
|
||||
#[allow(async_fn_in_trait)]
|
||||
pub trait BatchFillable: Sized {
|
||||
async fn with_batched<E>(self, tx: &impl ConnectionTrait) -> Result<Self, DbErr>
|
||||
where
|
||||
|
@ -114,6 +115,7 @@ use crate::selector::rich::{RichHashtag, RichMention};
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(async_fn_in_trait)]
|
||||
pub trait BatchFillableAcceptor<B> {
|
||||
async fn accept(&mut self, batch: B, tx: &impl ConnectionTrait) -> Result<(), DbErr>;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ use sea_orm::{ActiveValue::{NotSet, Set}, ColumnTrait, ConnectionTrait, DbErr, E
|
|||
|
||||
use crate::traits::fetch::Fetcher;
|
||||
|
||||
#[allow(async_fn_in_trait)]
|
||||
pub trait Addresser {
|
||||
async fn deliver(&self, to: Vec<String>, aid: &str, from: &str, tx: &impl ConnectionTrait) -> Result<(), DbErr>;
|
||||
async fn address(&self, activity: Option<&crate::model::activity::Model>, object: Option<&crate::model::object::Model>, tx: &impl ConnectionTrait) -> Result<(), DbErr>;
|
||||
|
|
|
@ -2,6 +2,7 @@ use sea_orm::{ActiveValue::{NotSet, Set}, DbErr, EntityTrait};
|
|||
|
||||
use crate::ext::JsonVec;
|
||||
|
||||
#[allow(async_fn_in_trait)]
|
||||
pub trait Administrable {
|
||||
async fn register_user(
|
||||
&self,
|
||||
|
|
|
@ -463,6 +463,7 @@ async fn resolve_object_r(ctx: &crate::Context, object: serde_json::Value, depth
|
|||
Ok(object_model)
|
||||
}
|
||||
|
||||
#[allow(async_fn_in_trait)]
|
||||
pub trait Fetchable : Sync + Send {
|
||||
async fn fetch(&mut self, ctx: &crate::Context) -> Result<&mut Self, RequestError>;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ pub enum NormalizerError {
|
|||
DbErr(#[from] sea_orm::DbErr),
|
||||
}
|
||||
|
||||
#[allow(async_fn_in_trait)]
|
||||
pub trait Normalizer {
|
||||
async fn insert_object(&self, obj: impl apb::Object, tx: &impl ConnectionTrait) -> Result<crate::model::object::Model, NormalizerError>;
|
||||
async fn insert_activity(&self, act: impl apb::Activity, tx: &impl ConnectionTrait) -> Result<crate::model::activity::Model, NormalizerError>;
|
||||
|
|
|
@ -29,10 +29,12 @@ pub enum ProcessorError {
|
|||
PullError(#[from] crate::traits::fetch::RequestError),
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
pub trait Processor {
|
||||
async fn process(&self, activity: impl apb::Activity, tx: &DatabaseTransaction) -> Result<(), ProcessorError>;
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Processor for crate::Context {
|
||||
async fn process(&self, activity: impl apb::Activity, tx: &DatabaseTransaction) -> Result<(), ProcessorError> {
|
||||
// TODO we could process Links and bare Objects maybe, but probably out of AP spec?
|
||||
|
|
|
@ -33,3 +33,8 @@ nodeinfo = { git = "https://codeberg.org/thefederationinfo/nodeinfo-rs", rev = "
|
|||
# mastodon
|
||||
mastodon-async-entities = { version = "1.1.0", optional = true }
|
||||
time = { version = "0.3", features = ["serde"], optional = true }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
mastodon = ["dep:mastodon-async-entities"]
|
||||
web = []
|
||||
|
|
|
@ -62,6 +62,7 @@ impl Identity {
|
|||
|
||||
pub struct AuthIdentity(pub Identity);
|
||||
|
||||
#[axum::async_trait]
|
||||
impl<S> FromRequestParts<S> for AuthIdentity
|
||||
where
|
||||
upub::Context: FromRef<S>,
|
||||
|
|
|
@ -3,6 +3,7 @@ use reqwest::Method;
|
|||
use apb::{LD, ActivityMut};
|
||||
use upub::{Context, model, traits::Fetcher};
|
||||
|
||||
#[allow(clippy::manual_map)] // TODO can Update code be improved?
|
||||
pub async fn process(ctx: Context, job: &model::job::Model) -> crate::JobResult<()> {
|
||||
tracing::info!("delivering {} to {:?}", job.activity, job.target);
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ pub enum JobError {
|
|||
|
||||
pub type JobResult<T> = Result<T, JobError>;
|
||||
|
||||
#[allow(async_fn_in_trait)]
|
||||
pub trait JobDispatcher : Sized {
|
||||
async fn poll(&self, filter: Option<model::job::JobType>) -> JobResult<Option<model::job::Model>>;
|
||||
async fn lock(&self, job_internal: i64) -> JobResult<bool>;
|
||||
|
|
Loading…
Reference in a new issue