Skip to content

Commit

Permalink
Merge pull request #70 from LemmyNet/main
Browse files Browse the repository at this point in the history
[pull] master from LemmyNet:main
  • Loading branch information
pull[bot] authored Jan 12, 2024
2 parents 130f990 + 9240a65 commit 9b3074a
Show file tree
Hide file tree
Showing 19 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion crates/apub/src/activities/block/block_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ impl ActivityHandler for BlockUser {

#[tracing::instrument(skip_all)]
async fn verify(&self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
verify_is_public(&self.to, &self.cc)?;
match self.target.dereference(context).await? {
SiteOrCommunity::Site(site) => {
Expand All @@ -149,6 +148,7 @@ impl ActivityHandler for BlockUser {

#[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
let expires = self.expires.map(Into::into);
let mod_person = self.actor.dereference(context).await?;
let blocked_person = self.object.dereference(context).await?;
Expand Down
2 changes: 1 addition & 1 deletion crates/apub/src/activities/block/undo_block_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ impl ActivityHandler for UndoBlockUser {

#[tracing::instrument(skip_all)]
async fn verify(&self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
verify_is_public(&self.to, &self.cc)?;
verify_domains_match(self.actor.inner(), self.object.actor.inner())?;
self.object.verify(context).await?;
Expand All @@ -98,6 +97,7 @@ impl ActivityHandler for UndoBlockUser {

#[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
let expires = self.object.expires.map(Into::into);
let mod_person = self.actor.dereference(context).await?;
let blocked_person = self.object.object.dereference(context).await?;
Expand Down
4 changes: 2 additions & 2 deletions crates/apub/src/activities/community/announce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,14 @@ impl ActivityHandler for AnnounceActivity {
}

#[tracing::instrument(skip_all)]
async fn verify(&self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
async fn verify(&self, _context: &Data<Self::DataType>) -> Result<(), LemmyError> {
verify_is_public(&self.to, &self.cc)?;
Ok(())
}

#[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
let object: AnnouncableActivities = self.object.object(context).await?.try_into()?;

// This is only for sending, not receiving so we reject it.
Expand Down
2 changes: 1 addition & 1 deletion crates/apub/src/activities/community/collection_add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ impl ActivityHandler for CollectionAdd {

#[tracing::instrument(skip_all)]
async fn verify(&self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
verify_is_public(&self.to, &self.cc)?;
let community = self.community(context).await?;
verify_person_in_community(&self.actor, &community, context).await?;
Expand All @@ -125,6 +124,7 @@ impl ActivityHandler for CollectionAdd {

#[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
let (community, collection_type) =
Community::get_by_collection_url(&mut context.pool(), &self.target.into()).await?;
match collection_type {
Expand Down
2 changes: 1 addition & 1 deletion crates/apub/src/activities/community/collection_remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ impl ActivityHandler for CollectionRemove {

#[tracing::instrument(skip_all)]
async fn verify(&self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
verify_is_public(&self.to, &self.cc)?;
let community = self.community(context).await?;
verify_person_in_community(&self.actor, &community, context).await?;
Expand All @@ -120,6 +119,7 @@ impl ActivityHandler for CollectionRemove {

#[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
let (community, collection_type) =
Community::get_by_collection_url(&mut context.pool(), &self.target.into()).await?;
match collection_type {
Expand Down
2 changes: 1 addition & 1 deletion crates/apub/src/activities/community/lock_page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ impl ActivityHandler for UndoLockPage {
}

async fn verify(&self, context: &Data<Self::DataType>) -> Result<(), Self::Error> {
insert_received_activity(&self.id, context).await?;
verify_is_public(&self.to, &self.cc)?;
let community = self.community(context).await?;
verify_person_in_community(&self.actor, &community, context).await?;
Expand All @@ -91,6 +90,7 @@ impl ActivityHandler for UndoLockPage {
}

async fn receive(self, context: &Data<Self::DataType>) -> Result<(), Self::Error> {
insert_received_activity(&self.id, context).await?;
let form = PostUpdateForm {
locked: Some(false),
..Default::default()
Expand Down
2 changes: 1 addition & 1 deletion crates/apub/src/activities/community/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ impl ActivityHandler for Report {

#[tracing::instrument(skip_all)]
async fn verify(&self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
let community = self.community(context).await?;
verify_person_in_community(&self.actor, &community, context).await?;
Ok(())
}

#[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
let actor = self.actor.dereference(context).await?;
let reason = self.reason()?;
match self.object.dereference(context).await? {
Expand Down
2 changes: 1 addition & 1 deletion crates/apub/src/activities/community/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ impl ActivityHandler for UpdateCommunity {

#[tracing::instrument(skip_all)]
async fn verify(&self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
verify_is_public(&self.to, &self.cc)?;
let community = self.community(context).await?;
verify_person_in_community(&self.actor, &community, context).await?;
Expand All @@ -83,6 +82,7 @@ impl ActivityHandler for UpdateCommunity {

#[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
let community = self.community(context).await?;

let community_update_form = self.object.into_update_form();
Expand Down
2 changes: 1 addition & 1 deletion crates/apub/src/activities/create_or_update/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ impl ActivityHandler for CreateOrUpdateNote {

#[tracing::instrument(skip_all)]
async fn verify(&self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
verify_is_public(&self.to, &self.cc)?;
let post = self.object.get_parents(context).await?.0;
let community = self.community(context).await?;
Expand All @@ -131,6 +130,7 @@ impl ActivityHandler for CreateOrUpdateNote {

#[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
// Need to do this check here instead of Note::from_json because we need the person who
// send the activity, not the comment author.
let existing_comment = self.object.id.dereference_local(context).await.ok();
Expand Down
2 changes: 1 addition & 1 deletion crates/apub/src/activities/create_or_update/post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ impl ActivityHandler for CreateOrUpdatePage {

#[tracing::instrument(skip_all)]
async fn verify(&self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
verify_is_public(&self.to, &self.cc)?;
let community = self.community(context).await?;
verify_person_in_community(&self.actor, &community, context).await?;
Expand Down Expand Up @@ -140,6 +139,7 @@ impl ActivityHandler for CreateOrUpdatePage {

#[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
let post = ApubPost::from_json(self.object, context).await?;

// author likes their own post by default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ impl ActivityHandler for CreateOrUpdateChatMessage {

#[tracing::instrument(skip_all)]
async fn verify(&self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
verify_person(&self.actor, context).await?;
verify_domains_match(self.actor.inner(), self.object.id.inner())?;
verify_domains_match(self.to[0].inner(), self.object.to[0].inner())?;
Expand All @@ -68,6 +67,7 @@ impl ActivityHandler for CreateOrUpdateChatMessage {

#[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
ApubPrivateMessage::from_json(self.object, context).await?;
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion crates/apub/src/activities/deletion/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ impl ActivityHandler for Delete {

#[tracing::instrument(skip_all)]
async fn verify(&self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
verify_delete_activity(self, self.summary.is_some(), context).await?;
Ok(())
}

#[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
if let Some(reason) = self.summary {
// We set reason to empty string if it doesn't exist, to distinguish between delete and
// remove. Here we change it back to option, so we don't write it to db.
Expand Down
2 changes: 1 addition & 1 deletion crates/apub/src/activities/deletion/undo_delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ impl ActivityHandler for UndoDelete {
}

async fn verify(&self, data: &Data<Self::DataType>) -> Result<(), Self::Error> {
insert_received_activity(&self.id, data).await?;
self.object.verify(data).await?;
verify_delete_activity(&self.object, self.object.summary.is_some(), data).await?;
Ok(())
}

#[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
if self.object.summary.is_some() {
UndoDelete::receive_undo_remove_action(
&self.actor.dereference(context).await?,
Expand Down
2 changes: 1 addition & 1 deletion crates/apub/src/activities/following/accept.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ impl ActivityHandler for AcceptFollow {

#[tracing::instrument(skip_all)]
async fn verify(&self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
verify_urls_match(self.actor.inner(), self.object.object.inner())?;
self.object.verify(context).await?;
if let Some(to) = &self.to {
Expand All @@ -64,6 +63,7 @@ impl ActivityHandler for AcceptFollow {

#[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
let community = self.actor.dereference(context).await?;
let person = self.object.actor.dereference(context).await?;
// This will throw an error if no follow was requested
Expand Down
2 changes: 1 addition & 1 deletion crates/apub/src/activities/following/follow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ impl ActivityHandler for Follow {

#[tracing::instrument(skip_all)]
async fn verify(&self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
verify_person(&self.actor, context).await?;
let object = self.object.dereference(context).await?;
if let UserOrCommunity::Community(c) = object {
Expand All @@ -91,6 +90,7 @@ impl ActivityHandler for Follow {

#[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
let actor = self.actor.dereference(context).await?;
let object = self.object.dereference(context).await?;
match object {
Expand Down
2 changes: 1 addition & 1 deletion crates/apub/src/activities/following/undo_follow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ impl ActivityHandler for UndoFollow {

#[tracing::instrument(skip_all)]
async fn verify(&self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
verify_urls_match(self.actor.inner(), self.object.actor.inner())?;
verify_person(&self.actor, context).await?;
self.object.verify(context).await?;
Expand All @@ -77,6 +76,7 @@ impl ActivityHandler for UndoFollow {

#[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
let person = self.actor.dereference(context).await?;
let object = self.object.object.dereference(context).await?;

Expand Down
2 changes: 1 addition & 1 deletion crates/apub/src/activities/voting/undo_vote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ impl ActivityHandler for UndoVote {

#[tracing::instrument(skip_all)]
async fn verify(&self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
let community = self.community(context).await?;
verify_person_in_community(&self.actor, &community, context).await?;
verify_urls_match(self.actor.inner(), self.object.actor.inner())?;
Expand All @@ -67,6 +66,7 @@ impl ActivityHandler for UndoVote {

#[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
let actor = self.actor.dereference(context).await?;
let object = self.object.object.dereference(context).await?;
match object {
Expand Down
2 changes: 1 addition & 1 deletion crates/apub/src/activities/voting/vote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ impl ActivityHandler for Vote {

#[tracing::instrument(skip_all)]
async fn verify(&self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
let community = self.community(context).await?;
verify_person_in_community(&self.actor, &community, context).await?;
let enable_downvotes = LocalSite::read(&mut context.pool())
Expand All @@ -72,6 +71,7 @@ impl ActivityHandler for Vote {

#[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
let actor = self.actor.dereference(context).await?;
let object = self.object.dereference(context).await?;

Expand Down
2 changes: 1 addition & 1 deletion crates/utils/translations

0 comments on commit 9b3074a

Please sign in to comment.