- #[tracing::instrument(skip(context, _websocket_id))]
- async fn perform(
- &self,
- context: &Data<LemmyContext>,
- _websocket_id: Option<ConnectionId>,
- ) -> Result<ResolveObjectResponse, LemmyError> {
- let local_user_view =
- get_local_user_view_from_jwt_opt(self.auth.as_ref(), context.pool(), context.secret())
- .await?;
- let local_site = LocalSite::read(context.pool()).await?;
- check_private_instance(&local_user_view, &local_site)?;
-
- // 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())
- .await
- .map_err(|e| e.with_message("couldnt_find_object"))
+ let res = if is_authenticated {
+ // user is fully authenticated; allow remote lookups as well.
+ search_query_to_object_id(&data.q, &context).await
+ } else {
+ // user isn't authenticated only allow a local search.
+ search_query_to_object_id_local(&data.q, &context).await