-
-
Notifications
You must be signed in to change notification settings - Fork 884
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
Adding shortname fetching for users and communities. Fixes #1662 #1663
Conversation
/// Takes in a shortname of the type dessalines@xyz.tld or dessalines (assumed to be local), and outputs the actor id. | ||
/// Used in the API for communities and users. | ||
pub fn build_actor_id_from_shortname( | ||
endpoint_type: EndpointType, | ||
short_name: &str, | ||
) -> Result<DbUrl, ParseError> { | ||
let split = short_name.split('@').collect::<Vec<&str>>(); | ||
|
||
let name = split[0]; | ||
|
||
// If there's no @, its local | ||
let domain = if split.len() == 1 { | ||
Settings::get().get_protocol_and_hostname() | ||
} else { | ||
format!("https://{}", split[1]) | ||
}; | ||
|
||
generate_apub_endpoint_for_domain(endpoint_type, name, &domain) | ||
} |
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.
Builds the actor_id from the short name.
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.
Actually here's a problem, you should use Settings::get().get_protocol_string()
instead of hardcoding https.
Btw I noticed that you really have to read this diff from bottom to top, so that you start at the low-level database code, and read the api code later. I first tried reading it from the top and its impossible to understand. So maybe we should consider adding a prefix to our crate folder names to order them correctly. |
No description provided.