remove do_send, dont return errors from activity_sender
This commit is contained in:
parent
35649032c0
commit
512eeb0432
5 changed files with 23 additions and 30 deletions
|
@ -27,7 +27,7 @@ pub async fn send_activity_to_community(
|
|||
actor: creator.to_owned(),
|
||||
to,
|
||||
};
|
||||
context.activity_sender().send(message).await??;
|
||||
context.activity_sender().do_send(message);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -12,7 +12,7 @@ use url::Url;
|
|||
|
||||
// We cant use ActorType here, because it doesnt implement Sized
|
||||
#[derive(Message)]
|
||||
#[rtype(result = "Result<(), LemmyError>")]
|
||||
#[rtype(result = "()")]
|
||||
pub struct SendUserActivity {
|
||||
pub activity: AnyBase,
|
||||
pub actor: User_,
|
||||
|
@ -20,7 +20,7 @@ pub struct SendUserActivity {
|
|||
}
|
||||
|
||||
#[derive(Message)]
|
||||
#[rtype(result = "Result<(), LemmyError>")]
|
||||
#[rtype(result = "()")]
|
||||
pub struct SendCommunityActivity {
|
||||
pub activity: AnyBase,
|
||||
pub actor: Community,
|
||||
|
@ -42,39 +42,34 @@ impl Actor for ActivitySender {
|
|||
}
|
||||
|
||||
impl Handler<SendUserActivity> for ActivitySender {
|
||||
type Result = Result<(), LemmyError>;
|
||||
type Result = ();
|
||||
|
||||
fn handle(&mut self, msg: SendUserActivity, _ctx: &mut Context<Self>) -> Self::Result {
|
||||
send_activity(msg.activity, &msg.actor, msg.to, &self.client)
|
||||
send_activity(msg.activity, &msg.actor, msg.to, &self.client);
|
||||
}
|
||||
}
|
||||
|
||||
impl Handler<SendCommunityActivity> for ActivitySender {
|
||||
type Result = Result<(), LemmyError>;
|
||||
type Result = ();
|
||||
|
||||
fn handle(&mut self, msg: SendCommunityActivity, _ctx: &mut Context<Self>) -> Self::Result {
|
||||
send_activity(msg.activity, &msg.actor, msg.to, &self.client)
|
||||
send_activity(msg.activity, &msg.actor, msg.to, &self.client);
|
||||
}
|
||||
}
|
||||
|
||||
fn send_activity(
|
||||
activity: AnyBase,
|
||||
actor: &dyn ActorType,
|
||||
to: Vec<Url>,
|
||||
client: &Client,
|
||||
) -> Result<(), LemmyError> {
|
||||
fn send_activity(activity: AnyBase, actor: &dyn ActorType, to: Vec<Url>, client: &Client) {
|
||||
if !Settings::get().federation.enabled {
|
||||
return Ok(());
|
||||
return;
|
||||
}
|
||||
|
||||
let serialised_activity = serde_json::to_string(&activity)?;
|
||||
let serialised_activity = serde_json::to_string(&activity).unwrap();
|
||||
debug!(
|
||||
"Sending activitypub activity {} to {:?}",
|
||||
&serialised_activity, &to
|
||||
);
|
||||
|
||||
for to_url in &to {
|
||||
check_is_apub_id_valid(&to_url)?;
|
||||
check_is_apub_id_valid(&to_url).unwrap();
|
||||
|
||||
let request = client
|
||||
.post(to_url.as_str())
|
||||
|
@ -90,6 +85,4 @@ fn send_activity(
|
|||
Ok::<(), LemmyError>(())
|
||||
});
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ impl ActorType for Community {
|
|||
actor: self.to_owned(),
|
||||
to: vec![to],
|
||||
};
|
||||
context.activity_sender().send(message).await??;
|
||||
context.activity_sender().do_send(message);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,7 @@ impl ActorType for Community {
|
|||
actor: creator.to_owned(),
|
||||
to: inboxes,
|
||||
};
|
||||
context.activity_sender().send(message).await??;
|
||||
context.activity_sender().do_send(message);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,7 @@ impl ActorType for Community {
|
|||
actor: creator.to_owned(),
|
||||
to: inboxes,
|
||||
};
|
||||
context.activity_sender().send(message).await??;
|
||||
context.activity_sender().do_send(message);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -250,7 +250,7 @@ impl ActorType for Community {
|
|||
actor: mod_.to_owned(),
|
||||
to: inboxes,
|
||||
};
|
||||
context.activity_sender().send(message).await??;
|
||||
context.activity_sender().do_send(message);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -284,7 +284,7 @@ impl ActorType for Community {
|
|||
actor: mod_.to_owned(),
|
||||
to: inboxes,
|
||||
};
|
||||
context.activity_sender().send(message).await??;
|
||||
context.activity_sender().do_send(message);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -542,7 +542,7 @@ pub async fn do_announce(
|
|||
actor: community.to_owned(),
|
||||
to,
|
||||
};
|
||||
context.activity_sender().send(message).await??;
|
||||
context.activity_sender().do_send(message);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ impl ApubObjectType for PrivateMessage {
|
|||
actor: creator.to_owned(),
|
||||
to: vec![to],
|
||||
};
|
||||
context.activity_sender().send(message).await??;
|
||||
context.activity_sender().do_send(message);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ impl ApubObjectType for PrivateMessage {
|
|||
actor: creator.to_owned(),
|
||||
to: vec![to],
|
||||
};
|
||||
context.activity_sender().send(message).await??;
|
||||
context.activity_sender().do_send(message);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,7 @@ impl ApubObjectType for PrivateMessage {
|
|||
actor: creator.to_owned(),
|
||||
to: vec![to],
|
||||
};
|
||||
context.activity_sender().send(message).await??;
|
||||
context.activity_sender().do_send(message);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,7 @@ impl ApubObjectType for PrivateMessage {
|
|||
actor: creator.to_owned(),
|
||||
to: vec![to],
|
||||
};
|
||||
context.activity_sender().send(message).await??;
|
||||
context.activity_sender().do_send(message);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ impl ActorType for User_ {
|
|||
actor: self.to_owned(),
|
||||
to: vec![to],
|
||||
};
|
||||
context.activity_sender().send(message).await??;
|
||||
context.activity_sender().do_send(message);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,7 @@ impl ActorType for User_ {
|
|||
actor: self.to_owned(),
|
||||
to: vec![to],
|
||||
};
|
||||
context.activity_sender().send(message).await??;
|
||||
context.activity_sender().do_send(message);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue