use crate::{
- http::{create_apub_response, create_apub_tombstone_response},
+ http::{create_apub_response, create_apub_tombstone_response, err_object_not_local},
objects::comment::ApubComment,
};
use activitypub_federation::traits::ApubObject;
use actix_web::{web, web::Path, HttpResponse};
-use diesel::result::Error::NotFound;
use lemmy_api_common::context::LemmyContext;
use lemmy_db_schema::{newtypes::CommentId, source::comment::Comment, traits::Crud};
use lemmy_utils::error::LemmyError;
let id = CommentId(info.comment_id.parse::<i32>()?);
let comment: ApubComment = Comment::read(context.pool(), id).await?.into();
if !comment.local {
- return Err(NotFound.into());
+ return Err(err_object_not_local());
}
if !comment.deleted && !comment.removed {
.json(WithContext::new(tombstone, CONTEXT.deref().clone()))
}
+fn err_object_not_local() -> LemmyError {
+ LemmyError::from_message("Object not local, fetch it from original instance")
+}
+
#[derive(Deserialize)]
pub struct ActivityQuery {
type_: String,
let activity = Activity::read_from_apub_id(context.pool(), &activity_id).await?;
let sensitive = activity.sensitive.unwrap_or(true);
- if !activity.local || sensitive {
- Ok(HttpResponse::NotFound().finish())
+ if !activity.local {
+ return Err(err_object_not_local());
+ } else if sensitive {
+ Ok(HttpResponse::Forbidden().finish())
} else {
Ok(create_json_apub_response(activity.data))
}
use crate::{
- http::{create_apub_response, create_apub_tombstone_response},
+ http::{create_apub_response, create_apub_tombstone_response, err_object_not_local},
objects::post::ApubPost,
};
use activitypub_federation::traits::ApubObject;
use actix_web::{web, HttpResponse};
-use diesel::result::Error::NotFound;
use lemmy_api_common::context::LemmyContext;
use lemmy_db_schema::{newtypes::PostId, source::post::Post, traits::Crud};
use lemmy_utils::error::LemmyError;
let id = PostId(info.post_id.parse::<i32>()?);
let post: ApubPost = Post::read(context.pool(), id).await?.into();
if !post.local {
- return Err(NotFound.into());
+ return Err(err_object_not_local());
}
if !post.deleted && !post.removed {