forked from AxTps/Starlight_Lancher
refactor: 移除遥测并修复启动器流程
This commit is contained in:
@ -69,7 +69,6 @@ pub use self::projects::{
|
||||
pub use self::run::{
|
||||
GcLaunchIntent, GcLaunchReport, QuickPlayType, kill, run,
|
||||
run_with_extra_launch_args, run_with_extra_launch_args_with_gc,
|
||||
try_update_playtime_by_instance_id,
|
||||
};
|
||||
pub use self::upgrade::{
|
||||
dismiss_instance_post_upgrade_notice, execute_instance_upgrade,
|
||||
|
||||
@ -6,7 +6,6 @@ use crate::state::instances::{
|
||||
PackMemberOverrideKind,
|
||||
};
|
||||
use crate::state::{ContentProvider, ContentSourceKind, ProjectType, State};
|
||||
use crate::util::fetch;
|
||||
use modrinth_content_management::{
|
||||
ContentType, ResolutionPreferences, ResolveContentPlan,
|
||||
};
|
||||
@ -85,16 +84,12 @@ pub async fn update_project(
|
||||
pub async fn add_project_from_version(
|
||||
instance_id: &str,
|
||||
version_id: &str,
|
||||
reason: fetch::DownloadReason,
|
||||
dependent_on_version_id: Option<String>,
|
||||
) -> crate::Result<String> {
|
||||
let state = State::get().await?;
|
||||
let project_path =
|
||||
crate::state::instances::commands::add_project_from_version(
|
||||
instance_id,
|
||||
version_id,
|
||||
reason,
|
||||
dependent_on_version_id,
|
||||
crate::state::ContentSourceKind::Local,
|
||||
crate::state::instances::ContentOwnershipKind::UserAdded,
|
||||
&state,
|
||||
@ -674,8 +669,6 @@ pub async fn restore_pack_member_default(
|
||||
crate::state::instances::commands::add_project_from_version(
|
||||
instance_id,
|
||||
release_id,
|
||||
fetch::DownloadReason::Update,
|
||||
None,
|
||||
ContentSourceKind::ModrinthModpack,
|
||||
ContentOwnershipKind::PackManaged,
|
||||
&state,
|
||||
|
||||
@ -1,17 +1,10 @@
|
||||
use super::content::get_projects;
|
||||
use crate::server_address::ServerAddress;
|
||||
use crate::state::{
|
||||
Credentials, InstanceInstallStage, InstanceLink, ProcessMetadata, Settings,
|
||||
State,
|
||||
Credentials, InstanceInstallStage, ProcessMetadata, Settings, State,
|
||||
};
|
||||
use crate::util::fetch;
|
||||
use crate::util::io::IOError;
|
||||
use crate::util::mojang::mojang_service_url;
|
||||
use serde_json::json;
|
||||
use std::collections::HashMap;
|
||||
use std::time::Duration;
|
||||
use tokio::process::Command;
|
||||
use tracing::{info, warn};
|
||||
|
||||
pub use crate::launcher::jvm_args::{GcLaunchIntent, GcLaunchReport};
|
||||
|
||||
@ -253,60 +246,6 @@ async fn run_credentials(
|
||||
mc_set_options.push(("fullscreen".to_string(), "true".to_string()));
|
||||
}
|
||||
|
||||
if credentials.is_microsoft()
|
||||
&& let Some(project_id) = server_play_project_id(&context.link)
|
||||
&& !project_id.trim().is_empty()
|
||||
{
|
||||
let server_id = uuid::Uuid::new_v4().to_string();
|
||||
let join_url = mojang_service_url(
|
||||
"https://sessionserver.mojang.com/session/minecraft/join",
|
||||
state.mojang_auth_use_mirror(),
|
||||
);
|
||||
let join_result = fetch::INSECURE_REQWEST_CLIENT
|
||||
.post(join_url.as_ref())
|
||||
.json(&json!({
|
||||
"accessToken": &credentials.access_token,
|
||||
"selectedProfile": credentials.offline_profile.id.simple().to_string(),
|
||||
"serverId": &server_id,
|
||||
}))
|
||||
.timeout(Duration::from_secs(5))
|
||||
.send()
|
||||
.await;
|
||||
|
||||
match join_result {
|
||||
Ok(resp) if resp.status().is_success() => {
|
||||
let result = fetch::post_json(
|
||||
concat!(
|
||||
env!("MODRINTH_API_BASE_URL"),
|
||||
"analytics/minecraft-server-play"
|
||||
),
|
||||
json!({
|
||||
"project_id": project_id,
|
||||
"username": &credentials.offline_profile.name,
|
||||
"server_id": &server_id,
|
||||
}),
|
||||
&state.api_semaphore,
|
||||
&state.pool,
|
||||
)
|
||||
.await;
|
||||
|
||||
match result {
|
||||
Ok(()) => {
|
||||
info!(
|
||||
"Tracked server play for '{project_id}' in analytics"
|
||||
)
|
||||
}
|
||||
Err(err) => warn!("Failed to report server play: {err:?}"),
|
||||
}
|
||||
}
|
||||
Ok(resp) => warn!(
|
||||
"Failed to join Mojang session server: HTTP {}",
|
||||
resp.status()
|
||||
),
|
||||
Err(err) => warn!("Failed to join Mojang session server: {err:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
if offline_mode {
|
||||
crate::minecraft_skins::flush_pending_skin_change_for_profile(
|
||||
credentials.offline_profile.id,
|
||||
@ -368,40 +307,6 @@ async fn run_credentials(
|
||||
Ok((process, gc_report))
|
||||
}
|
||||
|
||||
fn server_play_project_id(link: &InstanceLink) -> Option<&String> {
|
||||
match link {
|
||||
InstanceLink::ServerProject { project_id }
|
||||
| InstanceLink::ServerProjectModpack {
|
||||
server_project_id: project_id,
|
||||
..
|
||||
} => Some(project_id),
|
||||
InstanceLink::Unmanaged
|
||||
| InstanceLink::ModrinthModpack { .. }
|
||||
| InstanceLink::CurseForgeModpack { .. }
|
||||
| InstanceLink::ImportedModpack { .. }
|
||||
| InstanceLink::SharedInstance { .. } => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn modrinth_pack_version_id(link: &InstanceLink) -> Option<&str> {
|
||||
match link {
|
||||
InstanceLink::ModrinthModpack { version_id, .. }
|
||||
| InstanceLink::ServerProjectModpack {
|
||||
content_version_id: version_id,
|
||||
..
|
||||
} => Some(version_id),
|
||||
InstanceLink::Unmanaged
|
||||
| InstanceLink::ServerProject { .. }
|
||||
| InstanceLink::CurseForgeModpack { .. }
|
||||
| InstanceLink::ImportedModpack { .. }
|
||||
| InstanceLink::SharedInstance { .. } => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn playtime_api_url(base_url: &str) -> String {
|
||||
format!("{}/analytics/playtime", base_url.trim_end_matches('/'))
|
||||
}
|
||||
|
||||
pub async fn kill(instance_id: &str) -> crate::Result<()> {
|
||||
let state = State::get().await?;
|
||||
let processes =
|
||||
@ -413,104 +318,3 @@ pub async fn kill(instance_id: &str) -> crate::Result<()> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
pub async fn try_update_playtime_by_instance_id(
|
||||
instance_id: &str,
|
||||
) -> crate::Result<()> {
|
||||
let state = State::get().await?;
|
||||
let context =
|
||||
crate::state::instances::commands::get_instance_launch_context(
|
||||
instance_id,
|
||||
&state.pool,
|
||||
)
|
||||
.await?
|
||||
.ok_or_else(|| {
|
||||
crate::ErrorKind::OtherError(format!(
|
||||
"Tried to update playtime for nonexistent instance {instance_id}!"
|
||||
))
|
||||
})?;
|
||||
let updated_recent_playtime = context.instance.recent_time_played;
|
||||
let res = if updated_recent_playtime > 0 {
|
||||
let modrinth_pack_version_id = modrinth_pack_version_id(&context.link);
|
||||
let playtime_update_json = json!({
|
||||
"seconds": updated_recent_playtime,
|
||||
"loader": context.applied_content_set.loader.as_str(),
|
||||
"game_version": &context.applied_content_set.game_version,
|
||||
"parent": modrinth_pack_version_id,
|
||||
});
|
||||
let mut hashmap: HashMap<String, serde_json::Value> = HashMap::new();
|
||||
|
||||
for (_, project) in get_projects(instance_id, None).await? {
|
||||
if let Some(metadata) = project.modrinth {
|
||||
hashmap.insert(
|
||||
metadata.version_id.to_string(),
|
||||
playtime_update_json.clone(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let playtime_url = playtime_api_url(env!("MODRINTH_API_BASE_URL"));
|
||||
fetch::post_json(
|
||||
&playtime_url,
|
||||
serde_json::to_value(hashmap)?,
|
||||
&state.api_semaphore,
|
||||
&state.pool,
|
||||
)
|
||||
.await
|
||||
} else {
|
||||
Ok(())
|
||||
};
|
||||
|
||||
if res.is_ok() {
|
||||
crate::state::instances::commands::mark_instance_playtime_submitted(
|
||||
&context.instance.id,
|
||||
updated_recent_playtime,
|
||||
&state.pool,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
res
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{modrinth_pack_version_id, playtime_api_url};
|
||||
use crate::state::InstanceLink;
|
||||
|
||||
#[test]
|
||||
fn playtime_parent_requires_an_explicit_modrinth_link() {
|
||||
let modrinth = InstanceLink::ModrinthModpack {
|
||||
project_id: "project".to_string(),
|
||||
version_id: "version".to_string(),
|
||||
};
|
||||
let curseforge = InstanceLink::CurseForgeModpack {
|
||||
project_id: "123".to_string(),
|
||||
version_id: "456".to_string(),
|
||||
};
|
||||
let imported = InstanceLink::ImportedModpack {
|
||||
project_id: Some("legacy-project".to_string()),
|
||||
version_id: Some("legacy-version".to_string()),
|
||||
name: None,
|
||||
version_number: None,
|
||||
filename: None,
|
||||
};
|
||||
|
||||
assert_eq!(modrinth_pack_version_id(&modrinth), Some("version"));
|
||||
assert_eq!(modrinth_pack_version_id(&curseforge), None);
|
||||
assert_eq!(modrinth_pack_version_id(&imported), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn playtime_url_has_a_single_path_separator() {
|
||||
assert_eq!(
|
||||
playtime_api_url("https://api.modrinth.com"),
|
||||
"https://api.modrinth.com/analytics/playtime"
|
||||
);
|
||||
assert_eq!(
|
||||
playtime_api_url("https://api.modrinth.com/"),
|
||||
"https://api.modrinth.com/analytics/playtime"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1096,7 +1096,7 @@ async fn fetch_maven_metadata(
|
||||
fetch_semaphore: &FetchSemaphore,
|
||||
pool: &SqlitePool,
|
||||
) -> crate::Result<MavenMetadata> {
|
||||
let bytes = fetch(url, None, None, None, fetch_semaphore, pool).await?;
|
||||
let bytes = fetch(url, None, None, fetch_semaphore, pool).await?;
|
||||
let xml = std::str::from_utf8(&bytes).map_err(|error| {
|
||||
crate::ErrorKind::OtherError(format!(
|
||||
"Maven metadata at {url} was not UTF-8: {error}"
|
||||
@ -1116,8 +1116,7 @@ async fn fetch_forge_maven_metadata(
|
||||
fetch_semaphore: &FetchSemaphore,
|
||||
pool: &SqlitePool,
|
||||
) -> crate::Result<MavenMetadata> {
|
||||
let bytes =
|
||||
fetch_official(url, None, None, None, fetch_semaphore, pool).await?;
|
||||
let bytes = fetch_official(url, None, None, fetch_semaphore, pool).await?;
|
||||
let xml = std::str::from_utf8(&bytes).map_err(|error| {
|
||||
crate::ErrorKind::OtherError(format!(
|
||||
"Forge Maven metadata at {url} was not UTF-8: {error}"
|
||||
@ -1651,15 +1650,9 @@ async fn resolve_installer_profile(
|
||||
state: &State,
|
||||
installer_url: &str,
|
||||
) -> crate::Result<PartialVersionInfo> {
|
||||
let bytes = fetch(
|
||||
installer_url,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
&state.api_semaphore,
|
||||
&state.pool,
|
||||
)
|
||||
.await?;
|
||||
let bytes =
|
||||
fetch(installer_url, None, None, &state.api_semaphore, &state.pool)
|
||||
.await?;
|
||||
let installer_url = installer_url.to_string();
|
||||
let parsed = tokio::task::spawn_blocking(move || {
|
||||
parse_installer(bytes.to_vec(), &installer_url)
|
||||
@ -1702,7 +1695,6 @@ pub(crate) async fn ensure_installer_artifacts(
|
||||
&installer_url.client,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
&state.api_semaphore,
|
||||
&state.pool,
|
||||
)
|
||||
|
||||
@ -65,9 +65,9 @@ pub mod data {
|
||||
ManualDownloadOperationKind, ManualDownloadState, MemorySettings,
|
||||
ModLoader, ModrinthCredentials, Organization, OwnerType,
|
||||
PackMemberMaterializationState, PackMemberOverrideKind,
|
||||
PendingManualDownload, PrivacySettings, ProcessMetadata, Project,
|
||||
ProjectType, ProjectV3, SearchResult, SearchResults, SearchResultsV3,
|
||||
Settings, ShaderRuntime, TeamMember, Theme, User, UserFriend, Version,
|
||||
PendingManualDownload, ProcessMetadata, Project, ProjectType,
|
||||
ProjectV3, SearchResult, SearchResults, SearchResultsV3, Settings,
|
||||
ShaderRuntime, TeamMember, Theme, User, UserFriend, Version,
|
||||
WindowSize,
|
||||
};
|
||||
pub use ariadne::users::UserStatus;
|
||||
|
||||
@ -117,7 +117,6 @@ pub async fn import_curseforge(
|
||||
&thumbnail_url,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
&state.fetch_semaphore,
|
||||
&state.pool,
|
||||
)
|
||||
|
||||
@ -12,9 +12,8 @@ use crate::state::{
|
||||
ModrinthVersionId, SideType,
|
||||
};
|
||||
use crate::util::fetch::{
|
||||
ContentValidation, DownloadMeta, DownloadReason, DownloadRequest,
|
||||
FetchProgressFn, Integrity, ResourceClass, download_to_path, fetch,
|
||||
sha1_file_async, write_cached_icon,
|
||||
ContentValidation, DownloadRequest, FetchProgressFn, Integrity,
|
||||
ResourceClass, download_to_path, fetch, sha1_file_async, write_cached_icon,
|
||||
};
|
||||
use path_util::SafeRelativeUtf8UnixPathBuf;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -267,7 +266,6 @@ pub(crate) async fn generate_pack_from_version_id_with_reporter(
|
||||
title: String,
|
||||
icon_url: Option<String>,
|
||||
instance_id: String,
|
||||
reason: DownloadReason,
|
||||
reporter: InstallProgressReporter,
|
||||
) -> crate::Result<CreatePack> {
|
||||
let state = State::get().await?;
|
||||
@ -340,22 +338,6 @@ pub(crate) async fn generate_pack_from_version_id_with_reporter(
|
||||
.join(&version_id)
|
||||
.join(file_name);
|
||||
|
||||
let metadata =
|
||||
crate::api::instance::get(&instance_id)
|
||||
.await?
|
||||
.ok_or_else(|| {
|
||||
crate::ErrorKind::InputError(format!(
|
||||
"Unknown instance {instance_id}"
|
||||
))
|
||||
})?;
|
||||
|
||||
let download_meta = DownloadMeta {
|
||||
reason,
|
||||
game_version: metadata.applied_content_set.game_version.clone(),
|
||||
loader: metadata.applied_content_set.loader.as_str().to_string(),
|
||||
dependent_on: Some(version_id.clone()),
|
||||
};
|
||||
|
||||
let details = InstallPhaseDetails::Modpack {
|
||||
project_id: Some(project_id.clone()),
|
||||
version_id: Some(version_id.clone()),
|
||||
@ -430,7 +412,6 @@ pub(crate) async fn generate_pack_from_version_id_with_reporter(
|
||||
..Integrity::default()
|
||||
})
|
||||
.with_h2_range_concurrency(16)
|
||||
.with_download_meta(download_meta)
|
||||
.with_install_tracking(
|
||||
reporter.clone(),
|
||||
pack_path.display().to_string(),
|
||||
@ -487,7 +468,6 @@ pub(crate) async fn generate_pack_from_version_id_with_reporter(
|
||||
&icon_url,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
&state.fetch_semaphore,
|
||||
&state.pool,
|
||||
)
|
||||
|
||||
@ -23,8 +23,8 @@ use crate::state::{
|
||||
Settings, SideType,
|
||||
};
|
||||
use crate::util::fetch::{
|
||||
ContentValidation, DownloadMeta, DownloadReason, DownloadRequest,
|
||||
Integrity, ResourceClass, download_to_path, sha1_file_async,
|
||||
ContentValidation, DownloadRequest, Integrity, ResourceClass,
|
||||
download_to_path, sha1_file_async,
|
||||
};
|
||||
use crate::util::io;
|
||||
use async_zip::base::read::seek::ZipFileReader as SeekZipFileReader;
|
||||
@ -219,7 +219,6 @@ fn missing_required_content_pause(
|
||||
struct ModpackContentInstallContext {
|
||||
instance_id: String,
|
||||
instance_full_path: PathBuf,
|
||||
download_meta: DownloadMeta,
|
||||
pack_version_id: Option<String>,
|
||||
pack_project_id: Option<String>,
|
||||
reporter: InstallProgressReporter,
|
||||
@ -689,7 +688,6 @@ where
|
||||
pub(crate) async fn install_zipped_mrpack_files_with_reporter(
|
||||
create_pack: CreatePack,
|
||||
ignore_lock: bool,
|
||||
reason: DownloadReason,
|
||||
reporter: InstallProgressReporter,
|
||||
) -> crate::Result<MrpackInstallOutcome> {
|
||||
let state = &State::get().await?;
|
||||
@ -806,21 +804,6 @@ pub(crate) async fn install_zipped_mrpack_files_with_reporter(
|
||||
)
|
||||
.await?;
|
||||
|
||||
let metadata =
|
||||
crate::api::instance::get(&instance_id)
|
||||
.await?
|
||||
.ok_or_else(|| {
|
||||
crate::ErrorKind::InputError(format!(
|
||||
"Unknown instance {instance_id}"
|
||||
))
|
||||
})?;
|
||||
let download_meta = DownloadMeta {
|
||||
reason,
|
||||
game_version: metadata.applied_content_set.game_version.clone(),
|
||||
loader: metadata.applied_content_set.loader.as_str().to_string(),
|
||||
dependent_on: version_id.clone(),
|
||||
};
|
||||
|
||||
let num_files = pack.files.len();
|
||||
let content_total_bytes = pack
|
||||
.files
|
||||
@ -892,7 +875,6 @@ pub(crate) async fn install_zipped_mrpack_files_with_reporter(
|
||||
let content_context = ModpackContentInstallContext {
|
||||
instance_id: instance_id.clone(),
|
||||
instance_full_path: instance_full_path.clone(),
|
||||
download_meta,
|
||||
pack_version_id: version_id.clone(),
|
||||
pack_project_id: project_id.clone(),
|
||||
reporter: reporter.clone(),
|
||||
@ -1191,9 +1173,6 @@ pub(crate) async fn install_zipped_mrpack_files_with_reporter(
|
||||
project.downloads.iter().skip(1).cloned(),
|
||||
)
|
||||
.with_integrity(integrity)
|
||||
.with_download_meta(
|
||||
content_context.download_meta.clone(),
|
||||
)
|
||||
.with_segmented_download(true)
|
||||
.with_http1_segmented_download(false)
|
||||
.with_install_tracking(
|
||||
|
||||
@ -3,10 +3,7 @@
|
||||
pub use crate::util::download::DownloadEngine;
|
||||
pub use crate::{
|
||||
State,
|
||||
state::{
|
||||
DownloadSourceMode, Hooks, MemorySettings, PrivacySettings, Settings,
|
||||
WindowSize,
|
||||
},
|
||||
state::{DownloadSourceMode, Hooks, MemorySettings, Settings, WindowSize},
|
||||
};
|
||||
|
||||
/// Gets entire settings
|
||||
@ -21,10 +18,6 @@ pub async fn get() -> crate::Result<Settings> {
|
||||
#[tracing::instrument]
|
||||
pub async fn set(mut settings: Settings) -> crate::Result<()> {
|
||||
let state = State::get().await?;
|
||||
let current = Settings::get(&state.pool).await?;
|
||||
settings.telemetry = current.telemetry;
|
||||
settings.telemetry_consent_version = current.telemetry_consent_version;
|
||||
settings.discord_rpc = current.discord_rpc;
|
||||
super::terracotta::validate_public_nodes(
|
||||
&settings.terracotta_public_nodes,
|
||||
)?;
|
||||
@ -46,78 +39,6 @@ pub async fn set_download_engine(engine: DownloadEngine) -> crate::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
pub async fn get_privacy() -> crate::Result<PrivacySettings> {
|
||||
let state = State::get().await?;
|
||||
let settings = Settings::get(&state.pool).await?;
|
||||
Ok(PrivacySettings {
|
||||
telemetry: settings.telemetry,
|
||||
discord_rpc: settings.discord_rpc,
|
||||
consent_version: settings.telemetry_consent_version,
|
||||
})
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
pub async fn set_privacy(
|
||||
privacy: PrivacySettings,
|
||||
) -> crate::Result<PrivacySettings> {
|
||||
let state = State::get().await?;
|
||||
let mut transaction = state.pool.begin().await?;
|
||||
sqlx::query(
|
||||
"UPDATE settings SET telemetry = ?, discord_rpc = ?, telemetry_consent_version = ? WHERE id = 0",
|
||||
)
|
||||
.bind(privacy.telemetry)
|
||||
.bind(privacy.discord_rpc)
|
||||
.bind(privacy.consent_version)
|
||||
.execute(&mut *transaction)
|
||||
.await?;
|
||||
sqlx::query("DELETE FROM telemetry_outbox")
|
||||
.execute(&mut *transaction)
|
||||
.await?;
|
||||
transaction.commit().await?;
|
||||
|
||||
if let Err(error) =
|
||||
crate::telemetry::set_enabled(&state, privacy.telemetry).await
|
||||
{
|
||||
tracing::debug!(target: "theseus::telemetry", %error, "Failed to apply telemetry state");
|
||||
}
|
||||
if let Err(error) = state.discord_rpc.clear_to_default(true).await {
|
||||
tracing::debug!(target: "theseus::telemetry", %error, "Failed to apply Discord RPC state");
|
||||
}
|
||||
get_privacy().await
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
pub async fn set_telemetry(enabled: bool) -> crate::Result<PrivacySettings> {
|
||||
let state = State::get().await?;
|
||||
let mut transaction = state.pool.begin().await?;
|
||||
sqlx::query("UPDATE settings SET telemetry = ? WHERE id = 0")
|
||||
.bind(enabled)
|
||||
.execute(&mut *transaction)
|
||||
.await?;
|
||||
sqlx::query("DELETE FROM telemetry_outbox")
|
||||
.execute(&mut *transaction)
|
||||
.await?;
|
||||
transaction.commit().await?;
|
||||
if let Err(error) = crate::telemetry::set_enabled(&state, enabled).await {
|
||||
tracing::debug!(target: "theseus::telemetry", %error, "Failed to apply telemetry state");
|
||||
}
|
||||
get_privacy().await
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
pub async fn set_discord_rpc(enabled: bool) -> crate::Result<PrivacySettings> {
|
||||
let state = State::get().await?;
|
||||
sqlx::query("UPDATE settings SET discord_rpc = ? WHERE id = 0")
|
||||
.bind(enabled)
|
||||
.execute(&state.pool)
|
||||
.await?;
|
||||
if let Err(error) = state.discord_rpc.clear_to_default(true).await {
|
||||
tracing::debug!(target: "theseus::telemetry", %error, "Failed to apply Discord RPC state");
|
||||
}
|
||||
get_privacy().await
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
pub async fn cancel_directory_change(
|
||||
app_identifier: &str,
|
||||
|
||||
Reference in New Issue
Block a user