Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions crates/control/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ pub enum Command {
SetPublicProfile {
on: bool,
},
/// Who sees the player's scores on boards: `ScorePrivacy`.
ScorePrivacy,
/// `{scores}`: `friends`, `everyone` or `nobody`.
SetScorePrivacy {
scores: anyplay_api::Audience,
},
/// The people the player played with recently: `{remember, people}`.
PlayedWith,
/// Empties that list.
Expand Down Expand Up @@ -1528,6 +1534,19 @@ mod tests {
parse_command(r#"{"id":8,"do":"set_public_profile","on":true}"#),
Ok((8, Command::SetPublicProfile { on: true }))
);
assert_eq!(
parse_command(r#"{"id":20,"do":"score_privacy"}"#),
Ok((20, Command::ScorePrivacy))
);
assert_eq!(
parse_command(r#"{"id":21,"do":"set_score_privacy","scores":"nobody"}"#),
Ok((
21,
Command::SetScorePrivacy {
scores: anyplay_api::Audience::Nobody
}
))
);
assert_eq!(
parse_command(r#"{"id":9,"do":"played_with"}"#),
Ok((9, Command::PlayedWith))
Expand Down
17 changes: 14 additions & 3 deletions crates/net/src/cloud.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ use std::time::Duration;
use anyplay_api::client::{CLIENT_HEADER, ClientId};
use anyplay_api::{
AcceptShare, AccountId, AccountLink, AccountTrophies, AddToConversation, Added, ApiError,
AppealRequest, AppearOffline, BrowserTokenRequest, Cards, CodeAnswer, CodeRequest,
AppealRequest, AppearOffline, Audience, BrowserTokenRequest, Cards, CodeAnswer, CodeRequest,
Conversation, Conversations, CreateConversation, CreateSession, CreateShare, Device,
DiscordCodeExchange, DiscordRefresh, DiscordTokens, EmailAnswer, EmailRequest, ErrorCode,
FriendLists, FriendRequest, FriendRequestAnswer, Info, Invite, Invited, JoinCode, JoinSession,
MarkRead, Me, Message, Messages, MoveParty, Party, PartyEndpoint, PartyInvitations,
PlayedWithList, PlaytimeAdded, PlaytimeEntry, PlaytimeUpload, PresenceRequest, Privacy,
ProfilePage, PublicProfile, Rarity, ReactionRequest, Reactions, Redeemed, RefreshRequest,
Relays, RememberPlayedWith, Report, RunReport, RunSummary, SecretsChanged, SendMessage,
Session, Share, ShareInvitations, SignedIn, SignupRequest, Statement, Statements,
Relays, RememberPlayedWith, Report, RunReport, RunSummary, ScorePrivacy, SecretsChanged,
SendMessage, Session, Share, ShareInvitations, SignedIn, SignupRequest, Statement, Statements,
TicketRequest, Tokens, TrophiesAdded, Trophy, TrophyCompare, TrophyNumbers, TrophyUpload,
UpdateParty, UpdateSession, UpdateShare, path,
};
Expand Down Expand Up @@ -750,6 +750,17 @@ impl Cloud {
.await
}

pub async fn score_privacy(&self) -> Result<ScorePrivacy, CloudError> {
self.call::<(), _>(Method::GET, path::SCORE_PRIVACY, None)
.await
}

pub async fn set_score_privacy(&self, scores: Audience) -> Result<ScorePrivacy, CloudError> {
let body = ScorePrivacy { scores };
self.call(Method::PUT, path::SCORE_PRIVACY, Some(&body))
.await
}

pub async fn privacy(&self) -> Result<Privacy, CloudError> {
self.call::<(), _>(Method::GET, path::PRIVACY, None).await
}
Expand Down
16 changes: 16 additions & 0 deletions crates/net/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,22 @@ impl Service {
|_, p| p,
);
}
Command::ScorePrivacy => {
let Some(cloud) = self.signed_in_cloud(id) else {
return;
};
self.request(id, async move { cloud.score_privacy().await }, |_, p| p);
}
Command::SetScorePrivacy { scores } => {
let Some(cloud) = self.signed_in_cloud(id) else {
return;
};
self.request(
id,
async move { cloud.set_score_privacy(scores).await },
|_, p| p,
);
}
Command::Privacy => {
let Some(cloud) = self.signed_in_cloud(id) else {
return;
Expand Down
2 changes: 2 additions & 0 deletions spec/control-protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ When the cloud retires this launcher's version ([cloud API](cloud-api.md#convent
| `played_with` | | `{remember, people}`: the people the player played with recently ([Played with recently](cloud-api.md#played-with-recently)) |
| `clear_played_with` | | `{}`: empties that list |
| `set_remember_played_with` | `on` | `{remember_played_with}`: the new setting |
| `score_privacy` | | `{scores}`: who sees the player's scores on boards (`friends`, `everyone` or `nobody`; `friends` for a new account), see [Leaderboards](cloud-api.md#leaderboards); works while the leaderboard feature is off |
| `set_score_privacy` | `scores` | `{scores}`: the new setting |
| `privacy` | | the player's `Privacy` |
| `set_privacy` | `privacy` | the new `Privacy` |
| `profile` | `account` | `ProfilePage`: the `Profile` with the parts the player may see of that account, their trophy counts (null when hidden) and the connections they show (`links`) |
Expand Down
Loading