};
use lemmy_db_schema::{newtypes::PersonId, source::local_site::LocalSite, utils::DbPool};
use lemmy_db_views::structs::{CommentView, PostView};
-use lemmy_db_views_actor::structs::{CommunityView, PersonViewSafe};
+use lemmy_db_views_actor::structs::{CommunityView, PersonView};
use lemmy_utils::{error::LemmyError, ConnectionId};
#[async_trait::async_trait(?Send)]
let local_site = LocalSite::read(context.pool()).await?;
check_private_instance(&local_user_view, &local_site)?;
- let res = search_query_to_object_id(&self.q, local_user_view.is_none(), context)
+ // In release builds only allow for authenticated users to fetch remote objects
+ let local_only = local_user_view.is_none() && cfg!(not(debug_assertions));
+ let res = search_query_to_object_id(&self.q, local_only, context)
.await
.map_err(|e| e.with_message("couldnt_find_object"))?;
convert_response(res, local_user_view.map(|l| l.person.id), context.pool())
match object {
Person(p) => {
removed_or_deleted = p.deleted;
- res.person = Some(PersonViewSafe::read(pool, p.id).await?)
+ res.person = Some(PersonView::read(pool, p.id).await?)
}
Community(c) => {
removed_or_deleted = c.deleted || c.removed;
- res.community = Some(CommunityView::read(pool, c.id, user_id).await?)
+ res.community = Some(CommunityView::read(pool, c.id, user_id, None).await?)
}
Post(p) => {
removed_or_deleted = p.deleted || p.removed;
- res.post = Some(PostView::read(pool, p.id, user_id).await?)
+ res.post = Some(PostView::read(pool, p.id, user_id, None).await?)
}
Comment(c) => {
removed_or_deleted = c.deleted || c.removed;