Skip to content
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

Merged
merged 1 commit into from
Jul 20, 2021

Conversation

dessalines
Copy link
Member

No description provided.

@dessalines dessalines marked this pull request as ready for review July 19, 2021 14:14
Comment on lines +338 to +356
/// 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)
}
Copy link
Member Author

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.

Copy link
Member

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.

@dessalines dessalines requested a review from Nutomic July 19, 2021 14:23
@Nutomic Nutomic merged commit 5fe7de2 into main Jul 20, 2021
@Nutomic
Copy link
Member

Nutomic commented Jul 20, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants