- #[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(&self.auth, context.pool(), context.secret()).await?;
- let local_site = LocalSite::read(context.pool()).await?;
- let person_id = local_user_view.person.id;
- check_private_instance(&Some(local_user_view), &local_site)?;
-
- let res = search_query_to_object_id(&self.q, context)
- .await
- .map_err(|e| e.with_message("couldnt_find_object"))?;
- convert_response(res, 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