new finctions and fixes
This commit is contained in:
+28
-6
@@ -38,17 +38,39 @@ pub fn get(query: Query) -> &'static str {
|
||||
Query::RESOURCE_COLOR_DELETE => {
|
||||
r#"DELETE FROM user_resource_colors WHERE user_id = ? AND resource_kind = ? AND resource_slug = ?"#
|
||||
}
|
||||
|
||||
Query::RESOURCE_COLOR_INSERT => {
|
||||
r#"INSERT INTO user_resource_colors (user_id, resource_kind, resource_slug, color) VALUES (?, ?, ?, ?)"#
|
||||
}
|
||||
Query::RESOURCE_COLORS_DELETE_BY_RESOURCE => {
|
||||
r#"DELETE FROM user_resource_colors WHERE resource_kind = ? AND resource_slug = ?"#
|
||||
}
|
||||
Query::RESOURCE_COLORS_DELETE_BY_USER => {
|
||||
r#"DELETE FROM user_resource_colors WHERE user_id = ?"#
|
||||
}
|
||||
Query::RESOURCE_EDITOR_SETTINGS_SELECT => {
|
||||
r#"SELECT authorship_mode, CASE WHEN colors_enabled THEN 1 ELSE 0 END FROM resource_editor_settings WHERE resource_kind = ? AND resource_slug = ?"#
|
||||
r#"SELECT CAST(authorship_mode AS CHAR CHARACTER SET utf8mb4), CAST(CASE WHEN colors_enabled THEN 1 ELSE 0 END AS SIGNED) FROM resource_editor_settings WHERE resource_kind = ? AND resource_slug = ?"#
|
||||
}
|
||||
Query::RESOURCE_EDITOR_SETTINGS_UPSERT => {
|
||||
r#"INSERT INTO resource_editor_settings (resource_kind, resource_slug, authorship_mode, colors_enabled, updated_at) VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP) ON DUPLICATE KEY UPDATE authorship_mode = VALUES(authorship_mode), colors_enabled = VALUES(colors_enabled), updated_at = CURRENT_TIMESTAMP"#
|
||||
}
|
||||
Query::RESOURCE_EDITOR_SETTINGS_DELETE => {
|
||||
r#"DELETE FROM resource_editor_settings WHERE resource_kind = ? AND resource_slug = ?"#
|
||||
}
|
||||
Query::RESOURCE_EDITOR_SETTINGS_INSERT => {
|
||||
r#"INSERT INTO resource_editor_settings (resource_kind, resource_slug, authorship_mode, colors_enabled) VALUES (?, ?, ?, ?)"#
|
||||
Query::EDITOR_PREFERENCES_SELECT_PAD => {
|
||||
r#"SELECT CAST(CASE WHEN compact_view THEN 1 ELSE 0 END AS SIGNED), CAST(CASE WHEN editor_line_numbers THEN 1 ELSE 0 END AS SIGNED), CAST(CASE WHEN preview_line_numbers THEN 1 ELSE 0 END AS SIGNED), CAST(CASE WHEN line_links THEN 1 ELSE 0 END AS SIGNED), CAST(font_family AS CHAR CHARACTER SET utf8mb4), font_size FROM user_editor_preferences WHERE user_id = ? AND pad_id = ?"#
|
||||
}
|
||||
Query::RESOURCE_COLOR_INSERT => {
|
||||
r#"INSERT INTO user_resource_colors (user_id, resource_kind, resource_slug, color) VALUES (?, ?, ?, ?)"#
|
||||
Query::EDITOR_PREFERENCES_SELECT_NOTE => {
|
||||
r#"SELECT CAST(CASE WHEN compact_view THEN 1 ELSE 0 END AS SIGNED), CAST(CASE WHEN editor_line_numbers THEN 1 ELSE 0 END AS SIGNED), CAST(CASE WHEN preview_line_numbers THEN 1 ELSE 0 END AS SIGNED), CAST(CASE WHEN line_links THEN 1 ELSE 0 END AS SIGNED), CAST(font_family AS CHAR CHARACTER SET utf8mb4), font_size FROM user_editor_preferences WHERE user_id = ? AND note_id = ?"#
|
||||
}
|
||||
Query::EDITOR_PREFERENCES_UPSERT_PAD => {
|
||||
r#"INSERT INTO user_editor_preferences (user_id, pad_id, note_id, compact_view, editor_line_numbers, preview_line_numbers, line_links, font_family, font_size, updated_at) VALUES (?, ?, NULL, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP) ON DUPLICATE KEY UPDATE compact_view = VALUES(compact_view), editor_line_numbers = VALUES(editor_line_numbers), preview_line_numbers = VALUES(preview_line_numbers), line_links = VALUES(line_links), font_family = VALUES(font_family), font_size = VALUES(font_size), updated_at = CURRENT_TIMESTAMP"#
|
||||
}
|
||||
Query::EDITOR_PREFERENCES_UPSERT_NOTE => {
|
||||
r#"INSERT INTO user_editor_preferences (user_id, pad_id, note_id, compact_view, editor_line_numbers, preview_line_numbers, line_links, font_family, font_size, updated_at) VALUES (?, NULL, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP) ON DUPLICATE KEY UPDATE compact_view = VALUES(compact_view), editor_line_numbers = VALUES(editor_line_numbers), preview_line_numbers = VALUES(preview_line_numbers), line_links = VALUES(line_links), font_family = VALUES(font_family), font_size = VALUES(font_size), updated_at = CURRENT_TIMESTAMP"#
|
||||
}
|
||||
Query::EDITOR_PREFERENCES_DELETE_BY_USER => {
|
||||
r#"DELETE FROM user_editor_preferences WHERE user_id = ?"#
|
||||
}
|
||||
Query::AUTH_ACCOUNT_ACTION_BY_TOKEN => {
|
||||
r#"SELECT user_id, action, CAST(payload AS CHAR CHARACTER SET utf8mb4) AS payload, expires_at, used_at FROM account_action_tokens WHERE token = ?"#
|
||||
@@ -85,7 +107,7 @@ pub fn get(query: Query) -> &'static str {
|
||||
}
|
||||
Query::AUTH_DELETE_USER => r#"DELETE FROM users WHERE id = ?"#,
|
||||
Query::AUTH_ANONYMIZE_USER => {
|
||||
r#"UPDATE users SET nickname = ?, nickname_key = ?, email = ?, email_key = ?, password_hash = ?, is_active = 0, auth_provider = 'deleted', external_id = NULL, external_dn = NULL, directory_display_name = NULL, directory_username = NULL, updated_at = ? WHERE id = ?"#
|
||||
r#"UPDATE users SET nickname = ?, nickname_key = ?, email = ?, email_key = ?, password_hash = ?, is_active = 0, auth_provider = 'deleted', external_id = NULL, external_dn = NULL, directory_display_name = NULL, directory_username = NULL, editor_color = NULL, updated_at = ? WHERE id = ?"#
|
||||
}
|
||||
Query::AUTH_NICKNAME_BY_ID => r#"SELECT nickname FROM users WHERE id = ?"#,
|
||||
Query::AUTH_ANONYMIZE_NOTE_CREATORS => {
|
||||
|
||||
Reference in New Issue
Block a user