Use newest background-jobs

This commit is contained in:
asonix
2020-04-20 19:56:50 -05:00
parent 91a57985c9
commit f016f14efe
14 changed files with 54 additions and 157 deletions
+3 -12
View File
@@ -8,7 +8,7 @@ use crate::{
},
};
use activitystreams::primitives::XsdAnyUri;
use background_jobs::{ActixJob, Processor};
use background_jobs::ActixJob;
use std::{future::Future, pin::Pin};
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
@@ -17,9 +17,6 @@ pub struct Announce {
actor: Actor,
}
#[derive(Clone, Debug)]
pub struct AnnounceProcessor;
impl Announce {
pub fn new(object_id: XsdAnyUri, actor: Actor) -> Self {
Announce { object_id, actor }
@@ -60,18 +57,12 @@ fn generate_announce(
}
impl ActixJob for Announce {
type Processor = AnnounceProcessor;
type State = JobState;
type Future = Pin<Box<dyn Future<Output = Result<(), anyhow::Error>>>>;
const NAME: &'static str = "AnnounceProcessor";
fn run(self, state: Self::State) -> Self::Future {
Box::pin(self.perform(state))
}
}
impl Processor for AnnounceProcessor {
type Job = Announce;
const NAME: &'static str = "AnnounceProcessor";
const QUEUE: &'static str = "default";
}
+3 -12
View File
@@ -6,7 +6,7 @@ use crate::{
jobs::{apub::prepare_activity, Deliver, JobState},
};
use activitystreams::primitives::XsdAnyUri;
use background_jobs::{ActixJob, Processor};
use background_jobs::ActixJob;
use std::{future::Future, pin::Pin};
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
@@ -16,9 +16,6 @@ pub struct Follow {
actor: Actor,
}
#[derive(Clone, Debug)]
pub struct FollowProcessor;
impl Follow {
pub fn new(is_listener: bool, input: AcceptedObjects, actor: Actor) -> Self {
Follow {
@@ -105,18 +102,12 @@ fn generate_accept_follow(
}
impl ActixJob for Follow {
type Processor = FollowProcessor;
type State = JobState;
type Future = Pin<Box<dyn Future<Output = Result<(), anyhow::Error>>>>;
const NAME: &'static str = "FollowProcessor";
fn run(self, state: Self::State) -> Self::Future {
Box::pin(self.perform(state))
}
}
impl Processor for FollowProcessor {
type Job = Follow;
const NAME: &'static str = "FollowProcessor";
const QUEUE: &'static str = "default";
}
+3 -12
View File
@@ -3,7 +3,7 @@ use crate::{
data::Actor,
jobs::{apub::get_inboxes, DeliverMany, JobState},
};
use background_jobs::{ActixJob, Processor};
use background_jobs::ActixJob;
use std::{future::Future, pin::Pin};
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
@@ -12,9 +12,6 @@ pub struct Forward {
actor: Actor,
}
#[derive(Clone, Debug)]
pub struct ForwardProcessor;
impl Forward {
pub fn new(input: AcceptedObjects, actor: Actor) -> Self {
Forward { input, actor }
@@ -34,18 +31,12 @@ impl Forward {
}
impl ActixJob for Forward {
type Processor = ForwardProcessor;
type State = JobState;
type Future = Pin<Box<dyn Future<Output = Result<(), anyhow::Error>>>>;
const NAME: &'static str = "ForwardProcessor";
fn run(self, state: Self::State) -> Self::Future {
Box::pin(self.perform(state))
}
}
impl Processor for ForwardProcessor {
type Job = Forward;
const NAME: &'static str = "ForwardProcessor";
const QUEUE: &'static str = "default";
}
+1 -7
View File
@@ -14,13 +14,7 @@ mod forward;
mod reject;
mod undo;
pub use self::{
announce::{Announce, AnnounceProcessor},
follow::{Follow, FollowProcessor},
forward::{Forward, ForwardProcessor},
reject::{Reject, RejectProcessor},
undo::{Undo, UndoProcessor},
};
pub use self::{announce::Announce, follow::Follow, forward::Forward, reject::Reject, undo::Undo};
async fn get_inboxes(
state: &State,
+3 -12
View File
@@ -4,15 +4,12 @@ use crate::{
jobs::{apub::generate_undo_follow, Deliver, JobState},
};
use activitystreams::primitives::XsdAnyUri;
use background_jobs::{ActixJob, Processor};
use background_jobs::ActixJob;
use std::{future::Future, pin::Pin};
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
pub struct Reject(pub Actor);
#[derive(Clone, Debug)]
pub struct RejectProcessor;
impl Reject {
async fn perform(self, state: JobState) -> Result<(), anyhow::Error> {
if let Some(_) = state.actors.unfollower(&self.0).await? {
@@ -29,18 +26,12 @@ impl Reject {
}
impl ActixJob for Reject {
type Processor = RejectProcessor;
type State = JobState;
type Future = Pin<Box<dyn Future<Output = Result<(), anyhow::Error>>>>;
const NAME: &'static str = "RejectProcessor";
fn run(self, state: Self::State) -> Self::Future {
Box::pin(self.perform(state))
}
}
impl Processor for RejectProcessor {
type Job = Reject;
const NAME: &'static str = "RejectProcessor";
const QUEUE: &'static str = "default";
}
+3 -12
View File
@@ -5,7 +5,7 @@ use crate::{
jobs::{apub::generate_undo_follow, Deliver, JobState},
};
use activitystreams::primitives::XsdAnyUri;
use background_jobs::{ActixJob, Processor};
use background_jobs::ActixJob;
use std::{future::Future, pin::Pin};
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
@@ -14,9 +14,6 @@ pub struct Undo {
actor: Actor,
}
#[derive(Clone, Debug)]
pub struct UndoProcessor;
impl Undo {
pub fn new(input: AcceptedObjects, actor: Actor) -> Self {
Undo { input, actor }
@@ -42,18 +39,12 @@ impl Undo {
}
impl ActixJob for Undo {
type Processor = UndoProcessor;
type State = JobState;
type Future = Pin<Box<dyn Future<Output = Result<(), anyhow::Error>>>>;
const NAME: &'static str = "UndoProcessor";
fn run(self, state: Self::State) -> Self::Future {
Box::pin(self.perform(state))
}
}
impl Processor for UndoProcessor {
type Job = Undo;
const NAME: &'static str = "UndoProcessor";
const QUEUE: &'static str = "default";
}