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

Simplify config dess #1686

Merged
merged 2 commits into from
Aug 4, 2021
Merged

Simplify config dess #1686

merged 2 commits into from
Aug 4, 2021

Conversation

dessalines
Copy link
Member

You can diff the changes that I made in the merge, mainly in request.rs

@dessalines dessalines requested a review from Nutomic August 2, 2021 23:09
}
}

pub async fn fetch_iframely_and_pictrs_data(
client: &Client,
url: Option<&Url>,
) -> (Option<String>, Option<String>, Option<String>, Option<Url>) {
) -> Result<(Option<IframelyResponse>, Option<Url>), LemmyError> {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the main change from your branch: the Iframely response should not have been a default with a bunch of empty strings, but an Option due to either a missing config, or an error'd iframely fetch.

A lot of this will probably be moot if / when we replace Iframely with simple internal scraping.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems to be essentially the same as my version, except that you are making the call sites more verbose by creating the option values there. Functionally the only difference seems to be that you ignore errors from fetch_iframely(). I'm not sure why you're doing that, as they could help debug wrong configuration (eg wrong iframely url set, or iframely url set when iframely isnt installed). Maybe just log the error here?

Copy link
Member Author

@dessalines dessalines Aug 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a difference between returning a None if iframely either isn't set up, or has connection errors, and returning a IframelyResult { url: bunch of empty strings as defaults }.

We definitely shouldn't be returning default values if they're actually the result of a missing config or failed fetch.

We also don't want the entire function to return an error only if iframely fails, which is the reason for the .ok().

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think i'm a bit confused by this function as it merges pictrs and iframely responses in a weird way. It would probably be clearer with a separate function each.

@Nutomic Nutomic merged commit 7b8cbbb into main Aug 4, 2021
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