};
use actix_web::{body::Body, web, web::Path, HttpResponse};
use anyhow::Context;
+use diesel::result::Error::NotFound;
use itertools::Itertools;
use lemmy_db::{
comment::{Comment, CommentForm},
) -> Result<HttpResponse<Body>, LemmyError> {
let id = info.comment_id.parse::<i32>()?;
let comment = blocking(context.pool(), move |conn| Comment::read(conn, id)).await??;
+ if !comment.local {
+ return Err(NotFound.into());
+ }
if !comment.deleted {
Ok(create_apub_response(
prelude::*,
};
use actix_web::{web, HttpRequest, HttpResponse};
-use anyhow::{anyhow, Context};
+use anyhow::Context;
use lemmy_db::{
community::{Community, CommunityFollower, CommunityFollowerForm},
user::User_,
})
.await??;
- if !community.local {
- return Err(
- anyhow!(
- "Received activity is addressed to remote community {}",
- &community.actor_id
- )
- .into(),
- );
- }
debug!(
"Community {} received activity {:?}",
&community.name, &activity
use activitystreams_ext::Ext1;
use actix_web::{body::Body, web, HttpResponse};
use anyhow::Context;
+use diesel::result::Error::NotFound;
use lemmy_db::{
community::Community,
post::{Post, PostForm},
) -> Result<HttpResponse<Body>, LemmyError> {
let id = info.post_id.parse::<i32>()?;
let post = blocking(context.pool(), move |conn| Post::read(conn, id)).await??;
+ if !post.local {
+ return Err(NotFound.into());
+ }
if !post.deleted {
Ok(create_apub_response(&post.to_apub(context.pool()).await?))
pub fn read_from_name(conn: &PgConnection, community_name: &str) -> Result<Self, Error> {
use crate::schema::community::dsl::*;
community
+ .filter(local)
.filter(name.eq(community_name))
.first::<Self>(conn)
}
}
pub fn find_by_username(conn: &PgConnection, username: &str) -> Result<User_, Error> {
- user_.filter(name.ilike(username)).first::<User_>(conn)
+ user_
+ .filter(local)
+ .filter(name.ilike(username))
+ .first::<User_>(conn)
}
pub fn find_by_email(conn: &PgConnection, from_email: &str) -> Result<User_, Error> {
- user_.filter(email.eq(from_email)).first::<User_>(conn)
+ user_
+ .filter(local)
+ .filter(email.eq(from_email))
+ .first::<User_>(conn)
}
pub fn get_profile_url(&self, hostname: &str) -> String {