-
-
Notifications
You must be signed in to change notification settings - Fork 885
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
[Bug]: PUT requests to /site fail if application_question is not provided, even if the question has already been configured for the site #3323
Comments
One thing I forgot to mention is that the instance needs to have been configured to require registration application but that is the default nowadays. |
This is the fix I am using temporarily: diff --git a/crates/api_crud/src/site/create.rs b/crates/api_crud/src/site/create.rs
index 2a51309a4..8252e299a 100644
--- a/crates/api_crud/src/site/create.rs
+++ b/crates/api_crud/src/site/create.rs
@@ -81,6 +81,7 @@ impl PerformCrud for CreateSite {
data
.registration_mode
.unwrap_or(local_site.registration_mode),
+ &local_site,
)?;
let actor_id: DbUrl = Url::parse(&context.settings().get_protocol_and_hostname())?.into();
diff --git a/crates/api_crud/src/site/mod.rs b/crates/api_crud/src/site/mod.rs
index d0c09b935..793a671eb 100644
--- a/crates/api_crud/src/site/mod.rs
+++ b/crates/api_crud/src/site/mod.rs
@@ -1,4 +1,4 @@
-use lemmy_db_schema::RegistrationMode;
+use lemmy_db_schema::{source::local_site::LocalSite, RegistrationMode};
use lemmy_utils::error::LemmyError;
mod create;
@@ -8,9 +8,11 @@ mod update;
pub fn check_application_question(
application_question: &Option<Option<String>>,
registration_mode: RegistrationMode,
+ local_site: &LocalSite,
) -> Result<(), LemmyError> {
if registration_mode == RegistrationMode::RequireApplication
&& application_question.as_ref().unwrap_or(&None).is_none()
+ && local_site.application_question.is_none()
{
Err(LemmyError::from_message("application_question_required"))
} else {
diff --git a/crates/api_crud/src/site/update.rs b/crates/api_crud/src/site/update.rs
index fadde0a0b..433126e0d 100644
--- a/crates/api_crud/src/site/update.rs
+++ b/crates/api_crud/src/site/update.rs
@@ -75,6 +75,7 @@ impl PerformCrud for EditSite {
data
.registration_mode
.unwrap_or(local_site.registration_mode),
+ &local_site,
)?;
if let Some(listing_type) = &data.default_post_listing_type { Feel free to suggest changes to it. I can file a PR after that. |
@kartikynwa I noticed that modifying Taglines also shows this same error. Does your current fix resolve that as well? Like you mentioned, changing the registration setting is a workaround. Setting Registration Mode to Close Registration temporarily allows you to change both the rates and taglines. Here is the error log for the tagline for reference.
|
@samifinge Yeah it should fix that too. :) |
Please make a pull request. |
Filed #3372 |
Was actually fixed in #3146 |
Requirements
Summary
If I try to update the rate limit from the UI, the PUT request fails with this error:
This code is only checking whether application_question is a valid value in the request body and not if the application question has already been set:
lemmy/crates/api_crud/src/site/update.rs
Lines 72 to 78 in 63d3759
As such a request with this body fails:
Steps to Reproduce
Technical Details
Backend log
Version
BE 0.18.0
Lemmy Instance URL
No response
The text was updated successfully, but these errors were encountered: