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

On registration, automatically set content languages from accept-language header #4550

Merged
merged 5 commits into from
Mar 25, 2024

Conversation

Nutomic
Copy link
Member

@Nutomic Nutomic commented Mar 18, 2024

No description provided.

@Nutomic Nutomic changed the title On registration, automatically set content languages from accept header On registration, automatically set content languages from accept-language header Mar 20, 2024
// otherwise, init with all languages (this only happens during tests and
// for first admin user, which is created before site)
LocalUserLanguage::update(pool, vec![], local_user_.id).await?;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Added another change here, this isnt necessary anymore and was causing some confusion.

// If its the initial site setup, they are an admin
.admin(Some(!local_site.site_setup))
.build();

let inserted_local_user = LocalUser::create(&mut context.pool(), &local_user_form).await?;

let all_languages = Language::read_all(&mut context.pool()).await?;
Copy link
Member

Choose a reason for hiding this comment

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

Some tests are failing, which tells me something is wrong with moving this logic from the LocalUser::create (which is run in the unit tests), and this, which is only run from the API.

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought if a user has all languages enabled, thats stored by having nothing at all in LocalUserLanguage table. But thats not the case, we actually need to store all 184 language rows. So I had to add the update call back in. To avoid writing new user languages twice (first all languages, then those from accept-languages header), Ive removed the impl Crud for LocalUser and instead implemented create directly, so that languages can be passed in.

@dessalines dessalines merged commit 846848c into main Mar 25, 2024
1 of 2 checks passed
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.

4 participants