store delete model IP address

This commit is contained in:
Brandon Thomas committed 2021-07-10 13:08:17 -04:00
1 parent b8e4dadaf3
commit f24cdb6d38
2 files changed
+10 -3

No files matched your search

+6
View File
@@ -3,17 +3,20 @@ use sqlx::MySqlPool;
pub async fn delete_tts_model_as_user(
tts_model_token: &str,
creator_ip_address: &str,
mysql_pool: &MySqlPool,
) -> AnyhowResult<()> {
let _r = sqlx::query!(
r#"
UPDATE tts_models
SET
creator_ip_address_last_update = ?,
user_deleted_at = CURRENT_TIMESTAMP
WHERE
token = ?
LIMIT 1
"#,
creator_ip_address,
tts_model_token,
)
.execute(mysql_pool)
@@ -46,17 +49,20 @@ LIMIT 1
pub async fn undelete_tts_model_as_user(
tts_model_token: &str,
creator_ip_address: &str,
mysql_pool: &MySqlPool,
) -> AnyhowResult<()> {
let _r = sqlx::query!(
r#"
UPDATE tts_models
SET
creator_ip_address_last_update = ?,
user_deleted_at = NULL
WHERE
token = ?
LIMIT 1
"#,
creator_ip_address,
tts_model_token,
)
.execute(mysql_pool)
@@ -118,8 +118,7 @@ pub async fn delete_tts_model_handler(
return Err(DeleteTtsModelError::NotAuthorized);
}
// NB: I can't imagine we need to store this.
// let ip_address = get_request_ip(&http_request);
let ip_address = get_request_ip(&http_request);
let as_mod = delete_as_mod(is_mod, is_author, request.as_mod);
@@ -133,7 +132,8 @@ pub async fn delete_tts_model_handler(
} else {
delete_tts_model_as_user(
&path.token,
&server_state.mysql_pool
&ip_address,
&server_state.mysql_pool,
).await
}
} else {
@@ -147,6 +147,7 @@ pub async fn delete_tts_model_handler(
// NB: Technically only mods can see their own inference_results here
undelete_tts_model_as_user(
&path.token,
&ip_address,
&server_state.mysql_pool
).await
}