mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-10 12:01:36 +00:00
result visibility editing fix
This commit is contained in:
1 parent
bf10676680
commit
e4aa009750
1 file changed
+44
-37
@@ -54,8 +54,8 @@ pub struct EditProfileRequest {
|
||||
pub cashapp_username: Option<String>,
|
||||
pub website_url: Option<String>,
|
||||
|
||||
pub preferred_tts_result_visibility: RecordVisibility,
|
||||
pub preferred_w2l_result_visibility: RecordVisibility,
|
||||
pub preferred_tts_result_visibility: Option<RecordVisibility>,
|
||||
pub preferred_w2l_result_visibility: Option<RecordVisibility>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
@@ -244,44 +244,17 @@ pub async fn edit_profile_handler(
|
||||
|
||||
let ip_address = get_request_ip(&http_request);
|
||||
|
||||
let preferred_tts_result_visibility = request.preferred_tts_result_visibility
|
||||
.unwrap_or(RecordVisibility::Hidden);
|
||||
|
||||
let preferred_w2l_result_visibility = request.preferred_w2l_result_visibility
|
||||
.unwrap_or(RecordVisibility::Hidden);
|
||||
|
||||
let query_result = if editor_is_original_user {
|
||||
// We need to store the IP address details.
|
||||
sqlx::query!(
|
||||
r#"
|
||||
UPDATE users
|
||||
SET
|
||||
profile_markdown = ?,
|
||||
profile_rendered_html = ?,
|
||||
discord_username = ?,
|
||||
twitter_username = ?,
|
||||
twitch_username = ?,
|
||||
github_username = ?,
|
||||
cashapp_username = ?,
|
||||
website_url = ?,
|
||||
ip_address_last_update = ?,
|
||||
version = version + 1
|
||||
|
||||
WHERE users.token = ?
|
||||
LIMIT 1
|
||||
"#,
|
||||
profile_markdown,
|
||||
profile_html,
|
||||
discord_username,
|
||||
twitter_username,
|
||||
twitch_username,
|
||||
github_username,
|
||||
cashapp_username,
|
||||
website_url,
|
||||
ip_address.clone(),
|
||||
user_record.user_token.clone(),
|
||||
)
|
||||
.execute(&server_state.mysql_pool)
|
||||
.await
|
||||
} else {
|
||||
// We need to store the moderator details.
|
||||
sqlx::query!(
|
||||
r#"
|
||||
UPDATE users
|
||||
SET
|
||||
profile_markdown = ?,
|
||||
profile_rendered_html = ?,
|
||||
@@ -293,6 +266,42 @@ SET
|
||||
github_username = ?,
|
||||
cashapp_username = ?,
|
||||
website_url = ?,
|
||||
ip_address_last_update = ?,
|
||||
version = version + 1
|
||||
|
||||
WHERE users.token = ?
|
||||
LIMIT 1
|
||||
"#,
|
||||
profile_markdown,
|
||||
profile_html,
|
||||
preferred_tts_result_visibility.to_str(),
|
||||
preferred_w2l_result_visibility.to_str(),
|
||||
discord_username,
|
||||
twitter_username,
|
||||
twitch_username,
|
||||
github_username,
|
||||
cashapp_username,
|
||||
website_url,
|
||||
ip_address.clone(),
|
||||
user_record.user_token.clone(),
|
||||
)
|
||||
.execute(&server_state.mysql_pool)
|
||||
.await
|
||||
} else {
|
||||
// We need to store the moderator details.
|
||||
// Also, mods shouldn't change user preferences.
|
||||
sqlx::query!(
|
||||
r#"
|
||||
UPDATE users
|
||||
SET
|
||||
profile_markdown = ?,
|
||||
profile_rendered_html = ?,
|
||||
discord_username = ?,
|
||||
twitter_username = ?,
|
||||
twitch_username = ?,
|
||||
github_username = ?,
|
||||
cashapp_username = ?,
|
||||
website_url = ?,
|
||||
version = version + 1
|
||||
|
||||
WHERE users.token = ?
|
||||
@@ -300,8 +309,6 @@ LIMIT 1
|
||||
"#,
|
||||
profile_markdown,
|
||||
profile_html,
|
||||
request.preferred_tts_result_visibility,
|
||||
request.preferred_w2l_result_visibility,
|
||||
discord_username,
|
||||
twitter_username,
|
||||
twitch_username,
|
||||
|
||||
Reference in new issue
Block a user