-
-
Notifications
You must be signed in to change notification settings - Fork 883
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make resolve_object not require auth #3685 #3716
Make resolve_object not require auth #3685 #3716
Conversation
If user isn't authenticated with resolve_object, only allow a local search instead of possibly making an http request.
It doesn't look like this is actually blocking invalid tokens. I'll push an update tonight to fix that. |
Fixed the issue where I wasn't properly locking invalid tokens. |
context: &Data<LemmyContext>, | ||
) -> Result<SearchableObjects, LemmyError> { | ||
let url = Url::parse(query)?; | ||
ObjectId::from(url).dereference_local(context).await |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can directly call ObjectId::parse
which calls Url::parse
internally. And in fact it doesnt make much sense to have a separate function for this single line. Otherwise looks good.
@@ -84,7 +84,7 @@ pub struct SearchResponse { | |||
pub struct ResolveObject { | |||
/// Can be the full url, or a shortened version like: [email protected] | |||
pub q: String, | |||
pub auth: Sensitive<String>, | |||
pub auth: Option<Sensitive<String>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API change, but it shouldn't be breaking.
Resolves issue #3685
If user isn't authenticated with resolve_object, only allow a local search instead of possibly making an http request.
Changing resolve_object to take an optional auth parameter. When auth is null, the request is only allowed to search the local database rather than do a remote lookup.
This is primarily to resolve a few issue:
/api/v3/post...
on every Lemmy instance in the fediverse, is extremely slow. Current estimate, is around ~13 years worst case, if no new posts get added.Original PR for reference: #3706 (as it was easier to decline that one and open a new one with the requested changes).